Commit | Line | Data |
---|---|---|
97a9a385 MW |
1 | ### -*-makefile-*- |
2 | ### | |
3 | ### Build script for the SOD translator | |
4 | ### | |
5 | ### (c) 2015 Straylight/Edgeware | |
6 | ### | |
7 | ||
8 | ###----- Licensing notice --------------------------------------------------- | |
9 | ### | |
10 | ### This file is part of the Sensble Object Design, an object system for C. | |
11 | ### | |
12 | ### SOD is free software; you can redistribute it and/or modify | |
13 | ### it under the terms of the GNU General Public License as published by | |
14 | ### the Free Software Foundation; either version 2 of the License, or | |
15 | ### (at your option) any later version. | |
16 | ### | |
17 | ### SOD is distributed in the hope that it will be useful, | |
18 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | ### GNU General Public License for more details. | |
21 | ### | |
22 | ### You should have received a copy of the GNU General Public License | |
23 | ### along with SOD; if not, write to the Free Software Foundation, | |
24 | ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
25 | ||
b5d086c2 | 26 | include $(top_srcdir)/vars.am |
97a9a385 | 27 | |
6b5bf01a MW |
28 | nobase_dist_pkglispsrc_DATA = $(LISP_SOURCES) |
29 | LISP_SOURCES = | |
58a95090 | 30 | SYSDEFS = |
97a9a385 MW |
31 | |
32 | ###-------------------------------------------------------------------------- | |
33 | ### The source files. | |
34 | ||
97a9a385 | 35 | ## The package definition file. |
6b5bf01a | 36 | LISP_SOURCES += package.lisp |
97a9a385 MW |
37 | |
38 | ## General utilities. | |
6b5bf01a | 39 | LISP_SOURCES += utilities.lisp |
97a9a385 MW |
40 | |
41 | ## The parser library. | |
6b5bf01a MW |
42 | LISP_SOURCES += parser/package.lisp |
43 | LISP_SOURCES += parser/floc-proto.lisp parser/floc-impl.lisp | |
44 | LISP_SOURCES += parser/streams-proto.lisp parser/streams-impl.lisp | |
45 | LISP_SOURCES += parser/scanner-proto.lisp parser/scanner-impl.lisp | |
46 | LISP_SOURCES += parser/scanner-charbuf-impl.lisp | |
47 | LISP_SOURCES += parser/scanner-token-impl.lisp | |
48 | LISP_SOURCES += parser/parser-proto.lisp parser/parser-impl.lisp | |
49 | LISP_SOURCES += parser/parser-expr-proto.lisp \ | |
97a9a385 | 50 | parser/parser-expr-impl.lisp |
6b5bf01a | 51 | LISP_SOURCES += parser/scanner-context-impl.lisp |
97a9a385 MW |
52 | |
53 | ## Lexical analysis and translator-specific parser utilities. | |
6b5bf01a MW |
54 | LISP_SOURCES += lexer-proto.lisp lexer-impl.lisp |
55 | LISP_SOURCES += fragment-parse.lisp | |
97a9a385 MW |
56 | |
57 | ## C type representation. | |
6b5bf01a | 58 | LISP_SOURCES += c-types-proto.lisp c-types-impl.lisp \ |
97a9a385 MW |
59 | c-types-parse.lisp |
60 | ||
61 | ## Property sets. | |
6b5bf01a | 62 | LISP_SOURCES += pset-proto.lisp pset-impl.lisp pset-parse.lisp |
97a9a385 MW |
63 | |
64 | ## Code generation. | |
6b5bf01a | 65 | LISP_SOURCES += codegen-proto.lisp codegen-impl.lisp |
97a9a385 MW |
66 | |
67 | ## Output machinery. | |
6b5bf01a | 68 | LISP_SOURCES += output-proto.lisp output-impl.lisp |
97a9a385 MW |
69 | |
70 | ## Modules. | |
6b5bf01a MW |
71 | LISP_SOURCES += module-proto.lisp module-impl.lisp |
72 | LISP_SOURCES += module-parse.lisp module-output.lisp | |
73 | LISP_SOURCES += builtin.lisp | |
97a9a385 MW |
74 | |
75 | ## Class representation and layout. | |
6b5bf01a MW |
76 | LISP_SOURCES += classes.lisp c-types-class-impl.lisp |
77 | LISP_SOURCES += class-utilities.lisp | |
78 | LISP_SOURCES += class-make-proto.lisp class-make-impl.lisp | |
79 | LISP_SOURCES += class-layout-proto.lisp class-layout-impl.lisp | |
80 | LISP_SOURCES += class-finalize-proto.lisp class-finalize-impl.lisp | |
81 | LISP_SOURCES += class-output.lisp | |
97a9a385 MW |
82 | |
83 | ## Method generation. | |
6b5bf01a MW |
84 | LISP_SOURCES += method-proto.lisp method-impl.lisp |
85 | LISP_SOURCES += method-aggregate.lisp | |
97a9a385 MW |
86 | |
87 | ## User interface. | |
6b5bf01a | 88 | LISP_SOURCES += frontend.lisp optparse.lisp |
97a9a385 | 89 | |
a9cffac1 MW |
90 | ## Finishing touches. |
91 | LISP_SOURCES += final.lisp | |
e33ea301 | 92 | |
97a9a385 MW |
93 | ###-------------------------------------------------------------------------- |
94 | ### Constructing an output image. | |
95 | ||
5e6bcea3 | 96 | CLEANFILES += *.$(fasl) parser/*.$(fasl) |
97a9a385 | 97 | |
58a95090 MW |
98 | ## Autodetected configuration. |
99 | EXTRA_DIST += auto.lisp.in | |
100 | CLEANFILES += auto.lisp | |
101 | auto.lisp: auto.lisp.in Makefile | |
102 | $(SUBST) $(srcdir)/auto.lisp.in >$@.new $(SUBSTITUTIONS) && \ | |
103 | grep '^[^;]' $@.new >$@.strip && \ | |
104 | rm -f $@.new && mv $@.strip $@ | |
105 | ||
106 | ## Building a working-tree system definition. | |
107 | EXTRA_DIST += sod.asd.in | |
108 | CLEANFILES += sod.asd | |
109 | sod.asd: sod.asd.in Makefile | |
110 | $(SUBST) $(srcdir)/sod.asd.in >$@.new $(SUBSTITUTIONS) && \ | |
111 | mv $@.new $@ | |
112 | ||
113 | EXTRA_DIST += sod-frontend.asd.in | |
114 | CLEANFILES += sod-frontend.asd | |
115 | sod-frontend.asd: sod-frontend.asd.in Makefile | |
116 | $(SUBST) $(srcdir)/sod-frontend.asd.in >$@.new $(SUBSTITUTIONS) && \ | |
117 | mv $@.new $@ | |
118 | ||
b5d086c2 | 119 | ## Building the executable image. |
97a9a385 MW |
120 | bin_PROGRAMS += sod |
121 | sod_SOURCES = | |
58a95090 MW |
122 | sod: $(LISP_SOURCES) sod.asd sod-frontend.asd auto.lisp |
123 | $(V_DUMP)$(CL_LAUNCH) -o sod -d ! -l $(LISPSYS) +I \ | |
97a9a385 MW |
124 | -s sod-frontend -r sod-frontend:main |
125 | ||
126 | ###-------------------------------------------------------------------------- | |
5e6bcea3 MW |
127 | ### Unit testing. |
128 | ||
129 | ## The system definition. | |
58a95090 | 130 | EXTRA_DIST += sod-test.asd.in |
5e6bcea3 MW |
131 | |
132 | ## Basic utilities. | |
133 | EXTRA_DIST += test-base.lisp | |
134 | ||
135 | ## Parser tests. | |
136 | EXTRA_DIST += parser/parser-test.lisp | |
137 | EXTRA_DIST += parser/scanner-charbuf-test.lisp | |
138 | ||
139 | ## Translator tests. | |
140 | EXTRA_DIST += c-types-test.lisp | |
141 | EXTRA_DIST += codegen-test.lisp | |
142 | EXTRA_DIST += lexer-test.lisp | |
143 | ||
58a95090 MW |
144 | ## The system definition. |
145 | EXTRA_DIST += sod-test.asd.in | |
146 | CLEANFILES += sod-test.asd | |
147 | sod-test.asd: sod-test.asd.in Makefile | |
148 | $(SUBST) $(srcdir)/sod-test.asd.in >$@.new $(SUBSTITUTIONS) && \ | |
149 | mv $@.new $@ | |
150 | ||
5e6bcea3 | 151 | ## Running the Lisp tests. |
58a95090 MW |
152 | check-local: sod sod-test.asd |
153 | $(V_TEST)$(CL_LAUNCH) -l $(LISPSYS) -s sod-test +I \ | |
154 | -i '(handler-case (asdf:test-system "sod") ;\ | |
1d7528b6 MW |
155 | (error (cond) ;\ |
156 | (format *error-output* "ERR: ~A~%" cond) ;\ | |
157 | (cl-launch:quit 1)))' | |
5e6bcea3 MW |
158 | |
159 | ###-------------------------------------------------------------------------- | |
97a9a385 MW |
160 | ### Installation. |
161 | ||
162 | ## We want a symlink $(lispsysdir)/sod.asd -> $(lispsrcdir)/sod/sod.asd. It | |
163 | ## would be nice if this were a sane relative symlink, but that involves | |
164 | ## calculating the proper relative path from $(lispsrcdir)/sod to | |
165 | ## $(lispsysdir). Oh, well, here we go. This assumes that the path names | |
166 | ## don't have spaces in them; but that's generally a bad idea in Makefiles | |
167 | ## anyway. | |
168 | install-data-local: | |
58a95090 | 169 | $(MKDIR_P) $(DESTDIR)$(lispsysdir) $(DESTDIR)$(pkglispsrcdir) |
97a9a385 | 170 | @set -e; \ |
58a95090 | 171 | from=$(lispsysdir) to=$(pkglispsrcdir); \ |
97a9a385 MW |
172 | set -- $$(echo $$from | tr "/" " "); fwd=$$*; \ |
173 | set -- $$(echo $$to | tr "/" " "); twd=$$*; \ | |
174 | while :; do \ | |
175 | set -- $$fwd; fhd=$$1 fn=$$#; \ | |
176 | set -- $$twd; thd=$$1 tn=$$#; \ | |
177 | case :$$fn:$$tn: in *:0:*) break ;; esac; \ | |
178 | case "$$fhd" in "$$thd") ;; *) break ;; esac; \ | |
179 | set -- $$fwd; shift; fwd=$$*; \ | |
180 | set -- $$twd; shift; twd=$$*; \ | |
181 | done; \ | |
182 | dots=$$(echo $$fwd | sed 's/[^ ][^ ]*/../g'); \ | |
183 | rel=$$(echo $$dots $$twd | tr " " "/"); \ | |
58a95090 MW |
184 | for i in sod.asd sod-frontend.asd; do \ |
185 | echo >&2 "CREATE $$to/$$i"; \ | |
186 | sed -e '/#|@-auto-@|#/ { r auto.lisp' -e ' d; }' \ | |
187 | -e '/#|@-path-@|#/ d' \ | |
188 | $(srcdir)/$$i.in >$(DESTDIR)$(pkglispsrcdir)/$$i.new; \ | |
189 | mv $(DESTDIR)$(pkglispsrcdir)/$$i.new \ | |
190 | $(DESTDIR)$(pkglispsrcdir)/$$i; \ | |
191 | echo >&2 "LINK $$rel/$$i $$to/$$i"; \ | |
192 | ln -s $$rel/$$i $(DESTDIR)$$from/$$i.new; \ | |
193 | mv $(DESTDIR)$$from/$$i.new $(DESTDIR)$$from/$$i; \ | |
194 | done | |
195 | ||
196 | uninstall-local: | |
197 | for i in sod.asd sod-frontend.asd; do \ | |
198 | rm -f $(DESTDIR)$(pkglispsrcdir)/$$i $(DESTDIR)$(lispsysdir)/$$i; \ | |
199 | done | |
97a9a385 MW |
200 | |
201 | ###----- That's all, folks -------------------------------------------------- |