parser: fix `extension static inline` in bits/byteswap.h
[m6w6/ext-psi] / Makefile.frag
1
2 # provide headers in builddir, so they do not end up in /usr/include/ext/psi/src
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)/types:
9 mkdir -p $@
10 $(PHP_PSI_BUILDDIR)/types/%.h: $(PHP_PSI_SRCDIR)/src/types/%.h | $(PHP_PSI_BUILDDIR)/types
11 @cat >$@ <$<
12 $(PHP_PSI_BUILDDIR)/%.h: $(PHP_PSI_SRCDIR)/src/%.h
13 @cat >$@ <$<
14
15 $(PHP_PSI_SRCDIR)/src/parser_proc.h: $(PHP_PSI_SRCDIR)/src/parser_proc.c
16
17 $(PHP_PSI_SRCDIR)/src/parser_proc.c: $(PHP_PSI_SRCDIR)/src/parser_proc_grammar.y
18 # trickery needed for relative #line directives
19 cd $(PHP_PSI_SRCDIR) && bison -Wall -v -d -o $(patsubst $(PHP_PSI_SRCDIR)/%,%,$@) $(patsubst $(PHP_PSI_SRCDIR)/%,%,$<)
20
21 $(PHP_PSI_SRCDIR)/src/parser.re: $(PHP_PSI_SRCDIR)/src/parser_proc.h
22 touch $@
23 $(PHP_PSI_SRCDIR)/src/parser.c: $(PHP_PSI_SRCDIR)/src/parser.re
24 # trickery needed for relative #line directives
25 cd $(PHP_PSI_SRCDIR) && $(RE2C) -o $(patsubst $(PHP_PSI_SRCDIR)/%,%,$@) $(patsubst $(PHP_PSI_SRCDIR)/%,%,$<)
26
27 $(PHP_PSI_SRCDIR)/src/calc/%.h: $(PHP_PSI_SRCDIR)/scripts/gen_calc_%.php $(PHP_PSI_SRCDIR)/scripts/_include.php
28 $(PHP_EXECUTABLE) $< >$@
29
30 $(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
31
32 .PHONY: psi-generated
33 psi-generated: $(PHP_PSI_GENERATED)
34
35
36 PHP_PSI_DEPEND = $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep))
37
38 $(PHP_PSI_BUILDDIR)/%.dep: $(PHP_PSI_SRCDIR)/%.c | $(PHP_PSI_GENERATED)
39 $(CC) -MM -MG -MF $@ -MT $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(@:.dep=.lo)) \
40 $(CPPFLAGS) $(DEFS) $(INCLUDES) $< \
41 || touch $@
42
43 php_psi_stdinc.h:
44 php_psi_posix.h:
45
46 ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
47 ifneq ($(PSI_DEPS),)
48 -include $(PHP_PSI_DEPEND)
49 endif
50 endif
51
52 .PHONY: psi-build-headers
53 psi-build-headers: $(PHP_PSI_HEADERS)
54
55 .PHONY: psi-clean-headers
56 psi-clean-headers:
57 -rm -f $(PHP_PSI_HEADERS)
58
59 .PHONY: psi-clean
60 psi-clean: psi-clean-headers
61
62 .PHONY: psi-clean-objects
63 psi-clean-objects:
64 -rm -f $(PHP_PSI_BUILDDIR)/src/*o
65 -rm -f $(PHP_PSI_BUILDDIR)/src/types/*o
66
67 psi-clean: psi-clean-objects
68
69 .PHONY: psi-clean-generated
70 psi-clean-generated:
71 -rm -f $(PHP_PSI_GENERATED)
72
73 .PHONY: psi-clean-aux
74 psi-clean-aux: psi-clean-aux-bin psi-clean-aux-src
75
76 .PHONY: psi-clean-aux-src
77 psi-clean-aux-src:
78 -rm -f $(PHP_PSI_BUILDDIR)/lempar.c $(PHP_PSI_BUILDDIR)/lemon.c
79
80 .PHONY: psi-clean-aux-bin
81 psi-clean-aux-bin:
82 -rm -f $(PHP_PSI_BUILDDIR)/lemon
83
84 psi-clean: psi-clean-aux
85
86 .PHONY: psi-clean-depend
87 psi-clean-depend:
88 -rm -f $(PHP_PSI_DEPEND)
89
90 psi-clean: psi-clean-depend
91
92 .PHONY: psi-watch
93 psi-watch:
94 -while inotifywait -q -e modify -r $(PHP_PSI_SRCDIR); do $(MAKE); done
95
96 install-headers: psi-build-headers
97 clean: psi-clean-headers psi-clean-aux
98 ifneq ($(PSI_DEPS),)
99 clean: psi-clean-depend
100 endif