<NME> Makefile
<BEF> CC=gcc
CFLAGS+=-g -Wall -Wextra -Wno-unused-parameter -DDEBUG
INCLUDE+=-Iunix -Ilib -Iext
CS2a = -ltomcrypt -ltommath -DLTM_DESC -DCS_2a unix/crypt_libtom*.c
JSON = ../js0n/js0n.c ../js0n/j0g.c -I../js0n

LIB = src/lib/lob.c src/lib/hashname.c src/lib/xht.c src/lib/js0n.c src/lib/base32.c src/lib/chacha.c src/lib/murmur.c src/lib/jwt.c src/lib/base64.c src/lib/aes128.c src/lib/sha256.c src/lib/uECC.c
E3X = src/e3x/e3x.c src/e3x/self.c src/e3x/exchange.c src/e3x/cipher.c
MESH = src/mesh.c src/link.c src/chan.c
EXT = 
#NET = src/net/loopback.c src/net/udp4.c src/net/tcp4.c src/net/serial.c
NET = src/net/loopback.c 
UTIL = src/util/util.c src/util/chunks.c src/util/frames.c src/unix/util.c src/unix/util_sys.c
THROWBACK = throwback/all.c throwback/lob.c throwback/xform.c throwback/xform_hex.c

# CS1c by default
CS = src/e3x/cs1c/cs1c.c 

# check for CS3a deps
ifneq ("$(wildcard node_modules/libsodium-c/src/libsodium/.libs/libsodium.a)","")
CS += src/e3x/cs3a/cs3a.c
LDFLAGS += node_modules/libsodium-c/src/libsodium/.libs/libsodium.a
INCLUDE += -I./node_modules/libsodium-c/src/libsodium/include
else
CS += src/e3x/cs3a_disabled.c
endif

LIB_OBJFILES = $(patsubst %.c,%.o,$(LIB))
E3X_OBJFILES = $(patsubst %.c,%.o,$(E3X))
MESH_OBJFILES = $(patsubst %.c,%.o,$(MESH))
EXT_OBJFILES = $(patsubst %.c,%.o,$(EXT))
NET_OBJFILES = $(patsubst %.c,%.o,$(NET))
UTIL_OBJFILES = $(patsubst %.c,%.o,$(UTIL))
CS_OBJFILES = $(patsubst %.c,%.o,$(CS))
TB_OBJFILES = $(patsubst %.c,%.o,$(THROWBACK))

FULL_OBJFILES = $(LIB_OBJFILES) $(E3X_OBJFILES) $(MESH_OBJFILES) $(EXT_OBJFILES) $(NET_OBJFILES) $(UTIL_OBJFILES) $(CS_OBJFILES)

IDGEN_OBJFILES = $(FULL_OBJFILES) util/idgen.o
ROUTER_OBJFILES = $(FULL_OBJFILES) src/net/udp4.o util/router.o 
PING_OBJFILES = $(FULL_OBJFILES) util/ping.o 

