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 # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
33 CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
35 # gcc emits bogus "no prev proto" warning on find.c:alloc_action()
36 ifneq ($(CONFIG_WERROR),y)
37 CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
40 CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
41 # -fno-guess-branch-probability: prohibit pseudo-random guessing
42 # of branch probabilities (hopefully makes bloatcheck more stable):
43 CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
44 CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
45 CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
47 # FIXME: These warnings are at least partially to be concerned about and should
49 #CFLAGS+=$(call cc-option,-Wconversion,)
51 ifeq ($(CONFIG_DEBUG),y)
52 CFLAGS += $(call cc-option,-g)
55 ifeq ($(CONFIG_STATIC),y)
59 ifeq ($(CONFIG_SELINUX),y)
60 LDLIBS += -lselinux -lsepol
63 ifeq ($(CONFIG_EFENCE),y)
67 ifeq ($(CONFIG_DMALLOC),y)
73 LDFLAGS_ELF2FLT = -Wl,-elf2flt
74 ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
78 # Busybox is a stack-fatty so make sure we increase default size
79 # TODO: use "make stksizes" to find & fix big stack users; should
80 # just steal scripts/checkstack.pl from the kernel ...