Add more -W options to gcc.
[platform/upstream/busybox.git] / Makefile.flags
1 # ==========================================================================
2 # Build system
3 # ==========================================================================
4
5 BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
6 export BB_VER
7 SKIP_STRIP = n
8
9 # -std=gnu99 needed for [U]LLONG_MAX on some systems
10 CPPFLAGS += $(call cc-option,-std=gnu99,)
11
12 CPPFLAGS += \
13         -Iinclude -Ilibbb \
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
19
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.
27
28 ifeq ($(CONFIG_WERROR),y)
29 CFLAGS += $(call cc-option,-Werror,)
30 endif
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)
33
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,)
40
41 # FIXME: These warnings are at least partially to be concerned about and should
42 # be fixed..
43 #CFLAGS+=$(call cc-option,-Wconversion,)
44
45 ifeq ($(CONFIG_DEBUG),y)
46 CFLAGS += $(call cc-option,-g)
47 endif
48
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)
52 CFLAGS += -fpic
53 # and another 4% reduction of libbusybox.so:
54 # (external entry points must be marked EXTERNALLY_VISIBLE)
55 CFLAGS += $(call cc-option,-fvisibility=hidden)
56 endif
57
58 ifeq ($(CONFIG_STATIC),y)
59 LDFLAGS += -static
60 endif
61
62 LDLIBS += m crypt
63
64 ifeq ($(CONFIG_PAM),y)
65 LDLIBS += pam pam_misc
66 endif
67
68 ifeq ($(CONFIG_SELINUX),y)
69 LDLIBS += selinux sepol
70 endif
71
72 ifeq ($(CONFIG_EFENCE),y)
73 LDLIBS += efence
74 endif
75
76 ifeq ($(CONFIG_DMALLOC),y)
77 LDLIBS += dmalloc
78 endif
79
80 #LDFLAGS += -nostdlib
81
82 LDFLAGS_ELF2FLT = -Wl,-elf2flt
83 ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
84 SKIP_STRIP = y
85 endif
86
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.
91 FLTFLAGS += -s 16000