Makefile.flags 3.3 KB

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