1 # ==========================================================================
3 # ==========================================================================
5 BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
9 # -std=gnu99 needed for [U]LLONG_MAX on some systems
10 CPPFLAGS += $(call cc-option,-std=gnu99,)
14 $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include -I$(srctree)/libbb) \
15 -include include/autoconf.h \
16 -D_GNU_SOURCE -DNDEBUG \
17 $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
18 -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
20 # flag checks are grouped together to speed the checks up a bit..
21 CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
22 CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
23 CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
24 CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
25 # If you want to add more -Wsomething above, make sure that it is
26 # still possible to build bbox without warnings.
28 ifeq ($(CONFIG_WERROR),y)
29 CFLAGS += $(call cc-option,-Werror,)
31 # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
32 CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
34 CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
35 # -fno-guess-branch-probability: prohibit pseudo-random guessing
36 # of branch probabilities (hopefully makes bloatcheck more stable):
37 CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
38 CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
39 CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
41 # FIXME: These warnings are at least partially to be concerned about and should
43 #CFLAGS+=$(call cc-option,-Wconversion,)
45 ifeq ($(CONFIG_DEBUG),y)
46 CFLAGS += $(call cc-option,-g)
49 ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
50 # on i386: 14% smaller libbusybox.so
51 # (code itself is 9% bigger, we save on relocs/PLT/GOT)
53 # and another 4% reduction of libbusybox.so:
54 # (external entry points must be marked EXTERNALLY_VISIBLE)
55 CFLAGS += $(call cc-option,-fvisibility=hidden)
58 ifeq ($(CONFIG_STATIC),y)
64 ifeq ($(CONFIG_PAM),y)
65 LDLIBS += pam pam_misc
68 ifeq ($(CONFIG_SELINUX),y)
69 LDLIBS += selinux sepol
72 ifeq ($(CONFIG_EFENCE),y)
76 ifeq ($(CONFIG_DMALLOC),y)
82 LDFLAGS_ELF2FLT = -Wl,-elf2flt
83 ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
87 # Busybox is a stack-fatty so make sure we increase default size
88 # TODO: use "make stksizes" to find & fix big stack users
89 # (we stole scripts/checkstack.pl from the kernel... thanks guys!)
90 # Reduced from 20k to 16k in 1.9.0.