-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
33 lines (26 loc) · 1.02 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
# User modifiable variables
EXTEND = cogchef-default.PRE.h
API_DIR = api
OUT = out
DFLAGS = -DCOGCHEF_STRUCT_INIT -DCOGCHEF_JSON_ENCODER -DCOGCHEF_JSON_DECODER
# Remove suffix from EXTEND
EXTEND_NO_EXT_EXPAND = "$$(echo $(EXTEND) | sed -e 's/\.PRE\.h//')"
# Convert %.PRE.h -> %.h
HEADERS_EXPAND = "$$(echo $(API_DIR)/*.PRE.h | sed -e 's/\.PRE\.h/.h/g')"
# Join all API_DIR files together
TEMPFILE = cogchef-amalgamation.PRE.h
TEMPFILE_EXPAND = headers=$$(echo $(API_DIR)/*.PRE.h); for header in $$headers; do echo "\#include \"$$header\"" >> $(TEMPFILE); done
BUILD = $(MAKE) EXTEND_NO_EXT=$(EXTEND_NO_EXT_EXPAND) OUT_NO_EXT=$(OUT) DFLAGS="$(DFLAGS)" -f cogchef.mk
all:
@ touch $(TEMPFILE) && $(TEMPFILE_EXPAND)
@ $(BUILD) TEMPFILE=$(TEMPFILE) || rm -f $(TEMPFILE)
headers:
@ $(BUILD) HEADERS=$(HEADERS_EXPAND) $@
echo:
@ echo 'EXTEND: $(EXTEND)'
@ echo 'API_DIR: $(API_DIR)'
@ $(BUILD) HEADERS=$(HEADERS_EXPAND) $@
clean:
@ rm -f $(TEMPFILE)
@ $(BUILD) HEADERS=$(HEADERS_EXPAND) $@
.PHONY: headers echo clean