From e779d44d63c6da3682f2c1cef56607eef508bfcb Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Sat, 15 Aug 2015 12:50:16 +0200 Subject: [PATCH] New config.mk and Makefile --- Makefile | 18 ++++++++++++++++-- README.md | 1 + config.h | 1 - config.mk | 2 ++ ghash.c | 3 +++ 5 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 config.mk diff --git a/Makefile b/Makefile index 2ad0d7f..c432250 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,21 @@ +include config.mk + +LIBS = -lcurl -lmosquitto CFLAGS=-Wall -Werror -g +ifneq ($(HAVE_REDIS),no) + CFLAGS += -DHAVE_REDIS=1 + LIBS += -lhiredis +endif + + all: ot-recorder #### ot-reader ot-reader: ot-reader.c json.o utstring.h ghash.o mkpath.o jget.o - cc $(CFLAGS) ot-reader.c -o ot-reader json.o ghash.o mkpath.o jget.o -lhiredis + $(CC) $(CFLAGS) ot-reader.c -o ot-reader json.o ghash.o mkpath.o jget.o $(LIBS) ot-recorder: ot-recorder.c json.o utarray.h utstring.h geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o config.h udata.h misc.o - cc $(CFLAGS) ot-recorder.c -o ot-recorder json.o geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o misc.o -lmosquitto -lcurl -lhiredis + $(CC) $(CFLAGS) ot-recorder.c -o ot-recorder json.o geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o misc.o $(LIBS) geo.o: geo.h geo.c udata.h geohash.o: geohash.h geohash.c udata.h @@ -16,3 +25,8 @@ ghash.o: ghash.h ghash.c config.h udata.h misc.h safewrite.o: safewrite.h safewrite.c jget.o: jget.c jget.h json.h misc.o: misc.c misc.h udata.h + +clean: + rm -f *.o +clobber: clean + rm -f ot-recorder ocat diff --git a/README.md b/README.md index 231d8e6..e843c17 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,5 @@ Recorder ## Installation 1. Edit `config.h` +2. Edit `config.mk` and select features 2. Type `make` diff --git a/config.h b/config.h index 00446f1..f313bcf 100644 --- a/config.h +++ b/config.h @@ -1,2 +1 @@ -#define HAVE_REDIS #define JSONDIR "store" diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..57b1916 --- /dev/null +++ b/config.mk @@ -0,0 +1,2 @@ +# Select features +HAVE_REDIS ?= yes diff --git a/ghash.c b/ghash.c index aa50ca4..e47d477 100644 --- a/ghash.c +++ b/ghash.c @@ -3,6 +3,8 @@ #include "ghash.h" #include "misc.h" +#ifdef HAVE_REDIS + void redis_ping(redisContext **redis) { struct timeval timeout = { 1, 500000 }; // 1.5 seconds @@ -87,6 +89,7 @@ int ghash_get_redis_cache(redisContext **redis, char *ghash, UT_string *addr, UT return (found); } +#endif /* !HAVE_REDIS */ int ghash_readcache(struct udata *ud, char *ghash, UT_string *addr, UT_string *cc) {