Improve compatibility with autoconf by using config.h and similar #define names

This commit is contained in:
Christophe de Dinechin 2017-05-02 11:18:03 +02:00
parent 6fe7280a78
commit aa38d293f3
2 changed files with 9 additions and 8 deletions

View File

@ -1,11 +1,11 @@
#include "build-config.h"
#include "config.h"
#include <iostream>
#if HAVE_sys_improbable_h
#if HAVE_SYS_IMPROBABLE_H
#warning "Strange header present"
#endif
#if !HAVE_iostream
#if !HAVE_IOSTREAM
#warning "We expect to have iostream"
#endif

View File

@ -167,7 +167,7 @@ product:$(OBJPRODUCTS)
objects:$(OBJDIR:%=%/.mkdir) $(OBJECTS)
# "Hooks" for pre and post build steps
config: $(CONFIG:%=build-config.h)
config: $(CONFIG:%=config.h)
prebuild:
postbuild:
@ -368,18 +368,19 @@ endif
# Configuration rules
#------------------------------------------------------------------------------
build-config.h: $(CONFIG:%=$(OBJDIR)/%)
config.h: $(CONFIG:%=$(OBJDIR)/%)
$(PRINT_GENERATE) cat $(CONFIG:%="$(OBJDIR)/%") > $@
$(OBJDIR)/HAVE_<%.h>: $(OBJDIR)/CONFIG_HAVE_%.c
$(PRINT_CONFIG) mkdir -p "$$(dirname "$@")" ; echo '#define HAVE_$*_h' $$($(CC) -c "$<" -o "$<".o > "$<".err 2>&1 && echo 1 || echo 0) | sed -e 's|[./\\]|_|g' > "$@"
$(PRINT_CONFIG) mkdir -p "$$(dirname "$@")" ; echo '#define HAVE_$*_h' $$($(CC) $(CFLAGS) -c "$<" -o "$<".o > "$<".err 2>&1 && echo 1 || echo 0) | tr '[:lower:]' '[:upper:]' | sed -e 's/#DEFINE/#define/g' -e 's|[./\\]|_|g' > "$@"
$(OBJDIR)/HAVE_<%>: $(OBJDIR)/CONFIG_HAVE_%.cpp
$(PRINT_CONFIG) mkdir -p "$$(dirname "$@")" ; echo '#define HAVE_$*' $$($(CXX) -c "$<" -o "$<".o > "$<".err 2>&1 && echo 1 || echo 0) | sed -e 's|[./\\]|_|g' > "$@"
$(PRINT_CONFIG) mkdir -p "$$(dirname "$@")" ; echo '#define HAVE_$*' $$($(CXX) $(CXXFLAGS) -c "$<" -o "$<".o > "$<".err 2>&1 && echo 1 || echo 0) | tr '[:lower:]' '[:upper:]' | sed -e 's/#DEFINE/#define/g' -e 's|[./\\]|_|g' > "$@"
$(OBJDIR)/CONFIG_HAVE_%.c: $(OBJDIR)/.mkdir
$(PRINT_GENERATE) mkdir -p "$$(dirname "$@")" ; echo '#include' "<$*.h>" > "$@"
$(OBJDIR)/CONFIG_HAVE_%.cpp: $(OBJDIR)/.mkdir
$(PRINT_GENERATE) mkdir -p "$$(dirname "$@")" ; echo '#include' "<$*>" > "$@"
.PRECIOUS: $(OBJDIR)/CONFIG_HAVE_%.c
.PRECIOUS: $(OBJDIR)/CONFIG_HAVE_%.c $(OBJDIR)/CONFIG_HAVE_%.cpp
#------------------------------------------------------------------------------
# Makefile optimization tricks