Check for library presence
This commit is contained in:
parent
3293ab17f8
commit
26dedc59e1
4
Makefile
4
Makefile
|
@ -35,7 +35,9 @@ CONFIG= HAVE_<stdio.h> \
|
|||
HAVE_<sys/time.h> \
|
||||
HAVE_<sys/improbable.h> \
|
||||
HAVE_<iostream> \
|
||||
HAVE_clearenv
|
||||
HAVE_clearenv \
|
||||
HAVE_libm \
|
||||
HAVE_liboony
|
||||
|
||||
# Define what to test
|
||||
TESTS=product count-characters
|
||||
|
|
|
@ -84,5 +84,6 @@ AS_DEPEND= $(CC) $(CPPFLAGS) $(CPPFLAGS_$*) -MM -MP -MF $@ -MT $(@:.d=) $<
|
|||
# Configuration checks
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
CC_CONFIG= mkdir -p "$$(dirname "$@")" ; echo '\#define HAVE_$*_H' $$($(CC) $(CFLAGS) "$<" -o "$<".exe > "$<".err 2>&1 && "$<".exe && echo 1 || echo 0) | tr '[:lower:]' '[:upper:]' | sed -e 's|[^[:alnum:]]|_|g' -e 's|_DEFINE_\(.*\)_0|/* \#undef \1 */|g' -e 's|_DEFINE_\(.*\)_1|\#define \1 1|g' > "$@"
|
||||
CXX_CONFIG= mkdir -p "$$(dirname "$@")" ; echo '\#define HAVE_$*' $$($(CXX) $(CXXFLAGS) "$<" -o "$<".exe > "$<".err 2>&1 && "$<".exe && echo 1 || echo 0) | tr '[:lower:]' '[:upper:]' | sed -e 's|[^[:alnum:]]|_|g' -e 's|_DEFINE_\(.*\)_0|/* \#undef \1 */|g' -e 's|_DEFINE_\(.*\)_1|\#define \1 1|g' > "$@"
|
||||
CC_CONFIG= mkdir -p "$$(dirname "$@")" ; echo '\#define HAVE_$*_H' $$($(CC) $(CFLAGS) $(CFLAGS_CONFIG_$*) "$<" -o "$<".exe > "$<".err 2>&1 && "$<".exe && echo 1 || echo 0) | tr '[:lower:]' '[:upper:]' | sed -e 's|[^[:alnum:]]|_|g' -e 's|_DEFINE_\(.*\)_0|/* \#undef \1 */|g' -e 's|_DEFINE_\(.*\)_1|\#define \1 1|g' > "$@"
|
||||
CXX_CONFIG= mkdir -p "$$(dirname "$@")" ; echo '\#define HAVE_$*' $$($(CXX) $(CXXFLAGS) $(CXXFLAGS_CONFIG_$*) "$<" -o "$<".exe > "$<".err 2>&1 && "$<".exe && echo 1 || echo 0) | tr '[:lower:]' '[:upper:]' | sed -e 's|[^[:alnum:]]|_|g' -e 's|_DEFINE_\(.*\)_0|/* \#undef \1 */|g' -e 's|_DEFINE_\(.*\)_1|\#define \1 1|g' > "$@"
|
||||
LIB_CONFIG= mkdir -p "$$(dirname "$@")" ; echo '\#define HAVE_LIB$*' $$($(CC) $(CCFLAGS) $(CXXFLAGS_CONFIG_$*) -l$* "$<" -o "$<".exe > "$<".err 2>&1 && "$<".exe && echo 1 || echo 0) | tr '[:lower:]' '[:upper:]' | sed -e 's|[^[:alnum:]]|_|g' -e 's|_DEFINE_\(.*\)_0|/* \#undef \1 */|g' -e 's|_DEFINE_\(.*\)_1|\#define \1 1|g' > "$@"
|
||||
|
|
2
config.h
2
config.h
|
@ -5,3 +5,5 @@
|
|||
/* #undef HAVE_SYS_IMPROBABLE_H */
|
||||
#define HAVE_IOSTREAM 1
|
||||
/* #undef HAVE_CLEARENV_H */
|
||||
#define HAVE_LIBM 1
|
||||
/* #undef HAVE_LIBOONY */
|
||||
|
|
9
rules.mk
9
rules.mk
|
@ -288,6 +288,7 @@ PRINT_COPY= $(PRINT_COMMAND) $(INFO) "[COPY]" $< '=>' $@ ;
|
|||
PRINT_DEPEND= $(PRINT_COMMAND) $(INFO) "[DEPEND] " $< ;
|
||||
PRINT_TEST= $(PRINT_COMMAND) $(INFO) "[TEST]" $(@:.runtest=) ;
|
||||
PRINT_CONFIG= $(PRINT_COMMAND) $(INFO) "[CONFIG]" "$*" ;
|
||||
PRINT_LIBCONFIG=$(PRINT_COMMAND) $(INFO) "[CONFIG]" "lib$*" ;
|
||||
|
||||
logs.mkdir: $(dir $(BUILD_LOG))/.mkdir $(dir $(BUILD_SAVED_LOG))/.mkdir
|
||||
%/.mkdir:
|
||||
|
@ -383,14 +384,18 @@ $(OBJDIR)/HAVE_<%>: $(OBJDIR)/CONFIG_HAVE_%.cpp
|
|||
$(OBJDIR)/CONFIG_HAVE_%.cpp: $(OBJDIR)/.mkdir
|
||||
$(PRINT_GENERATE) mkdir -p "$$(dirname "$@")" ; echo '#include' "<$*>" > "$@"; echo 'int main() { return 0; }' >> "$@"
|
||||
|
||||
# Library
|
||||
$(OBJDIR)/HAVE_lib%: $(OBJDIR)/CONFIG_LIB%.c
|
||||
$(PRINT_LIBCONFIG) $(LIB_CONFIG)
|
||||
$(OBJDIR)/CONFIG_LIB%.c:
|
||||
$(PRINT_GENERATE) mkdir -p "$$(dirname "$@")" ; echo 'int main() { return 0; }' > "$@"
|
||||
|
||||
# Check if a function is present
|
||||
$(OBJDIR)/HAVE_%: $(OBJDIR)/CONFIG_CHECK_%.c
|
||||
$(PRINT_CONFIG) $(CC_CONFIG)
|
||||
$(OBJDIR)/CONFIG_CHECK_%.c: config/check_%.c
|
||||
$(PRINT_COPY) cp $< $@
|
||||
|
||||
.PRECIOUS: $(OBJDIR)/CONFIG_HAVE_%.c $(OBJDIR)/CONFIG_HAVE_%.cpp
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Makefile optimization tricks
|
||||
|
|
Loading…
Reference in New Issue