3
0

Makefile.flags 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # ==========================================================================
  2. # Build system
  3. # ==========================================================================
  4. BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
  5. SKIP_STRIP = n
  6. # -std=gnu99 needed for [U]LLONG_MAX on some systems
  7. CPPFLAGS += $(call cc-option,-std=gnu99,)
  8. CPPFLAGS += \
  9. -Iinclude -Ilibbb \
  10. $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
  11. -include include/autoconf.h \
  12. -D_GNU_SOURCE -DNDEBUG \
  13. $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
  14. -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
  15. # flag checks are grouped together to speed the checks up a bit..
  16. CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
  17. CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
  18. # If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
  19. # (or anything else for that matter) make sure that it is still possible
  20. # to build bbox without warnings. Current offender: find.c:alloc_action().
  21. # Looks more like gcc bug: gcc will warn on it with or without prototype.
  22. # But still, warning-free compile is a must, or else we will drown
  23. # in warnings pretty soon.
  24. ifeq ($(CONFIG_WERROR),y)
  25. CFLAGS += $(call cc-option,-Werror,)
  26. else
  27. # for development, warn a little bit about unused results..
  28. CPPFLAGS += -D_FORTIFY_SOURCE=2
  29. endif
  30. # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
  31. CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
  32. # gcc emits bogus "no prev proto" warning on find.c:alloc_action()
  33. ifneq ($(CONFIG_WERROR),y)
  34. CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
  35. endif
  36. CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
  37. # -fno-guess-branch-probability: prohibit pseudo-random guessing
  38. # of branch probabilities (hopefully makes bloatcheck more stable):
  39. CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
  40. CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
  41. CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
  42. # FIXME: These warnings are at least partially to be concerned about and should
  43. # be fixed..
  44. #CFLAGS+=$(call cc-option,-Wconversion,)
  45. ifeq ($(CONFIG_DEBUG),y)
  46. CFLAGS += $(call cc-option,-g)
  47. endif
  48. ifeq ($(CONFIG_STATIC),y)
  49. LDFLAGS += -static
  50. endif
  51. BBOX_LIB_LIST = m crypt
  52. ifeq ($(CONFIG_PAM),y)
  53. BBOX_LIB_LIST += pam pam_misc
  54. endif
  55. ifeq ($(CONFIG_SELINUX),y)
  56. BBOX_LIB_LIST += selinux sepol
  57. endif
  58. ifeq ($(CONFIG_EFENCE),y)
  59. BBOX_LIB_LIST += efence
  60. endif
  61. ifeq ($(CONFIG_DMALLOC),y)
  62. BBOX_LIB_LIST += dmalloc
  63. endif
  64. # For scripts/trylink
  65. export BBOX_LIB_LIST
  66. #LDFLAGS += -nostdlib
  67. LDFLAGS_ELF2FLT = -Wl,-elf2flt
  68. ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
  69. SKIP_STRIP = y
  70. endif
  71. # Busybox is a stack-fatty so make sure we increase default size
  72. # TODO: use "make stksizes" to find & fix big stack users
  73. # (we stole scripts/checkstack.pl from the kernel... thanks guys!)
  74. FLTFLAGS += -s 20000