fix char_width decl
[m6w6/ext-psi] / Makefile.frag
1
2 # provide headers in builddir, so they do not end up in a "src" subdirectory
3
4 PHP_PSI_HEADERS := $(addprefix $(PHP_PSI_BUILDDIR)/,$(PHP_PSI_HEADERS))
5 PHP_PSI_SOURCES := $(addprefix $(PHP_PSI_SRCDIR)/,$(PHP_PSI_SOURCES))
6 PHP_PSI_GENERATED:=$(addprefix $(PHP_PSI_SRCDIR)/,$(PHP_PSI_GENERATED))
7
8 $(PHP_PSI_BUILDDIR)/calc:
9 mkdir -p $@
10 $(PHP_PSI_BUILDDIR)/calc/%.h: $(PHP_PSI_SRCDIR)/src/calc/%.h | $(PHP_PSI_BUILDDIR)/calc
11 @cat >$@ <$<
12 $(PHP_PSI_BUILDDIR)/types:
13 mkdir -p $@
14 $(PHP_PSI_BUILDDIR)/types/%.h: $(PHP_PSI_SRCDIR)/src/types/%.h | $(PHP_PSI_BUILDDIR)/types
15 @cat >$@ <$<
16 $(PHP_PSI_BUILDDIR)/%.h: $(PHP_PSI_SRCDIR)/src/%.h
17 @cat >$@ <$<
18
19 $(PHP_PSI_SRCDIR)/src/parser_proc.h: $(PHP_PSI_SRCDIR)/src/parser_proc.c
20
21 $(PHP_PSI_SRCDIR)/src/parser_proc.c: $(PHP_PSI_SRCDIR)/src/parser_proc_grammar.y
22 # trickery needed for relative #line directives
23 cd $(PHP_PSI_SRCDIR) && bison -Wall -v -d -o $(patsubst $(PHP_PSI_SRCDIR)/%,%,$@) $(patsubst $(PHP_PSI_SRCDIR)/%,%,$<)
24
25 $(PHP_PSI_SRCDIR)/src/parser_scan.re: $(PHP_PSI_SRCDIR)/src/parser_proc.h
26 touch $@
27 $(PHP_PSI_SRCDIR)/src/parser_scan.c: $(PHP_PSI_SRCDIR)/src/parser_scan.re
28 # trickery needed for relative #line directives
29 cd $(PHP_PSI_SRCDIR) && $(RE2C) -o $(patsubst $(PHP_PSI_SRCDIR)/%,%,$@) $(patsubst $(PHP_PSI_SRCDIR)/%,%,$<)
30
31 $(PHP_PSI_SRCDIR)/src/calc/%.h: $(PHP_PSI_SRCDIR)/scripts/gen_calc_%.php $(PHP_PSI_SRCDIR)/scripts/_include.php
32 $(PHP_EXECUTABLE) $< >$@
33
34 $(PHP_PSI_SRCDIR)/src/calc.h: | $(PHP_PSI_SRCDIR)/src/calc/basic.h $(PHP_PSI_SRCDIR)/src/calc/bin.h $(PHP_PSI_SRCDIR)/src/calc/bool.h $(PHP_PSI_SRCDIR)/src/calc/unary.h $(PHP_PSI_SRCDIR)/src/calc/cast.h $(PHP_PSI_SRCDIR)/src/calc/cmp.h $(PHP_PSI_SRCDIR)/src/calc/oper.h
35
36 .PHONY: psi-generated
37 psi-generated: $(PHP_PSI_GENERATED)
38
39
40 PHP_PSI_DEPEND = $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep))
41
42 $(PHP_PSI_BUILDDIR)/%.dep: $(PHP_PSI_SRCDIR)/%.c | $(PHP_PSI_GENERATED)
43 @echo Generating $@ ...
44 @$(CC) -MM -MG -MF $@ -MT $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(@:.dep=.lo)) \
45 $(CPPFLAGS) $(DEFS) $(INCLUDES) $< \
46 || touch $@
47
48 php_psi_stdinc.h:
49 php_psi_posix.h:
50
51 ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
52 ifneq ($(PSI_DEPS),)
53 -include $(PHP_PSI_DEPEND)
54 endif
55 endif
56
57 .PHONY: psi-build-headers
58 psi-build-headers: $(PHP_PSI_HEADERS)
59
60 .PHONY: psi-clean-headers
61 psi-clean-headers:
62 -rm -f $(PHP_PSI_HEADERS)
63
64 .PHONY: psi-clean
65 psi-clean: psi-clean-headers
66
67 .PHONY: psi-clean-objects
68 psi-clean-objects:
69 -rm -f $(PHP_PSI_BUILDDIR)/src/*o
70 -rm -f $(PHP_PSI_BUILDDIR)/src/types/*o
71
72 psi-clean: psi-clean-objects
73
74 .PHONY: psi-clean-generated
75 psi-clean-generated:
76 -rm -f $(PHP_PSI_GENERATED)
77
78 .PHONY: psi-clean-depend
79 psi-clean-depend:
80 -rm -f $(PHP_PSI_DEPEND)
81
82 psi-clean: psi-clean-depend
83
84 .PHONY: psi-watch
85 psi-watch:
86 -while inotifywait -q -e modify -r $(PHP_PSI_SRCDIR); do $(MAKE); done
87
88 .PHONY: psi-paranoid-backups
89 psi-paranoid-backups:
90 @-if test -z "$(REPO)"; then \
91 echo; \
92 echo "Usage: make psi-paranoid-backups REPO=<repo to push to>"; \
93 echo; \
94 else \
95 echo "Watching $(PHP_PSI_SRCDIR) for changes to flush and push to $(REPO) ..."; \
96 while inotifywait -q -e modify -r $(PHP_PSI_SRCDIR); do \
97 git ci -am flush; \
98 git push $(REPO); \
99 done; \
100 fi
101
102 install-headers: psi-build-headers
103 clean: psi-clean-headers
104 ifneq ($(PSI_DEPS),)
105 clean: psi-clean-depend
106 endif
107