1 # ==========================================================================
3 # ==========================================================================
5 BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
8 # -std=gnu99 needed for [U]LLONG_MAX on some systems
9 CPPFLAGS += $(call cc-option,-std=gnu99,)
13 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
14 -include include/autoconf.h \
15 -D_GNU_SOURCE -DNDEBUG \
16 $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
17 -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
19 # flag checks are grouped together to speed the checks up a bit..
20 CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
21 CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
22 # If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
23 # (or anything else for that matter) make sure that it is still possible
24 # to build bbox without warnings. Current offender: find.c:alloc_action().
25 # Looks more like gcc bug: gcc will warn on it with or without prototype.
26 # But still, warning-free compile is a must, or else we will drown
27 # in warnings pretty soon.
29 ifeq ($(CONFIG_WERROR),y)
30 CFLAGS += $(call cc-option,-Werror,)
32 # for development, warn a little bit about unused results..
33 CPPFLAGS += -D_FORTIFY_SOURCE=2
35 # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
36 CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
38 # gcc emits bogus "no prev proto" warning on find.c:alloc_action()
39 ifneq ($(CONFIG_WERROR),y)
40 CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
43 CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
44 # -fno-guess-branch-probability: prohibit pseudo-random guessing
45 # of branch probabilities (hopefully makes bloatcheck more stable):
46 CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
47 CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
48 CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
50 # FIXME: These warnings are at least partially to be concerned about and should
52 #CFLAGS+=$(call cc-option,-Wconversion,)
54 ifeq ($(CONFIG_DEBUG),y)
55 CFLAGS += $(call cc-option,-g)
58 ifeq ($(CONFIG_STATIC),y)
62 ifeq ($(CONFIG_SELINUX),y)
63 LDLIBS += -lselinux -lsepol
66 ifeq ($(CONFIG_EFENCE),y)
70 ifeq ($(CONFIG_DMALLOC),y)
76 LDFLAGS_ELF2FLT = -Wl,-elf2flt
77 ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
81 # Busybox is a stack-fatty so make sure we increase default size
82 # TODO: use "make stksizes" to find & fix big stack users
83 # (we stole scripts/checkstack.pl from the kernel... thanks guys!)