+### -*-makefile-*-
+###
+### Build script for the SOD translator
+###
+### (c) 2015 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the Sensble Object Design, an object system for C.
+###
+### SOD is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+###
+### SOD is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with SOD; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+bin_PROGRAMS =
+
+CLEANFILES =
+
+pkglispsrcdir = $(lispsrcdir)/$(PACKAGE)
+
+dist_pkglispsrc_DATA =
+
+###--------------------------------------------------------------------------
+### The source files.
+
+## The system definition file.
+dist_pkglispsrc_DATA += sod.asd
+
+## The package definition file.
+dist_pkglispsrc_DATA += package.lisp
+
+## General utilities.
+dist_pkglispsrc_DATA += utilities.lisp
+
+## The parser library.
+dist_pkglispsrc_DATA += parser/floc-proto.lisp parser/floc-impl.lisp
+dist_pkglispsrc_DATA += parser/streams-proto.lisp parser/streams-impl.lisp
+dist_pkglispsrc_DATA += parser/scanner-proto.lisp parser/scanner-impl.lisp
+dist_pkglispsrc_DATA += parser/scanner-charbuf-impl.lisp
+dist_pkglispsrc_DATA += parser/scanner-token-impl.lisp
+dist_pkglispsrc_DATA += parser/parser-proto.lisp parser/parser-impl.lisp
+dist_pkglispsrc_DATA += parser/parser-expr-proto.lisp \
+ parser/parser-expr-impl.lisp
+dist_pkglispsrc_DATA += parser/scanner-context-impl.lisp
+
+## Lexical analysis and translator-specific parser utilities.
+dist_pkglispsrc_DATA += lexer-proto.lisp lexer-impl.lisp
+dist_pkglispsrc_DATA += fragment-parse.lisp
+
+## C type representation.
+dist_pkglispsrc_DATA += c-types-proto.lisp c-types-impl.lisp \
+ c-types-parse.lisp
+
+## Property sets.
+dist_pkglispsrc_DATA += pset-proto.lisp pset-impl.lisp pset-parse.lisp
+
+## Code generation.
+dist_pkglispsrc_DATA += codegen-proto.lisp codegen-impl.lisp
+
+## Output machinery.
+dist_pkglispsrc_DATA += output-proto.lisp output-impl.lisp
+
+## Modules.
+dist_pkglispsrc_DATA += module-proto.lisp module-impl.lisp
+dist_pkglispsrc_DATA += module-parse.lisp module-output.lisp
+dist_pkglispsrc_DATA += builtin.lisp
+
+## Class representation and layout.
+dist_pkglispsrc_DATA += classes.lisp c-types-class-impl.lisp
+dist_pkglispsrc_DATA += class-utilities.lisp
+dist_pkglispsrc_DATA += class-make-proto.lisp class-make-impl.lisp
+dist_pkglispsrc_DATA += class-layout-proto.lisp class-layout-impl.lisp
+dist_pkglispsrc_DATA += class-finalize-proto.lisp class-finalize-impl.lisp
+dist_pkglispsrc_DATA += class-output.lisp
+
+## Method generation.
+dist_pkglispsrc_DATA += method-proto.lisp method-impl.lisp
+
+## User interface.
+dist_pkglispsrc_DATA += sod-frontend.asd
+dist_pkglispsrc_DATA += frontend.lisp optparse.lisp
+
+###--------------------------------------------------------------------------
+### Constructing an output image.
+
+CLEANFILES += *.$(FASL_TYPE)
+
+bin_PROGRAMS += sod
+sod_SOURCES =
+sod: $(dist_pkglispsrc_DATA)
+ set -ex; true_srcdir=$$(cd $(srcdir); pwd); \
+ ASDF_OUTPUT_TRANSLATIONS=$$true_srcdir:$(abs_builddir): \
+ $(CL_LAUNCH) -o sod -d ! -l $(LISPSYS) +I -S $$true_srcdir/ \
+ -s sod-frontend -r sod-frontend:main
+
+###--------------------------------------------------------------------------
+### Installation.
+
+## We want a symlink $(lispsysdir)/sod.asd -> $(lispsrcdir)/sod/sod.asd. It
+## would be nice if this were a sane relative symlink, but that involves
+## calculating the proper relative path from $(lispsrcdir)/sod to
+## $(lispsysdir). Oh, well, here we go. This assumes that the path names
+## don't have spaces in them; but that's generally a bad idea in Makefiles
+## anyway.
+install-data-local:
+ $(MKDIR_P) $(DESTDIR)$(lispsysdir)
+ @set -e; \
+ from=$(lispsysdir) to=$(pkglispsrcdir)/sod.asd; \
+ set -- $$(echo $$from | tr "/" " "); fwd=$$*; \
+ set -- $$(echo $$to | tr "/" " "); twd=$$*; \
+ while :; do \
+ set -- $$fwd; fhd=$$1 fn=$$#; \
+ set -- $$twd; thd=$$1 tn=$$#; \
+ case :$$fn:$$tn: in *:0:*) break ;; esac; \
+ case "$$fhd" in "$$thd") ;; *) break ;; esac; \
+ set -- $$fwd; shift; fwd=$$*; \
+ set -- $$twd; shift; twd=$$*; \
+ done; \
+ dots=$$(echo $$fwd | sed 's/[^ ][^ ]*/../g'); \
+ rel=$$(echo $$dots $$twd | tr " " "/"); \
+ echo >&2 "ln -s $$rel $$to"; \
+ ln -s $$rel $(DESTDIR)$$from.new; \
+ mv $(DESTDIR)$$from.new $(DESTDIR)$$from
+
+###----- That's all, folks --------------------------------------------------