make it possible to build bbox without warnings again.
[platform/upstream/busybox.git] / Makefile.flags
1 # ==========================================================================
2 # Build system
3 # ==========================================================================
4
5 BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
6
7 # -std=gnu99 needed for [U]LLONG_MAX on some systems
8 CPPFLAGS += $(call cc-option,-std=gnu99,)
9
10 CPPFLAGS += \
11         -Iinclude -Ilibbb \
12         $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
13         -include include/autoconf.h \
14         -D_GNU_SOURCE -DNDEBUG \
15         $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
16         -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
17
18 # flag checks are grouped together to speed the checks up a bit..
19 CFLAGS += $(call cc-option,-Wall -Wshadow,)
20 ifeq ($(CONFIG_WERROR),y)
21 CFLAGS += $(call cc-option,-Werror,)
22 endif
23 CFLAGS += $(call cc-option,-Wundef -Wold-style-definition -Wstrict-prototypes,)
24 # If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
25 # (or anything else for that matter) make sure that it is still possible
26 # to build bbox without warnings. Current offender: find.c:alloc_action().
27 # Looks more like gcc bug: gcc will warn on it with or without prototype.
28 # But still, warning-free compile is a must, or else we will drown
29 # in warnings pretty soon.
30 ifneq ($(CONFIG_WERROR),y)
31 CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
32 endif
33 CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
34 # -fno-guess-branch-probability: prohibit pseudo-random guessing
35 # of branch probabilities (hopefully makes bloatcheck more stable):
36 CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
37 CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
38 CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
39
40 # FIXME: These warnings are at least partially to be concerned about and should
41 # be fixed..
42 #CFLAGS+=$(call cc-option,-Wconversion,)
43
44 ifeq ($(CONFIG_DEBUG),y)
45 CFLAGS += $(call cc-option,-g)
46 endif
47
48 ifeq ($(CONFIG_STATIC),y)
49 LDFLAGS += -static
50 endif
51 #LDFLAGS += -nostdlib