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 | ### | |
e0808c47 | 10 | ### This file is part of the Sensible Object Design, an object system for C. |
97a9a385 MW |
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 | 31 | |
dcb84c9f | 32 | ASDF_ENV = \ |
cc501d13 | 33 | CL_SOURCE_REGISTRY=$$(pwd): \ |
dcb84c9f MW |
34 | ASDF_OUTPUT_TRANSLATIONS=$$(cd $(srcdir); pwd):$(abs_builddir): |
35 | ||
97a9a385 MW |
36 | ###-------------------------------------------------------------------------- |
37 | ### The source files. | |
38 | ||
97a9a385 | 39 | ## The package definition file. |
6b5bf01a | 40 | LISP_SOURCES += package.lisp |
97a9a385 MW |
41 | |
42 | ## General utilities. | |
6b5bf01a | 43 | LISP_SOURCES += utilities.lisp |
97a9a385 MW |
44 | |
45 | ## The parser library. | |
6b5bf01a MW |
46 | LISP_SOURCES += parser/package.lisp |
47 | LISP_SOURCES += parser/floc-proto.lisp parser/floc-impl.lisp | |
48 | LISP_SOURCES += parser/streams-proto.lisp parser/streams-impl.lisp | |
49 | LISP_SOURCES += parser/scanner-proto.lisp parser/scanner-impl.lisp | |
50 | LISP_SOURCES += parser/scanner-charbuf-impl.lisp | |
51 | LISP_SOURCES += parser/scanner-token-impl.lisp | |
52 | LISP_SOURCES += parser/parser-proto.lisp parser/parser-impl.lisp | |
53 | LISP_SOURCES += parser/parser-expr-proto.lisp \ | |
97a9a385 | 54 | parser/parser-expr-impl.lisp |
6b5bf01a | 55 | LISP_SOURCES += parser/scanner-context-impl.lisp |
97a9a385 MW |
56 | |
57 | ## Lexical analysis and translator-specific parser utilities. | |
6b5bf01a MW |
58 | LISP_SOURCES += lexer-proto.lisp lexer-impl.lisp |
59 | LISP_SOURCES += fragment-parse.lisp | |
97a9a385 MW |
60 | |
61 | ## C type representation. | |
6b5bf01a | 62 | LISP_SOURCES += c-types-proto.lisp c-types-impl.lisp \ |
97a9a385 MW |
63 | c-types-parse.lisp |
64 | ||
65 | ## Property sets. | |
6b5bf01a | 66 | LISP_SOURCES += pset-proto.lisp pset-impl.lisp pset-parse.lisp |
97a9a385 MW |
67 | |
68 | ## Code generation. | |
6b5bf01a | 69 | LISP_SOURCES += codegen-proto.lisp codegen-impl.lisp |
97a9a385 MW |
70 | |
71 | ## Output machinery. | |
6b5bf01a | 72 | LISP_SOURCES += output-proto.lisp output-impl.lisp |
97a9a385 MW |
73 | |
74 | ## Modules. | |
6b5bf01a MW |
75 | LISP_SOURCES += module-proto.lisp module-impl.lisp |
76 | LISP_SOURCES += module-parse.lisp module-output.lisp | |
77 | LISP_SOURCES += builtin.lisp | |
97a9a385 MW |
78 | |
79 | ## Class representation and layout. | |
6b5bf01a MW |
80 | LISP_SOURCES += classes.lisp c-types-class-impl.lisp |
81 | LISP_SOURCES += class-utilities.lisp | |
82 | LISP_SOURCES += class-make-proto.lisp class-make-impl.lisp | |
83 | LISP_SOURCES += class-layout-proto.lisp class-layout-impl.lisp | |
84 | LISP_SOURCES += class-finalize-proto.lisp class-finalize-impl.lisp | |
85 | LISP_SOURCES += class-output.lisp | |
97a9a385 MW |
86 | |
87 | ## Method generation. | |
6b5bf01a MW |
88 | LISP_SOURCES += method-proto.lisp method-impl.lisp |
89 | LISP_SOURCES += method-aggregate.lisp | |
97a9a385 MW |
90 | |
91 | ## User interface. | |
6b5bf01a | 92 | LISP_SOURCES += frontend.lisp optparse.lisp |
97a9a385 | 93 | |
a9cffac1 MW |
94 | ## Finishing touches. |
95 | LISP_SOURCES += final.lisp | |
e33ea301 | 96 | |
97a9a385 MW |
97 | ###-------------------------------------------------------------------------- |
98 | ### Constructing an output image. | |
99 | ||
5e6bcea3 | 100 | CLEANFILES += *.$(fasl) parser/*.$(fasl) |
97a9a385 | 101 | |
58a95090 MW |
102 | ## Autodetected configuration. |
103 | EXTRA_DIST += auto.lisp.in | |
104 | CLEANFILES += auto.lisp | |
105 | auto.lisp: auto.lisp.in Makefile | |
106 | $(SUBST) $(srcdir)/auto.lisp.in >$@.new $(SUBSTITUTIONS) && \ | |
107 | grep '^[^;]' $@.new >$@.strip && \ | |
108 | rm -f $@.new && mv $@.strip $@ | |
109 | ||
110 | ## Building a working-tree system definition. | |
111 | EXTRA_DIST += sod.asd.in | |
112 | CLEANFILES += sod.asd | |
113 | sod.asd: sod.asd.in Makefile | |
114 | $(SUBST) $(srcdir)/sod.asd.in >$@.new $(SUBSTITUTIONS) && \ | |
115 | mv $@.new $@ | |
116 | ||
117 | EXTRA_DIST += sod-frontend.asd.in | |
118 | CLEANFILES += sod-frontend.asd | |
119 | sod-frontend.asd: sod-frontend.asd.in Makefile | |
120 | $(SUBST) $(srcdir)/sod-frontend.asd.in >$@.new $(SUBSTITUTIONS) && \ | |
121 | mv $@.new $@ | |
122 | ||
b5d086c2 | 123 | ## Building the executable image. |
97a9a385 MW |
124 | bin_PROGRAMS += sod |
125 | sod_SOURCES = | |
9bd7c3e9 MW |
126 | sod$(EXEEXT): $(LISP_SOURCES) sod.asd sod-frontend.asd auto.lisp |
127 | $(V_DUMP)$(ASDF_ENV) $(CL_LAUNCH) -o $@ -d ! -l $(LISPSYS) +I \ | |
97a9a385 MW |
128 | -s sod-frontend -r sod-frontend:main |
129 | ||
8698accb MW |
130 | ## The executable is needed if we're just distributing. |
131 | dist-hook: sod$(EXEEXT) | |
132 | ||
97a9a385 | 133 | ###-------------------------------------------------------------------------- |
5e6bcea3 MW |
134 | ### Unit testing. |
135 | ||
136 | ## The system definition. | |
58a95090 | 137 | EXTRA_DIST += sod-test.asd.in |
5e6bcea3 MW |
138 | |
139 | ## Basic utilities. | |
140 | EXTRA_DIST += test-base.lisp | |
141 | ||
142 | ## Parser tests. | |
143 | EXTRA_DIST += parser/parser-test.lisp | |
144 | EXTRA_DIST += parser/scanner-charbuf-test.lisp | |
145 | ||
146 | ## Translator tests. | |
147 | EXTRA_DIST += c-types-test.lisp | |
148 | EXTRA_DIST += codegen-test.lisp | |
149 | EXTRA_DIST += lexer-test.lisp | |
150 | ||
58a95090 MW |
151 | ## The system definition. |
152 | EXTRA_DIST += sod-test.asd.in | |
153 | CLEANFILES += sod-test.asd | |
154 | sod-test.asd: sod-test.asd.in Makefile | |
155 | $(SUBST) $(srcdir)/sod-test.asd.in >$@.new $(SUBSTITUTIONS) && \ | |
156 | mv $@.new $@ | |
157 | ||
5e6bcea3 | 158 | ## Running the Lisp tests. |
58a95090 | 159 | check-local: sod sod-test.asd |
6e21a5d2 MW |
160 | $(V_TEST)$(ASDF_ENV) $(CL_LAUNCH) -l $(LISPSYS) \ |
161 | -s sod-frontend +I \ | |
162 | -i '(handler-case ;\ | |
163 | (progn ;\ | |
164 | (asdf:load-system "sod-test") ;\ | |
165 | (asdf:test-system "sod")) ;\ | |
1d7528b6 MW |
166 | (error (cond) ;\ |
167 | (format *error-output* "ERR: ~A~%" cond) ;\ | |
6e21a5d2 | 168 | (optparse:exit 1)))' |
5e6bcea3 MW |
169 | |
170 | ###-------------------------------------------------------------------------- | |
9ed8eb2a MW |
171 | ### Manual pages. |
172 | ||
6bed6ea3 MW |
173 | man_MANS += sod.1 sod-module.5 |
174 | CLEANFILES += sod.1 sod-module.5 | |
175 | EXTRA_DIST += sod.1.in sod-module.5.in | |
9ed8eb2a MW |
176 | |
177 | ###-------------------------------------------------------------------------- | |
97a9a385 MW |
178 | ### Installation. |
179 | ||
180 | ## We want a symlink $(lispsysdir)/sod.asd -> $(lispsrcdir)/sod/sod.asd. It | |
181 | ## would be nice if this were a sane relative symlink, but that involves | |
182 | ## calculating the proper relative path from $(lispsrcdir)/sod to | |
183 | ## $(lispsysdir). Oh, well, here we go. This assumes that the path names | |
184 | ## don't have spaces in them; but that's generally a bad idea in Makefiles | |
185 | ## anyway. | |
186 | install-data-local: | |
58a95090 | 187 | $(MKDIR_P) $(DESTDIR)$(lispsysdir) $(DESTDIR)$(pkglispsrcdir) |
97a9a385 | 188 | @set -e; \ |
58a95090 | 189 | from=$(lispsysdir) to=$(pkglispsrcdir); \ |
97a9a385 MW |
190 | set -- $$(echo $$from | tr "/" " "); fwd=$$*; \ |
191 | set -- $$(echo $$to | tr "/" " "); twd=$$*; \ | |
192 | while :; do \ | |
193 | set -- $$fwd; fhd=$$1 fn=$$#; \ | |
194 | set -- $$twd; thd=$$1 tn=$$#; \ | |
195 | case :$$fn:$$tn: in *:0:*) break ;; esac; \ | |
196 | case "$$fhd" in "$$thd") ;; *) break ;; esac; \ | |
197 | set -- $$fwd; shift; fwd=$$*; \ | |
198 | set -- $$twd; shift; twd=$$*; \ | |
199 | done; \ | |
200 | dots=$$(echo $$fwd | sed 's/[^ ][^ ]*/../g'); \ | |
201 | rel=$$(echo $$dots $$twd | tr " " "/"); \ | |
58a95090 MW |
202 | for i in sod.asd sod-frontend.asd; do \ |
203 | echo >&2 "CREATE $$to/$$i"; \ | |
204 | sed -e '/#|@-auto-@|#/ { r auto.lisp' -e ' d; }' \ | |
205 | -e '/#|@-path-@|#/ d' \ | |
206 | $(srcdir)/$$i.in >$(DESTDIR)$(pkglispsrcdir)/$$i.new; \ | |
207 | mv $(DESTDIR)$(pkglispsrcdir)/$$i.new \ | |
208 | $(DESTDIR)$(pkglispsrcdir)/$$i; \ | |
209 | echo >&2 "LINK $$rel/$$i $$to/$$i"; \ | |
210 | ln -s $$rel/$$i $(DESTDIR)$$from/$$i.new; \ | |
211 | mv $(DESTDIR)$$from/$$i.new $(DESTDIR)$$from/$$i; \ | |
212 | done | |
213 | ||
214 | uninstall-local: | |
215 | for i in sod.asd sod-frontend.asd; do \ | |
216 | rm -f $(DESTDIR)$(pkglispsrcdir)/$$i $(DESTDIR)$(lispsysdir)/$$i; \ | |
217 | done | |
97a9a385 | 218 | |
88005ae9 MW |
219 | ###-------------------------------------------------------------------------- |
220 | ### Additional random things useful during development. | |
221 | ||
222 | ## ASDF hacking for finding the system definitions. | |
223 | EXTRA_DIST += asdf-hack.lisp.in | |
224 | noinst_DATA += asdf-hack.lisp | |
225 | asdf-hack.lisp: asdf-hack.lisp.in Makefile | |
226 | $(SUBST) $(srcdir)/asdf-hack.lisp.in >$@.new $(SUBSTITUTIONS) && \ | |
227 | mv $@.new $@ | |
4aa2092a | 228 | CLEANFILES += asdf-hack.lisp |
88005ae9 MW |
229 | |
230 | ## Emacs hacking for indentation. | |
231 | EXTRA_DIST += emacs-hacks.el | |
232 | ||
97a9a385 | 233 | ###----- That's all, folks -------------------------------------------------- |