3
0

Makefile.flags 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. CFLAGS += $(call cc-option,-Wall,)
  17. CFLAGS += $(call cc-option,-Wshadow,)
  18. CFLAGS += $(call cc-option,-Wwrite-strings,)
  19. CFLAGS += $(call cc-option,-Wundef,)
  20. CFLAGS += $(call cc-option,-Wstrict-prototypes,)
  21. CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
  22. CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,)
  23. CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
  24. # warn about C99 declaration after statement
  25. CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
  26. # If you want to add more -Wsomething above, make sure that it is
  27. # still possible to build bbox without warnings.
  28. ifeq ($(CONFIG_WERROR),y)
  29. CFLAGS += $(call cc-option,-Werror,)
  30. ## TODO:
  31. ## gcc version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC) is a PITA:
  32. ## const char *ptr; ... off_t v = *(off_t*)ptr; -> BOOM
  33. ## and no easy way to convince it to shut the hell up.
  34. ## We have a lot of such things all over the place.
  35. ## Classic *(off_t*)(void*)ptr does not work,
  36. ## and I am unwilling to do crazy gcc specific ({ void *ppp = ...; })
  37. ## stuff in macros. This would obfuscate the code too much.
  38. #CFLAGS += $(call cc-ifversion, -eq, 0404, -fno-strict-aliasing)
  39. endif
  40. # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
  41. CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
  42. CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
  43. # -fno-guess-branch-probability: prohibit pseudo-random guessing
  44. # of branch probabilities (hopefully makes bloatcheck more stable):
  45. CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
  46. CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
  47. CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
  48. # FIXME: These warnings are at least partially to be concerned about and should
  49. # be fixed..
  50. #CFLAGS += $(call cc-option,-Wconversion,)
  51. ifneq ($(CONFIG_DEBUG),y)
  52. CFLAGS += $(call cc-option,-Os,)
  53. else
  54. CFLAGS += $(call cc-option,-g,)
  55. #CFLAGS += "-D_FORTIFY_SOURCE=2"
  56. ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
  57. CFLAGS += $(call cc-option,-O0,)
  58. else
  59. CFLAGS += $(call cc-option,-Os,)
  60. endif
  61. endif
  62. # If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
  63. ARCH_FPIC ?= -fpic
  64. ARCH_FPIE ?= -fpie
  65. ARCH_PIE ?= -pie
  66. ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
  67. # on i386: 14% smaller libbusybox.so
  68. # (code itself is 9% bigger, we save on relocs/PLT/GOT)
  69. CFLAGS += $(ARCH_FPIC)
  70. # and another 4% reduction of libbusybox.so:
  71. # (external entry points must be marked EXTERNALLY_VISIBLE)
  72. CFLAGS += $(call cc-option,-fvisibility=hidden)
  73. endif
  74. ifeq ($(CONFIG_STATIC),y)
  75. CFLAGS_busybox += -static
  76. endif
  77. ifeq ($(CONFIG_PIE),y)
  78. CFLAGS_busybox += $(ARCH_PIE)
  79. CFLAGS += $(ARCH_FPIE)
  80. endif
  81. ifneq ($(CONFIG_EXTRA_CFLAGS),)
  82. CFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_CFLAGS)))
  83. #"))
  84. endif
  85. LDLIBS += m crypt
  86. ifeq ($(CONFIG_PAM),y)
  87. LDLIBS += pam pam_misc
  88. endif
  89. ifeq ($(CONFIG_SELINUX),y)
  90. LDLIBS += selinux sepol
  91. endif
  92. ifeq ($(CONFIG_EFENCE),y)
  93. LDLIBS += efence
  94. endif
  95. ifeq ($(CONFIG_DMALLOC),y)
  96. LDLIBS += dmalloc
  97. endif
  98. # If a flat binary should be built, CFLAGS_busybox="-elf2flt"
  99. # env var should be set for make invocation.
  100. # Here we check whether CFLAGS_busybox indeed contains that flag.
  101. # (For historical reasons, we also check LDFLAGS, which doesn't
  102. # seem to be entirely correct variable to put "-elf2flt" into).
  103. W_ELF2FLT = -elf2flt
  104. ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
  105. SKIP_STRIP = y
  106. endif
  107. # Busybox is a stack-fatty so make sure we increase default size
  108. # TODO: use "make stksizes" to find & fix big stack users
  109. # (we stole scripts/checkstack.pl from the kernel... thanks guys!)
  110. # Reduced from 20k to 16k in 1.9.0.
  111. FLTFLAGS += -s 16000