-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (45 loc) · 1.38 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
include Makefile.config
MAIN := $(TITLE).js
OBJECTS := $(addprefix $(OBJDIR)/, $(SOURCES))
SOURCES := $(addprefix $(SRCDIR)/, $(SOURCES))
TREEDIRS := $(filter-out $(OBJDIR)/, $(sort $(dir $(OBJECTS))))
TESTFILES := $(patsubst support/%.js, $(TESTDIR)/%.js, $(SUPPORT))
v := 0
V := $(v)
AT_0 := @
AT_1 :=
AT := $(AT_$(V))
log :=
LOG := $(log)
M4FLAGS := -P $(foreach TAG, $(LOG), -DLOG_$(TAG))
INITOBJ := printf "\n"
debug : M4FLAGS += -DDEBUG
debug : INITOBJ := printf "\n/* %s */\n"
debug : $(MAIN) tests
release : $(MAIN) tests
.PHONY : tests
tests : $(TESTFILES) $(TESTDIR)/$(MAIN)
$(TITLE) : $(MAIN)
$(MAIN) : $(OBJDIR)/$(NSDEFS) $(OBJECTS)
$(AT)cat $^ > $@
$(TESTDIR)/$(MAIN) : $(MAIN)
$(AT)cp $< $@
$(TESTFILES) : $(TESTDIR)/%.js : support/%.js
$(AT)cp $< $@
$(OBJDIR) :
$(AT)mkdir -p $@
$(TREEDIRS) : | $(OBJDIR)/$(NSDEFS)
$(AT)mkdir -p $@
$(AT)printf "hd.%s= new hd.ns.Namespace();\n" $(subst /,.,$(patsubst $(OBJDIR)/%,%,$@)) >>$(OBJDIR)/$(NSDEFS);
$(OBJDIR)/$(NSDEFS) : $(MACRODEFS) $(SRCDIR)/$(NSDEFS) | $(OBJDIR)
$(AT)$(INITOBJ) $(patsubst $(OBJDIR)/%, %, $@) > $@
$(AT)m4 $(M4FLAGS) $^ >> $@
$(OBJECTS) : $(OBJDIR)/% : $(MACRODEFS) $(SRCDIR)/% | $(TREEDIRS)
$(AT)$(INITOBJ) $(patsubst $(OBJDIR)/%, %, $@) > $@
$(AT)m4 $(M4FLAGS) $^ >> $@
$(AT)printf "\n" >> $@
.PHONY: clean
clean:
$(AT)rm -f $(MAIN)
$(AT)rm -rf $(OBJDIR)
$(AT)rm -f $(TESTFILES) $(TESTDIR)/$(MAIN)