diff --git a/config.gnu.mk b/config.gnu.mk index 23bbf7b..d9bb387 100644 --- a/config.gnu.mk +++ b/config.gnu.mk @@ -113,11 +113,13 @@ CFG_TEST= \ CFG_UNDEF0= \ | sed -e 's|^\#define \(.*\) 0$$|/* \#undef \1 */|g' > "$@"; \ [ -f "$<".out ] && cat >> "$@" "$<".out; true +CFG_CFLAGS= $(CFLAGS) $(shell cat $(PKG_CFLAGS) $(PKG_LDFLAGS) /dev/null) +CFG_CXXFLAGS= $(CXXFLAGS) $(shell cat $(PKG_CFLAGS) $(PKG_LDFLAGS) /dev/null) -CFG_CC_CMD= $$($(CC) $(CFLAGS) $(CFLAGS_CONFIG_$*) $(LDFLAGS) $(CFG_TEST)) -CFG_CXX_CMD= $$($(CXX) $(CXXFLAGS) $(CXXFLAGS_CONFIG_$*) $(LDFLAGS) $(CFG_TEST)) -CFG_LIB_CMD= $$($(CC) $(CFLAGS) $(CFLAGS_CONFIG_$*) $(LDFLAGS) -l$* $(CFG_TEST)) -CFG_FN_CMD= $$($(CC) $(CFLAGS) $(CFLAGS_CONFIG_$*) $(LDFLAGS) $(CFG_TEST)) +CFG_CC_CMD= `$(CC) $(CFG_CFLAGS) $(CFLAGS_CONFIG_$*) $(CFG_TEST)` +CFG_CXX_CMD= `$(CXX) $(CFG_CXXFLAGS) $(CXXFLAGS_CONFIG_$*) $(CFG_TEST)` +CFG_LIB_CMD= `$(CC) $(CFG_CFLAGS) $(CFLAGS_CONFIG_$*) -l$* $(CFG_TEST)` +CFG_FN_CMD= `$(CC) $(CFG_CFLAGS) $(CFLAGS_CONFIG_$*) $(CFG_TEST)` CC_CONFIG= $(CFG_DEF) HAVE_$(CFG_UPPER)_H $(CFG_CC_CMD) $(CFG_UNDEF0) CXX_CONFIG= $(CFG_DEF) HAVE_$(CFG_UPPER) $(CFG_CXX_CMD) $(CFG_UNDEF0) diff --git a/rules.mk b/rules.mk index 7cfcd58..f5315af 100644 --- a/rules.mk +++ b/rules.mk @@ -94,9 +94,6 @@ BUILD_COUNT:= $(words $(SOURCES)) GIT_REVISION:= $(shell git rev-parse --short HEAD 2> /dev/null || echo "unknown") PROFILE_OUTPUT:=$(subst $(EXE_EXT),,$(OBJROOT_EXE))_prof_$(GIT_REVISION).vsp --include $(PKGCONFIGS:%=$(OBJROOT)/%.pkg-config.mk) - - #------------------------------------------------------------------------------ # User targets #------------------------------------------------------------------------------ @@ -182,7 +179,6 @@ objects:$(OBJDIR:%=%/.mkdir) $(OBJECTS) # "Hooks" for pre and post build steps config: $(VARIANTS:%=%.variant) -config: $(PKGCONFIGS:%=$(OBJROOT)/%.pkg-config.mk) config: $(CONFIG:%=config.h) prebuild: config postbuild: @@ -209,11 +205,6 @@ product.test: product .ALWAYS %.install_hdr: $(PREFIX_HDR).mkdir $(PRINT_INSTALL) $(INSTALL) $* $(PREFIX_HDR) -# Check pkg-config -$(OBJROOT)/%.pkg-config.mk: $(MAKEFILE_DEPS) $(OBJROOT)/.mkdir - $(PRINT_PKGCONFIG) pkg-config $* - $(PRINT_COMMAND) (echo CFLAGS_PKGCONFIG+=`pkg-config --cflags $*` && echo LDFLAGS_PKGCONFIG+=`pkg-config --libs $*`) > $@ - # Benchmarking (always done with profile target) benchmark: $(BENCHMARK:%=%.benchmark) $(BENCHMARKS:%=%.benchmark) product.benchmark: product .ALWAYS @@ -391,6 +382,23 @@ ifeq ($(MAKECMDGOALS),build) endif +#------------------------------------------------------------------------------ +# Package configuration +#------------------------------------------------------------------------------ + +# Package configuration file +PKG_CFLAGS=$(PKGCONFIGS:%=$(OBJROOT)/%.pkg-config.cflags) +PKG_LDFLAGS=$(PKGCONFIGS:%=$(OBJROOT)/%.pkg-config.ldflags) +$(OBJROOT)/pkg-config.mk: $(PKG_CFLAGS) $(PKG_LDFLAGS) + $(PRINT_COMMAND) (echo CFLAGS_PKGCONFIG=`cat $(PKG_CFLAGS)`; echo LDFLAGS_PKGCONFIG=`cat $(PKG_LDFLAGS)`) > $@ +-include $(PKGCONFIGS:%=$(OBJROOT)/pkg-config.mk) + +$(OBJROOT)/%.pkg-config.cflags: $(MAKEFILE_DEPS) $(OBJROOT)/.mkdir + $(PRINT_PKGCONFIG) pkg-config --cflags $* > $@ +$(OBJROOT)/%.pkg-config.ldflags: $(MAKEFILE_DEPS) $(OBJROOT)/.mkdir + $(PRINT_COMMAND) pkg-config --libs $* > $@ + + #------------------------------------------------------------------------------ # Configuration rules #------------------------------------------------------------------------------ @@ -398,7 +406,7 @@ endif NORM_CONFIG=$(subst <,.lt.,$(subst >,.gt.,$(subst /,.sl.,$(CONFIG)))) ORIG_TARGET=$(subst .lt.,<,$(subst .gt.,>,$(subst .sl.,/,$*))) CONFIG_DEPS= $(MAKEFILE_DEPS) $(OBJDIR)/.mkdir \ - $(PKGCONFIGS:%=$(OBJROOT)/%.pkg-config.mk) + $(PKGCONFIGS:%=$(OBJROOT)/pkg-config.mk) config.h: $(NORM_CONFIG:%=$(OBJDIR)/CFG_HAVE_%.h) $(PRINT_GENERATE) cat $^ > $@