[PATCH]: set C dialect when compiling world

Roman Divacky rdivacky at freebsd.org
Tue Jan 13 14:11:58 PST 2009


On Tue, Jan 13, 2009 at 10:55:20PM +0100, Roman Divacky wrote:
> hi
> 
> in my effort to make world compile in gnu99 mode I'd like this
> patch to be commited:
> 
> Index: bsd.sys.mk
> ===================================================================
> RCS file: /home/ncvs/src/share/mk/bsd.sys.mk,v
> retrieving revision 1.47
> diff -u -r1.47 bsd.sys.mk
> --- bsd.sys.mk	23 Jul 2008 06:14:21 -0000	1.47
> +++ bsd.sys.mk	13 Jan 2009 21:36:04 -0000
> @@ -8,8 +8,11 @@
>  
>  # for GCC:  http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143
>  
> -.if !defined(NO_WARNS) && ${CC} != "icc"
> -. if defined(CSTD)
> +# the default is gnu89 for now
> +. if !defined(CSTD)
> +CSTD		= gnu89
> +. endif
> +

CSTD	+= gnu89

of course :)

>  .  if ${CSTD} == "k&r"
>  CFLAGS		+= -traditional
>  .  elif ${CSTD} == "c89" || ${CSTD} == "c90"
> @@ -23,7 +26,8 @@
>  .  endif
>  # -pedantic is problematic because it also imposes namespace restrictions
>  #CFLAGS		+= -pedantic
> -. endif
> +
> +.if !defined(NO_WARNS) && ${CC} != "icc"
>  . if defined(WARNS)
>  .  if ${WARNS} >= 1
>  CWARNFLAGS	+=	-Wsystem-headers
> 
> 
> the rationale behind this:
> 
> we set CSTD to gnu89 so typical {library|app|whatever} build gets added 
> ".... -std=gnu89 ...." to its CFLAGS. the command line looks like this for
> example:
> 
> cc -O2 -pipe -DMALLOC_PRODUCTION -march=native -I/usr/src/lib/libc/include -I/usr/src/lib/libc/../../include
> -I/usr/src/lib/libc/i386 -D__DBINTERFACE_PRIVATE -I/usr/src/lib/libc/../../contrib/gdtoa -DINET6
> -I/usr/obj/usr/src/lib/libc -I/usr/src/lib/libc/resolv -DPOSIX_MISTAKE -I/usr/src/lib/libc/locale -DBROKEN_DES
> -DPORTMAP -DDES_BUILTIN -I/usr/src/lib/libc/rpc -DYP -DNS_CACHING -DSYMBOL_VERSIONING -std=gnu89 -fstack-protector
> -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -c getppid.S
> 
> it's nicely hidden in the 4th line near the end ;)
> 
> I want this to be able to easily switch the C dialect used for various parts of
> the world. We dont want to mess with expected C dialect of contributed software.
> Hence once I switch the default to gnu99 I can just put CSTD=gnu89 to cddl/Makefile
> etc. and be fine. 
> 
> note that this change is a nop as gcc defaults to gnu89 mode but we need it because
> of the intended switch to gnu89.

switch to gnu99 of course

thnx to Christoph Mallon for the corrections


More information about the freebsd-current mailing list