diff options
| author | Rob Landley <rob@landley.net> | 2006-04-19 20:32:27 +0000 |
|---|---|---|
| committer | Rob Landley <rob@landley.net> | 2006-04-19 20:32:27 +0000 |
| commit | 5076eb4af923ec2d3355450cfa356dbac9f5aeca (patch) | |
| tree | a31dc763e6d880d1ee8896e51bffb2adaa30c559 | |
| parent | 856489b63c276571387a9646d418081b5609628b (diff) | |
| download | busybox-w32-5076eb4af923ec2d3355450cfa356dbac9f5aeca.tar.gz busybox-w32-5076eb4af923ec2d3355450cfa356dbac9f5aeca.tar.bz2 busybox-w32-5076eb4af923ec2d3355450cfa356dbac9f5aeca.zip | |
svn 14824 broke -funsigned-char and possibly building out of tree, because
$(srcdir) can't bind early since it's set to a different value in each subdir.
If it binds early, it's blank, hence an empty -I which eats the next option
as a directory to look for #include files in.
So CFLAGS has to bind late, but the check_gcc stuff should only get run once.
I added a "make V=2" mode to show when check_gcc gets run, and turned WARNINGS
into a CFLAGS line since it was always getting added anyway.
| -rw-r--r-- | Rules.mak | 38 |
1 files changed, 25 insertions, 13 deletions
| @@ -72,11 +72,14 @@ CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS))) | |||
| 72 | #CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char | 72 | #CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char |
| 73 | #GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") | 73 | #GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") |
| 74 | 74 | ||
| 75 | WARNINGS=-Wall -Wstrict-prototypes -Wshadow | 75 | # This must bind late because srcdir is reset for every source subdirectory. |
| 76 | CFLAGS:=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) | 76 | CFLAGS=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir) |
| 77 | 77 | CFLAGS+=$(CHECKED_CFLAGS) | |
| 78 | ARFLAGS=cru | 78 | ARFLAGS=cru |
| 79 | 79 | ||
| 80 | # Warnings | ||
| 81 | |||
| 82 | CFLAGS+=-Wall -Wstrict-prototypes -Wshadow | ||
| 80 | 83 | ||
| 81 | # gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest | 84 | # gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest |
| 82 | # get the CC MAJOR/MINOR version | 85 | # get the CC MAJOR/MINOR version |
| @@ -100,8 +103,13 @@ TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ | |||
| 100 | ) | 103 | ) |
| 101 | endif | 104 | endif |
| 102 | 105 | ||
| 103 | # A nifty macro to make testing gcc features easier | 106 | # A nifty macro to make testing gcc features easier, but note that everything |
| 107 | # that uses this _must_ use := or it will be re-evaluated for every file. | ||
| 108 | ifeq ($(strip $(V)),2) | ||
| 109 | VERBOSE_CHECK_GCC=echo check_gcc $(1) >> /dev/stderr; | ||
| 110 | endif | ||
| 104 | check_gcc=$(shell \ | 111 | check_gcc=$(shell \ |
| 112 | $(VERBOSE_CHECK_GCC)\ | ||
| 105 | if [ "$(1)" != "" ]; then \ | 113 | if [ "$(1)" != "" ]; then \ |
| 106 | if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ | 114 | if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ |
| 107 | then echo "$(1)"; else echo "$(2)"; fi \ | 115 | then echo "$(1)"; else echo "$(2)"; fi \ |
| @@ -113,9 +121,13 @@ check_ld=$(shell \ | |||
| 113 | $(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \ | 121 | $(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \ |
| 114 | fi) | 122 | fi) |
| 115 | 123 | ||
| 116 | CFLAGS+=$(call check_gcc,-funsigned-char,) | 124 | # Pin CHECKED_CFLAGS with := so it's only evaluated once. |
| 125 | CHECKED_CFLAGS:=$(call check_gcc,-funsigned-char,) | ||
| 126 | CHECKED_CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,) | ||
| 127 | |||
| 128 | # Preemptively pin this too. | ||
| 129 | PROG_CFLAGS:= | ||
| 117 | 130 | ||
| 118 | CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,) | ||
| 119 | 131 | ||
| 120 | #-------------------------------------------------------- | 132 | #-------------------------------------------------------- |
| 121 | # Arch specific compiler optimization stuff should go here. | 133 | # Arch specific compiler optimization stuff should go here. |
| @@ -189,24 +201,24 @@ else | |||
| 189 | endif | 201 | endif |
| 190 | endif | 202 | endif |
| 191 | ifeq ($(strip $(CONFIG_DEBUG)),y) | 203 | ifeq ($(strip $(CONFIG_DEBUG)),y) |
| 192 | CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE | 204 | CFLAGS +=-g -D_GNU_SOURCE |
| 193 | LDFLAGS += $(call check_ld,--warn-common,) | 205 | LDFLAGS += $(call check_ld,--warn-common,) |
| 194 | else | 206 | else |
| 195 | CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG | 207 | CFLAGS+=$(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG |
| 196 | LDFLAGS += $(call check_ld,--warn-common,) | 208 | LDFLAGS += $(call check_ld,--warn-common,) |
| 197 | LDFLAGS += $(call check_ld,--sort-common,) | 209 | LDFLAGS += $(call check_ld,--sort-common,) |
| 198 | endif | 210 | endif |
| 199 | # warn a bit more verbosely for non-release versions | 211 | # warn a bit more verbosely for non-release versions |
| 200 | ifneq ($(EXTRAVERSION),) | 212 | ifneq ($(EXTRAVERSION),) |
| 201 | CFLAGS+=$(call check_gcc,-Wstrict-prototypes,) | 213 | CHECKED_CFLAGS+=$(call check_gcc,-Wstrict-prototypes,) |
| 202 | CFLAGS+=$(call check_gcc,-Wmissing-prototypes,) | 214 | CHECKED_CFLAGS+=$(call check_gcc,-Wmissing-prototypes,) |
| 203 | CFLAGS+=$(call check_gcc,-Wmissing-declarations,) | 215 | CHECKED_CFLAGS+=$(call check_gcc,-Wmissing-declarations,) |
| 204 | endif | 216 | endif |
| 205 | STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment | 217 | STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment |
| 206 | ifeq ($(strip $(CONFIG_STATIC)),y) | 218 | ifeq ($(strip $(CONFIG_STATIC)),y) |
| 207 | PROG_CFLAGS += $(call check_gcc,-static,) | 219 | PROG_CFLAGS += $(call check_gcc,-static,) |
| 208 | endif | 220 | endif |
| 209 | CFLAGS_SHARED += $(call check_gcc,-shared,) | 221 | CFLAGS_SHARED := $(call check_gcc,-shared,) |
| 210 | LIB_CFLAGS+=$(CFLAGS_SHARED) | 222 | LIB_CFLAGS+=$(CFLAGS_SHARED) |
| 211 | 223 | ||
| 212 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) | 224 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) |
| @@ -231,7 +243,7 @@ endif | |||
| 231 | 243 | ||
| 232 | 244 | ||
| 233 | OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o | 245 | OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o |
| 234 | CFLAGS += $(CROSS_CFLAGS) | 246 | CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS) |
| 235 | ifdef BB_INIT_SCRIPT | 247 | ifdef BB_INIT_SCRIPT |
| 236 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' | 248 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
| 237 | endif | 249 | endif |
