buildflags.mk 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # This Makefile snippet defines the following variables:
  2. #
  3. # CFLAGS: flags for the C compiler
  4. # CPPFLAGS: flags for the C preprocessor
  5. # CXXFLAGS: flags for the C++ compiler
  6. # OBJCFLAGS: flags for the Objective C compiler
  7. # OBJCXXFLAGS: flags for the Objective C++ compiler
  8. # GCJFLAGS: flags for the GNU Java compiler
  9. # FFLAGS: flags for the Fortran 77 compiler
  10. # FCFLAGS: flags for the Fortran 9x compiler
  11. # LDFLAGS: flags for the linker
  12. #
  13. # You can also export them in the environment by setting
  14. # DPKG_EXPORT_BUILDFLAGS to a non-empty value.
  15. #
  16. # This list is kept in sync with the default set of flags returned
  17. # by dpkg-buildflags.
  18. dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
  19. DPKG_BUILDFLAGS_LIST = CFLAGS CPPFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS \
  20. GCJFLAGS FFLAGS FCFLAGS LDFLAGS
  21. define dpkg_buildflags_export_envvar
  22. ifdef $(1)
  23. DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$(value $(1))"
  24. endif
  25. endef
  26. $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS))
  27. $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
  28. $(foreach operation,SET STRIP APPEND PREPEND,\
  29. $(eval $(call dpkg_buildflags_export_envvar,DEB_$(flag)_MAINT_$(operation)))))
  30. dpkg_buildflags_setvar = $(1) = $(call dpkg_late_eval,$(1),$(DPKG_BUILDFLAGS_EXPORT_ENVVAR) dpkg-buildflags --get $(1))
  31. $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
  32. $(eval $(call dpkg_buildflags_setvar,$(flag))))
  33. ifdef DPKG_EXPORT_BUILDFLAGS
  34. export $(DPKG_BUILDFLAGS_LIST)
  35. endif