buildflags.mk 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. # GCJFLAGS: flags for the GNU Java compiler
  7. # FFLAGS: flags for the Fortran compiler
  8. # LDFLAGS: flags for the linker
  9. #
  10. # You can also export them in the environment by setting
  11. # DPKG_EXPORT_BUILDFLAGS to a non-empty value.
  12. #
  13. # This list is kept in sync with the default set of flags returned
  14. # by dpkg-buildflags.
  15. dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
  16. DPKG_BUILDFLAGS_LIST = CFLAGS CPPFLAGS CXXFLAGS GCJFLAGS FFLAGS LDFLAGS
  17. define dpkg_buildflags_export_envvar
  18. ifdef $(1)
  19. DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$(value $(1))"
  20. endif
  21. endef
  22. $(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS))
  23. $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
  24. $(foreach operation,SET STRIP APPEND PREPEND,\
  25. $(eval $(call dpkg_buildflags_export_envvar,DEB_$(flag)_MAINT_$(operation)))))
  26. dpkg_buildflags_setvar = $(1) = $(call dpkg_late_eval,$(1),$(DPKG_BUILDFLAGS_EXPORT_ENVVAR) dpkg-buildflags --get $(1))
  27. $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
  28. $(eval $(call dpkg_buildflags_setvar,$(flag))))
  29. ifdef DPKG_EXPORT_BUILDFLAGS
  30. export $(DPKG_BUILDFLAGS_LIST)
  31. endif