Opendigitalradio / etisnoop

etisnoop is a ETI file analyser
GNU General Public License v3.0
9 stars 13 forks source link

Add --std=gnu99 arg to gcc calls #18

Closed hairmare closed 8 years ago

hairmare commented 8 years ago

On CentOS 7.2, gcc seems to need some gentle encouragment to compile episnoop with autotools.

I was experiencing the following issues and found that adding --std=gnu99 through autoconf makes it compile again.

  CC       src/firecode.o
src/firecode.c: In function 'firecode_crc':
src/firecode.c:34:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (size_t len = 0; len < size; len++) {
     ^
src/firecode.c:34:5: note: use option -std=c99 or -std=gnu99 to compile your code
src/firecode.c:35:9: error: 'for' loop initial declarations are only allowed in C99 mode
         for (int i = 0x80; i != 0; i >>= 1) {
         ^
make[1]: *** [src/firecode.o] Error 1
make[1]: Leaving directory `/root/rpmbuild/BUILD/etisnoop-1.1.0'

FWIW, this is the bundled GCCs version on CentOS.

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
mpbraendli commented 8 years ago

Hi, thanks, good you saw that! However, it seems that AM_PROG_CC_C_O is obsolete:

This is an obsolescent macro that checks that the C compiler supports the -c and -o options together. Note that, since Automake 1.14, the AC_PROG_CC is rewritten to implement such checks itself, and thus the explicit use of AM_PROG_CC_C_O should no longer be required. https://www.gnu.org/software/automake/manual/html_node/Public-Macros.html

Does it work if you only add AC_PROG_CC_STDC ? https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/C-Compiler.html

mpb

hairmare commented 8 years ago

I had only added AC_PROG_CC_STDC but autoreconf told me this.

$ sh bootstrap.sh 
Makefile.am:13: warning: compiling 'src/firecode.c' in subdir requires 'AM_PROG_CC_C_O' in 'configure.ac'
You can call ./configure now

It seems that CentOS 7.2 has an old version of automake that doesn't yet contain the change.

$ automake --version
automake (GNU automake) 1.13.4

I'll probably end up adding the call to the deprecated macro using a patch on the RPM build.

Let me know if you'd like me to update this PR so it only contains the AC_PROG_CC_STDC macro.

Maybe it would make sense to add a check for automake 1.14. My autotools skills are rather rusty :/

nickpiggott commented 8 years ago

Just noting that I'm having this problem on Ubuntu.

automake v1.14.1 gcc v4.9.2

hairmare commented 8 years ago

On Ubuntu you'll only need to add AC_PROG_CC_STDC since your automake is up to spec.

I didn't update the PR to only support automake >1.14 since I find the wording in the docs very confusing. According to them the AM_PROG_CC_C_O macro is obsolescent [sic] and should no longer be required 😕

hairmare commented 8 years ago

After looking up obsolescent I rebased this and added a comment.

obsolescent becoming obsolete. "the custom is now obsolescent"

It looks like the automake folks do a lot of planning ahead.

mpbraendli commented 8 years ago

Thanks for the analysis of that issue and for your patch!