From 0ef723e6c448f555c52b156a8abf488b4dd6f368 Mon Sep 17 00:00:00 2001 From: Evan Gates Date: Mon, 3 Oct 2016 15:55:22 -0700 Subject: [PATCH] use only one getconf header this simplifies the getconf.sh script and handling parallel make --- Makefile | 10 +++++----- getconf.c | 17 +---------------- getconf.sh | 18 ++++++++---------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 6b2bfdf..25bab70 100644 --- a/Makefile +++ b/Makefile @@ -205,10 +205,10 @@ $(LIBUTIL): $(LIBUTILOBJ) $(AR) rc $@ $? $(RANLIB) $@ -getconf.c: confstr_l.h limits_l.h sysconf_l.h pathconf_l.h +getconf.o: getconf.h -confstr_l.h limits_l.h sysconf_l.h pathconf_l.h: getconf.sh - ./getconf.sh +getconf.h: getconf.sh + ./getconf.sh > $@ install: all mkdir -p $(DESTDIR)$(PREFIX)/bin @@ -234,7 +234,7 @@ dist: clean sbase-box: $(LIB) $(SRC) mkdir -p build cp $(HDR) build - cp confstr_l.h limits_l.h sysconf_l.h pathconf_l.h build + cp getconf.h build for f in $(SRC); do sed "s/^main(/$$(echo "$${f%.c}" | sed s/-/_/g)_&/" < $$f > build/$$f; done echo '#include ' > build/$@.c echo '#include ' >> build/$@.c @@ -270,7 +270,7 @@ sbase-box-uninstall: uninstall clean: rm -f $(BIN) $(OBJ) $(LIB) sbase-box sbase-$(VERSION).tar.gz - rm -f confstr_l.h limits_l.h sysconf_l.h pathconf_l.h + rm -f getconf.h .PHONY: all install uninstall dist sbase-box sbase-box-install sbase-box-uninstall clean diff --git a/getconf.c b/getconf.c index 94bff80..e611659 100644 --- a/getconf.c +++ b/getconf.c @@ -12,22 +12,7 @@ struct var { long v; }; -static const struct var pathconf_l[] = { -#include "pathconf_l.h" -}; - -static const struct var sysconf_l[] = { -#include "sysconf_l.h" -}; - -static const struct var confstr_l[] = { -#include "confstr_l.h" -}; - -static const struct var limits_l[] = { -#include "limits_l.h" -}; - +#include "getconf.h" void usage(void) diff --git a/getconf.sh b/getconf.sh index cca5873..e826385 100755 --- a/getconf.sh +++ b/getconf.sh @@ -1,14 +1,12 @@ #!/bin/sh -ifdef() -{ - awk '{printf("#ifdef %s\n"\ - "\t{\"%s\",\t%s},\n"\ - "#endif\n", $2, $1, $2)}' > $1 +ifdef() { + printf 'static const struct var %s[] = {\n' "$1" + awk '{printf("#ifdef %s\n\t{\"%s\",\t%s},\n#endif\n", $2, $1, $2)}' + echo '};' } - -cat <