New config.mk and Makefile

This commit is contained in:
Jan-Piet Mens
2015-08-15 12:50:16 +02:00
parent 8593282336
commit e779d44d63
5 changed files with 22 additions and 3 deletions

View File

@@ -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

View File

@@ -8,4 +8,5 @@ Recorder
## Installation
1. Edit `config.h`
2. Edit `config.mk` and select features
2. Type `make`

View File

@@ -1,2 +1 @@
#define HAVE_REDIS
#define JSONDIR "store"

2
config.mk Normal file
View File

@@ -0,0 +1,2 @@
# Select features
HAVE_REDIS ?= yes

View File

@@ -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)
{