-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstartle.mk
31 lines (23 loc) · 885 Bytes
/
startle.mk
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
include startle/gen.mk
print-%:
@echo $* = $($*)
# modified from http://scottmcpeak.com/autodepend/autodepend.html
# pull in dependency info for *existing* .o files
-include $(DEPS)
# generate dependency info and headers
$(BUILD_DIR)/%.d: %.c
@mkdir -p $(dir $@)
@$(CC) $(INCLUDE) -MM $(CFLAGS) $*.c -MG -MT $(BUILD_DIR)/$*.o -o- 2>/dev/null | \
sed -E -e 's/ ([a-zA-Z][^ .]*)\.h/ .gen\/\1.h/g' > $(BUILD_DIR)/$*.d
LOCAL_HEADERS += $(shell find -L . -not -path './.gen/*' -name '*.h')
LOCAL_HEADERS := $(sort $(LOCAL_HEADERS))
GEN_LOCAL_HEADERS := $(patsubst ./%.h, .gen/%.h, $(LOCAL_HEADERS))
# hack to catch any dependencies in .gen that are local headers
$(GEN_LOCAL_HEADERS): .gen/%.h: %.h
@mkdir -p $(dir $@)
ln -fs $(PWD)/$*.h .gen/$*.h
# compile
$(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.d
@echo $*.o
$(CC) -c $(CFLAGS) $*.c -o $(BUILD_DIR)/$*.o
.SECONDARY: $(GEN)