From b608c594799c79c227ffbb2009c9aa39b0d68033 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 17 Nov 2020 01:42:28 -0700 Subject: [PATCH] src: make and use a config.h file Not every system is the same. Automatically create a config.h file that contains "interesting" information about a system that cannot be determined at compile time via predefined macros. Provide this file via a CONFIG_H macro to interested source files that can then `#include CONFIG_H` when it's defined. Currently only the framework is provided. In other words, the config.h file is created but is always empty and the proper CONFIG_H macro definition is passed on to interested source files. Signed-off-by: Kyle J. McKay --- src/.gitignore | 1 + src/GNUmakefile | 9 ++++++--- src/make-config-h.sh | 4 ++++ src/peek_packet.c | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100755 src/make-config-h.sh diff --git a/src/.gitignore b/src/.gitignore index b321c54..0cb6533 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -7,6 +7,7 @@ can_user_push can_user_push_http.d* can_user_push_http.o* can_user_push_http +config.h getent.d* getent.o* getent diff --git a/src/GNUmakefile b/src/GNUmakefile index 184cc5a..1e3a69f 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile @@ -19,7 +19,7 @@ clean : rm -rf throttle.o* throttle.d* throttle rm -rf ulimit512.o* ulimit512.d* ulimit512 rm -rf ltsha256.o* ltsha256.d* ltsha256 - rm -f GROUP-FILE PASSWD-FILE SOCKET-FILE + rm -f config.h GROUP-FILE PASSWD-FILE SOCKET-FILE install : @@ -51,6 +51,9 @@ SOCKET-FILE: FORCE echo "$$TRACK_SOCKET_FILE" >SOCKET-FILE; \ fi +config.h : make-config-h.sh + ./make-config-h.sh "$(CC)" >$@ + can_user_push : can_user_push.c $(CC) -o $@ $(CFLAGS) $? @@ -69,8 +72,8 @@ list_packs.inc : list_packs.txt list_packs : list_packs.c list_packs.inc $(CC) -o $@ $(CFLAGS) list_packs.c -peek_packet : peek_packet.c - $(CC) -o $@ $(CFLAGS) peek_packet.c +peek_packet : config.h peek_packet.c + $(CC) -o $@ $(CFLAGS) -DCONFIG_H='"config.h"' peek_packet.c rangecgi : rangecgi.c $(CC) -o $@ $(CFLAGS) rangecgi.c diff --git a/src/make-config-h.sh b/src/make-config-h.sh new file mode 100755 index 0000000..78fe96a --- /dev/null +++ b/src/make-config-h.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e +CC="$1" +: "${CC:=cc}" diff --git a/src/peek_packet.c b/src/peek_packet.c index fbbb324..220e2dc 100644 --- a/src/peek_packet.c +++ b/src/peek_packet.c @@ -195,6 +195,10 @@ NON-NULL-BYTE = %x01-FF */ +#ifdef CONFIG_H +#include CONFIG_H +#endif + #include #include #include -- 2.11.4.GIT