HEADERS=$(wildcard include/*.h)

all: idgen ping static
	@echo "TODO\t`git grep TODO | wc -l | tr -d ' '`"

deps:
	npm install

# todo, this header mangling process is a drag

static: libtelehash
	@cat $(LIB) $(E3X) $(MESH) $(EXT) $(UTIL) > telehash.c
	@cat include/lob.h include/xht.h include/e3x_cipher.h include/e3x_self.h include/e3x_exchange.h include/hashname.h include/mesh.h include/link.h include/chan.h include/util_chunks.h include/util_frames.h include/*.h > telehash.h
	@sed -i.bak "/#include \".*h\"/d" telehash.h
	@rm -f telehash.h.bak

static-cs1c:
	@echo "#include <telehash.h>" > telehash.c
	@cat $(LIB) $(E3X) $(MESH) $(EXT) $(UTIL) src/e3x/cs1c/cs1c.c src/e3x/cs3a_disabled.c >> telehash.c
	@sed -i '' "/#include \".*h\"/d" telehash.c
	@cat include/lob.h include/xht.h include/e3x_cipher.h include/e3x_self.h include/e3x_exchange.h include/hashname.h include/mesh.h include/link.h include/chan.h include/util_chunks.h include/util_frames.h include/*.h > telehash.h
	@sed -i.bak "/#include \".*h\"/d" telehash.h
	@rm -f telehash.h.bak

static-throwback:
	@echo "#include <telehash.h>" > telehash.c
	@cat $(LIB) $(E3X) $(MESH) $(EXT) $(UTIL) $(THROWBACK) >> telehash.c
	@sed -i '' "/#include \".*h\"/d" telehash.c
	@cat include/lob.h include/xht.h include/e3x_cipher.h include/e3x_self.h include/e3x_exchange.h include/hashname.h include/mesh.h include/link.h include/chan.h include/util_chunks.h include/util_frames.h include/*.h throwback/throwback.h > telehash.h
	@sed -i.bak "/#include \".*h\"/d" telehash.h
	@rm -f telehash.h.bak

libtelehash: $(FULL_OBJFILES)
	rm -f libtelehash.a
	ar crs libtelehash.a $(FULL_OBJFILES)

throwback-update:
	cd ../throwback && make static
	cp ../throwback/dew.c throwback/
	cp ../throwback/dew.h throwback/

throwback-test: $(FULL_OBJFILES) $(TB_OBJFILES)
	$(CC) $(CFLAGS) $(INCLUDE) -o test/bin/test_throwback throwback/test.c throwback/dew.c $(TB_OBJFILES) $(FULL_OBJFILES) $(LDFLAGS)
	./test/bin/test_throwback

.PHONY: arduino test TAGS

test: $(FULL_OBJFILES) ping
	cd test; $(MAKE) $(MFLAGS)

TAGS:
	find . | grep ".*\.\(h\|c\)" | xargs etags -f TAGS

%.o : %.c $(HEADERS)
	$(CC) $(INCLUDE) $(CFLAGS) -c $< -o $@

idgen: $(IDGEN_OBJFILES)
	$(CC) $(CFLAGS) -o bin/idgen $(IDGEN_OBJFILES) $(LDFLAGS)

ping:
#ping: $(PING_OBJFILES)
#	$(CC) $(CFLAGS) -o bin/ping $(PING_OBJFILES) $(LDFLAGS)

router: $(ROUTER_OBJFILES)
	$(CC) $(CFLAGS) -o bin/router $(ROUTER_OBJFILES) $(LDFLAGS)

#mesh:
#	$(CC) $(CFLAGS) -o bin/mesh util/mesh.c src/*.c unix/util.c src/ext/*.c $(ARCH)

#port:
#	$(CC) $(CFLAGS) -o bin/port util/port.c src/*.c unix/util.c src/ext/*.c $(ARCH)

clean:
	rm -rf bin/*
	rm -f arduino/src/telehash/*.h
	rm -f arduino/src/telehash/*.c
	rm -f id.json
	cd test; $(MAKE) clean
	find . -name "*.o" -exec rm -f {} \;
	rm -f lib*.a

<MSG> moving DEBUG to default in, flag to compile out

<DFF> @@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS+=-g -Wall -Wextra -Wno-unused-parameter -DDEBUG
+CFLAGS+=-g -Wall -Wextra -Wno-unused-parameter
 INCLUDE+=-Iunix -Ilib -Iext
 CS2a = -ltomcrypt -ltommath -DLTM_DESC -DCS_2a unix/crypt_libtom*.c
 JSON = ../js0n/js0n.c ../js0n/j0g.c -I../js0n

{'addition_count': 1, 'commit_subject': 'moving DEBUG to default in, flag to compile out', 'deletion_count': 1, 'file_extension': '', 'lang': 'Makefile', 'license': 'mit', 'repo_name': 'telehash/telehash-c'}