add -fvisibility=hidden to CC flags, mark XXX_main functions
[oweals/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_BUILD_LIBBUSYBOX),y)
60 # on i386: 14% smaller libbusybox.so
61 # (code itself is 9% bigger, we save on relocs/PLT/GOT)
62 CFLAGS += -fpic
63 # and another 4% reduction of libbusybox.so:
64 # (external entry points must be marked EXTERNALLY_VISIBLE)
65 CFLAGS += $(call cc-option,-fvisibility=hidden)
66 endif
67
68 ifeq ($(CONFIG_STATIC),y)
69 LDFLAGS += -static
70 endif
71
72 LDLIBS += m crypt
73
74 ifeq ($(CONFIG_PAM),y)
75 LDLIBS += pam pam_misc
76 endif
77
78 ifeq ($(CONFIG_SELINUX),y)
79 LDLIBS += selinux sepol
80 endif
81
82 ifeq ($(CONFIG_EFENCE),y)
83 LDLIBS += efence
84 endif
85
86 ifeq ($(CONFIG_DMALLOC),y)
87 LDLIBS += dmalloc
88 endif
89
90 #LDFLAGS += -nostdlib
91
92 LDFLAGS_ELF2FLT = -Wl,-elf2flt
93 ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
94 SKIP_STRIP = y
95 endif
96
97 # Busybox is a stack-fatty so make sure we increase default size
98 # TODO: use "make stksizes" to find & fix big stack users
99 # (we stole scripts/checkstack.pl from the kernel... thanks guys!)
100 FLTFLAGS += -s 20000