From d249205f3e61b82253dbfabd21da3c5ea1fe83fb Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 4 Jan 2014 01:24:48 +0000 Subject: Merge cleanup of feature tests to VERSION_1_12, resolving conflicts. --- Makefile | 63 ++++++++++++--------------------------------------------------- configure | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 51 deletions(-) create mode 100755 configure diff --git a/Makefile b/Makefile index 9545803f..9b9e8426 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,14 @@ DBLN = llib-lapropos.ln llib-lmandocdb.ln llib-lman.cgi.ln llib-lcatman.ln all: mandoc preconv demandoc $(DBBIN) +TESTSRCS = test-betoh64.c \ + test-fgetln.c \ + test-getsubopt.c \ + test-mmap.c \ + test-strlcat.c \ + test-strlcpy.c \ + test-strptime.c + SRCS = Makefile \ NEWS \ TODO \ @@ -160,17 +168,11 @@ SRCS = Makefile \ term.h \ term_ascii.c \ term_ps.c \ - test-betoh64.c \ - test-fgetln.c \ - test-getsubopt.c \ - test-mmap.c \ - test-strlcat.c \ - test-strlcpy.c \ - test-strptime.c \ tree.c \ vol.c \ vol.in \ - whatis.1 + whatis.1 \ + $(TESTSRCS) LIBMAN_OBJS = man.o \ man_hash.o \ @@ -390,50 +392,9 @@ mdocml.tar.gz: $(SRCS) index.html: $(INDEX_OBJS) -config.h: config.h.pre config.h.post +config.h: configure config.h.pre config.h.post $(TESTSRCS) rm -f config.log - ( cat config.h.pre; \ - echo; \ - echo '#define VERSION "$(VERSION)"'; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-fgetln test-fgetln.c >> config.log 2>&1; then \ - echo '#define HAVE_FGETLN'; \ - rm test-fgetln; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-strptime test-strptime.c >> config.log 2>&1; then \ - echo '#define HAVE_STRPTIME'; \ - rm test-strptime; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \ - echo '#define HAVE_GETSUBOPT'; \ - rm test-getsubopt; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-strlcat test-strlcat.c >> config.log 2>&1; then \ - echo '#define HAVE_STRLCAT'; \ - rm test-strlcat; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-mmap test-mmap.c >> config.log 2>&1; then \ - echo '#define HAVE_MMAP'; \ - rm test-mmap; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \ - echo '#define HAVE_STRLCPY'; \ - rm test-strlcpy; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-betoh64 test-betoh64.c >> config.log 2>&1; then \ - echo '#define HAVE_BETOH64'; \ - rm test-betoh64; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-strcasestr test-strcasestr.c >> config.log 2>&1; then \ - echo '#define HAVE_STRCASESTR'; \ - rm test-strcasestr; \ - fi; \ - if $(CC) $(CFLAGS) -Werror -Wno-unused -o test-strsep test-strsep.c >> config.log 2>&1; then \ - echo '#define HAVE_STRSEP'; \ - rm test-strsep; \ - fi; \ - echo; \ - cat config.h.post \ - ) > $@ + CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure .h.h.html: highlight -I $< >$@ diff --git a/configure b/configure new file mode 100755 index 00000000..4465178a --- /dev/null +++ b/configure @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Copyright (c) 2014 Ingo Schwarze +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +set -e +exec > config.h 2> config.log + +CFLAGS="${CFLAGS} -Wno-unused -Werror" + +runtest() { + echo ${CC} ${CFLAGS} -o test-${1} test-${1}.c 1>&2 + ${CC} ${CFLAGS} -o "test-${1}" "test-${1}.c" 1>&2 || return 0 + "./test-${1}" && echo "#define HAVE_${2}" \ + || echo FAILURE: test-${1} returned $? 1>&2 + rm "test-${1}" +} + +cat config.h.pre +echo +echo "#define VERSION \"${VERSION}\"" +runtest betoh64 BETOH64 +runtest fgetln FGETLN +runtest getsubopt GETSUBOPT +runtest mmap MMAP +runtest strcasestr STRCASESTR +runtest strlcat STRLCAT +runtest strlcpy STRLCPY +runtest strptime STRPTIME +runtest strsep STRSEP +echo +cat config.h.post + +exit 0 -- cgit v1.2.3-56-ge451