reviving libbusybox, adding CONFIG_INDIVIDUAL part 3
[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 # If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
24 # (or anything else for that matter) make sure that it is still possible
25 # to build bbox without warnings. Current offender: find.c:alloc_action().
26 # Looks more like gcc bug: gcc will warn on it with or without prototype.
27 # But still, warning-free compile is a must, or else we will drown
28 # in warnings pretty soon.
29
30 ifeq ($(CONFIG_WERROR),y)
31 CFLAGS += $(call cc-option,-Werror,)
32 else
33 # for development, warn a little bit about unused results..
34 CPPFLAGS += -D_FORTIFY_SOURCE=2
35 endif
36 # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
37 CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
38
39 # gcc emits bogus "no prev proto" warning on find.c:alloc_action()
40 ifneq ($(CONFIG_WERROR),y)
41 CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
42 endif
43
44 CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
45 # -fno-guess-branch-probability: prohibit pseudo-random guessing
46 # of branch probabilities (hopefully makes bloatcheck more stable):
47 CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
48 CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
49 CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
50
51 # FIXME: These warnings are at least partially to be concerned about and should
52 # be fixed..
53 #CFLAGS+=$(call cc-option,-Wconversion,)
54
55 ifeq ($(CONFIG_DEBUG),y)
56 CFLAGS += $(call cc-option,-g)
57 endif
58
59 ifeq ($(CONFIG_STATIC),y)
60 LDFLAGS += -static
61 endif
62
63 LDLIBS += m crypt
64
65 ifeq ($(CONFIG_PAM),y)
66 LDLIBS += pam pam_misc
67 endif
68
69 ifeq ($(CONFIG_SELINUX),y)
70 LDLIBS += selinux sepol
71 endif
72
73 ifeq ($(CONFIG_EFENCE),y)
74 LDLIBS += efence
75 endif
76
77 ifeq ($(CONFIG_DMALLOC),y)
78 LDLIBS += dmalloc
79 endif
80
81 #LDFLAGS += -nostdlib
82
83 LDFLAGS_ELF2FLT = -Wl,-elf2flt
84 ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
85 SKIP_STRIP = y
86 endif
87
88 # Busybox is a stack-fatty so make sure we increase default size
89 # TODO: use "make stksizes" to find & fix big stack users
90 # (we stole scripts/checkstack.pl from the kernel... thanks guys!)
91 FLTFLAGS += -s 20000