Remove the need to say 'HAVE_' in 'CONFIG'

This commit is contained in:
Christophe de Dinechin 2017-06-17 09:36:07 +02:00
parent 9c7547477e
commit 1a1856c3af
3 changed files with 25 additions and 21 deletions

View File

@ -29,16 +29,16 @@ SOURCES=hello.cpp
PRODUCTS=hello.exe
# Define configuration options
CONFIG= HAVE_<stdio.h> \
HAVE_<unistd.h> \
HAVE_<nonexistent.h> \
HAVE_<sys/time.h> \
HAVE_<sys/improbable.h> \
HAVE_<iostream> \
HAVE_clearenv \
HAVE_libm \
HAVE_liboony \
HAVE_sbrk
CONFIG= <stdio.h> \
<unistd.h> \
<nonexistent.h> \
<sys/time.h> \
<sys/improbable.h> \
<iostream> \
clearenv \
libm \
liboony \
sbrk
# Define what to test
TESTS=product count-characters

View File

@ -254,16 +254,16 @@ header file.
Here is an example from the sample `Makefile`:
CONFIG= HAVE_<stdio.h> \
HAVE_<unistd.h> \
HAVE_<nonexistent.h> \
HAVE_<sys/time.h> \
HAVE_<sys/improbable.h> \
HAVE_<iostream> \
HAVE_clearenv \
HAVE_libm \
HAVE_liboony \
HAVE_sbrk
CONFIG= <stdio.h> \
<unistd.h> \
<nonexistent.h> \
<sys/time.h> \
<sys/improbable.h> \
<iostream> \
clearenv \
libm \
liboony \
sbrk
Here is what the generated `config.h` might look like:

View File

@ -372,7 +372,7 @@ endif
NORM_CONFIG=$(subst <,.lt.,$(subst >,.gt.,$(subst /,.sl.,$(CONFIG))))
ORIG_TARGET=$(subst .lt.,<,$(subst .gt.,>,$(subst .sl.,/,$*)))
config.h: $(NORM_CONFIG:%=$(OBJDIR)/%)
config.h: $(NORM_CONFIG:%=$(OBJDIR)/HAVE_%)
$(PRINT_GENERATE) cat $^ > $@
# C standard headers, e.g. HAVE_<stdio.h>
@ -380,24 +380,28 @@ $(OBJDIR)/HAVE_.lt.%.h.gt.: $(OBJDIR)/CONFIG_HAVE_%.c
$(PRINT_CONFIG) $(CC_CONFIG)
$(OBJDIR)/CONFIG_HAVE_%.c: $(OBJDIR)/.mkdir
$(PRINT_GENERATE) echo '#include' "<$(ORIG_TARGET).h>" > "$@"; echo 'int main() { return 0; }' >> "$@"
.PRECIOUS: $(OBJDIR)/CONFIG_HAVE_%.c
# C++ Standard headers, e.g. HAVE_<iostream>
$(OBJDIR)/HAVE_.lt.%.gt.: $(OBJDIR)/CONFIG_HAVE_%.cpp
$(PRINT_CONFIG) $(CXX_CONFIG)
$(OBJDIR)/CONFIG_HAVE_%.cpp: $(OBJDIR)/.mkdir
$(PRINT_GENERATE) echo '#include' "<$(ORIG_TARGET)>" > "$@"; echo 'int main() { return 0; }' >> "$@"
.PRECIOUS: $(OBJDIR)/CONFIG_HAVE_%.cpp
# Library
$(OBJDIR)/HAVE_lib%: $(OBJDIR)/CONFIG_LIB%.c
$(PRINT_LIBCONFIG) $(LIB_CONFIG)
$(OBJDIR)/CONFIG_LIB%.c: $(OBJDIR)/.mkdir
$(PRINT_GENERATE) echo 'int main() { return 0; }' > "$@"
.PRECIOUS: $(OBJDIR)/CONFIG_LIB%.c
# Check if a function is present
$(OBJDIR)/HAVE_%: $(OBJDIR)/CONFIG_CHECK_%.c
$(PRINT_CONFIG) $(FN_CONFIG)
$(OBJDIR)/CONFIG_CHECK_%.c: $(BUILD)config/check_%.c $(OBJDIR)/.mkdir
$(PRINT_COPY) cp $< $@
.PRECIOUS: $(OBJDIR)/CONFIG_CHECK_%.c
#------------------------------------------------------------------------------