-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
122 lines (96 loc) · 4.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
CC=gcc
EMCC=emcc
CFLAGS+=-g -std=c99 -std=gnu99 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DDEBUG -D_GNU_SOURCE
#CFLAGS+=-Weverything -Wno-unused-macros -Wno-undef -Wno-gnu-zero-variadic-macro-arguments -Wno-padded -Wno-gnu-label-as-value -Wno-gnu-designator -Wno-missing-prototypes -Wno-format-nonliteral
INCLUDE+=-Iinclude -Iinclude/lib -Iunix -Ithrowback
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