From: Mark Wooding Date: Wed, 19 Aug 2015 01:17:36 +0000 (+0100) Subject: Introduce a proper build system and clear away old cruft. X-Git-Tag: 0.2.0~70 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/97a9a385a376202d0859ff8191858d13ec8901c2 Introduce a proper build system and clear away old cruft. --- diff --git a/.gitignore b/.gitignore index 9fa0c7e..1abd9a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ -*~ *.fasl *.pdf *.out *.log *.dvi *.aux +Makefile.in +/COPYING +/COPYING.LIB +/aclocal.m4 +/autom4te.cache/ +/config/ +/configure diff --git a/.links b/.links new file mode 100644 index 0000000..c7a181f --- /dev/null +++ b/.links @@ -0,0 +1,3 @@ +COPYING +COPYING.LIB +config/auto-version diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..4e1b7d5 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,37 @@ +### -*-makefile-*- +### +### Build script for SOD +### +### (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. + +SUBDIRS = + +###-------------------------------------------------------------------------- +### Subdirectories to build + +## The SOD translator. +SUBDIRS += src + +## The runtime support library. +SUBDIRS += lib + +###----- That's all, folks -------------------------------------------------- diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..361421f --- /dev/null +++ b/configure.ac @@ -0,0 +1,85 @@ +dnl -*-autoconf-*- +dnl +dnl Configuration script for SOD +dnl +dnl (c) 2015 Straylight/Edgeware +dnl + +dnl----- Licensing notice --------------------------------------------------- +dnl +dnl This file is part of the Sensble Object Design, an object system for C. +dnl +dnl SOD is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl SOD is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with SOD; if not, write to the Free Software Foundation, +dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +dnl-------------------------------------------------------------------------- +dnl Initialization. + +mdw_AUTO_VERSION +AC_INIT([sod], AUTO_VERSION, [mdw@distorted.org.uk]) +AC_CONFIG_SRCDIR([lib/sod.h]) +AC_CONFIG_AUX_DIR([config]) +AM_INIT_AUTOMAKE([foreign]) +mdw_SILENT_RULES + +AC_PROG_CC +AM_PROG_LIBTOOL +AX_CFLAGS_WARN_ALL +mdw_LIBTOOL_VERSION_INFO + +dnl-------------------------------------------------------------------------- +dnl Common Lisp things. + +AC_ARG_WITH([lisp-system], + [AS_HELP_STRING([--with-lisp-system=SYSTEMS], + [preference order of cl-launch Lisp systems])], + [], [with_lisp_system="sbcl clisp"]) + +AC_CHECK_PROGS([CL_LAUNCH], [cl-launch], [not-found]) +case "$CL_LAUNCH" in + not-found) AC_MSG_ERROR([\`cl-launch' not found]) ;; +esac + +AC_MSG_CHECKING([for best choice of Lisp system]) +if ! LISPSYS=$($CL_LAUNCH -l "$with_lisp_system" \ + -ip '(string-downcase (lisp-implementation-type))'); then + AC_MSG_ERROR([cl-launch didn't like any Lisp system]) +fi +AC_SUBST([LISPSYS]) +AC_MSG_RESULT([$LISPSYS]) + +AC_MSG_CHECKING([FASL file extension]) +FASL_TYPE=$($CL_LAUNCH -l $LISPSYS -ip \ + '(pathname-type (compile-file-pathname "foo.lisp"))') +AC_SUBST([FASL_TYPE]) +AC_MSG_RESULT([.$FASL_TYPE]) + +AC_ARG_WITH([lisp-source-dir], + [AS_HELP_STRING([--with-lisp-source-dir=DIR], + [where to install Common Lisp source files])], + [], [with_lisp_source_dir='${datadir}/common-lisp/source']) +AC_ARG_WITH([lisp-system-dir], + [AS_HELP_STRING([--with-lisp-system-dir=DIR], + [where to install ASDF system links])], + [], [with_lisp_system_dir='${datadir}/common-lisp/systems']) +AC_SUBST([lispsrcdir], [$with_lisp_source_dir]) +AC_SUBST([lispsysdir], [$with_lisp_system_dir]) + +dnl-------------------------------------------------------------------------- +dnl Output. + +AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile]) +AC_OUTPUT + +dnl----- That's all, folks -------------------------------------------------- diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 0000000..6b21e4b --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1,58 @@ +### -*-makefile-*- +### +### Build script for SOD runtime library +### +### (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. + +lib_LTLIBRARIES = libsod.la +libsod_la_LDFLAGS = -version-info $(LIBTOOL_VERSION_INFO) + +libsod_la_SOURCES = +include_HEADERS = + +nodist_libsod_la_SOURCES = +nodist_include_HEADERS = + +SOD = $(top_builddir)/src/sod + +BUILT_SOURCES = + +###-------------------------------------------------------------------------- +### The source files. + +libsod_la_SOURCES += sod.c +include_HEADERS += sod.h + +###-------------------------------------------------------------------------- +### Generated builtin module. + +BUILT_SOURCES += sod-base.c sod-base.h +nodist_libsod_la_SOURCES+= sod-base.c +nodist_include_HEADERS += sod-base.h + +sod-base.c: $(SOD) + $(SOD) -tc --builtin + +sod-base.h: $(SOD) + $(SOD) -th --builtin + +###----- That's all, folks -------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..e71c5c0 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,136 @@ +### -*-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 -------------------------------------------------- diff --git a/src/bar.sod b/src/bar.sod deleted file mode 100644 index 0ae19d3..0000000 --- a/src/bar.sod +++ /dev/null @@ -1,5 +0,0 @@ -/* another example module */ - -demo "bar, before import"; -import "foo"; -demo "bar, after import"; diff --git a/src/dump-sod b/src/dump-sod deleted file mode 100755 index f0063c2..0000000 --- a/src/dump-sod +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -ex -cl-launch -o sod -d "$(pwd)/sod.img" -s sod +I -r sod:main "$@" diff --git a/src/foo.lisp b/src/foo.lisp deleted file mode 100644 index 4063c03..0000000 --- a/src/foo.lisp +++ /dev/null @@ -1,7 +0,0 @@ -(cl:in-package #:sod) - -(defun list-tokens (scanner) - (let ((toke (make-instance 'sod-token-scanner :char-scanner scanner))) - (loop collect (list (token-type toke) (token-value toke)) - until (scanner-at-eof-p toke) - do (scanner-step toke)))) diff --git a/src/foo.sod b/src/foo.sod deleted file mode 100644 index 049179b..0000000 --- a/src/foo.sod +++ /dev/null @@ -1,23 +0,0 @@ -/* foo */ - -code c : includes { -#include "foo.h" -} - -code h : includes { -#include "sod.h" -} - -//[link = SodObject] -class Test : SodObject { - int x = 0; - - int cur() { return me->test.x; } - void inc() { me->test.x++; } - void dec() { me->test.x--; } -} - -[nick = snd] -class Second : Test { - void test.dec() { Test *t = SECOND__CONV_TEST(me); t->test.x -= 3; } -} diff --git a/src/hacks.lisp b/src/hacks.lisp deleted file mode 100644 index 96ae996..0000000 --- a/src/hacks.lisp +++ /dev/null @@ -1,6 +0,0 @@ -(in-package #:sod) - -(defun make-lexer (string) - (make-instance 'sod-token-scanner - :char-scanner (make-string-scanner string) - :filename "")) diff --git a/src/run-sod b/src/run-sod deleted file mode 100755 index f4b6e65..0000000 --- a/src/run-sod +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/sh -":"; exec cl-launch -X -l "sbcl clisp cmucl ecl" -s asdf -- "$0" "$0" "$@" || exit 1 # -*-lisp-*- - -(handler-bind ((warning (lambda (cond) - (declare (ignore cond)) - (invoke-restart 'muffle-warning)))) - (asdf:operate 'asdf:load-op "sod")) - -(funcall (intern "MAIN" (find-package "SOD"))) diff --git a/src/scratch.lisp b/src/scratch.lisp deleted file mode 100644 index 8862ac2..0000000 --- a/src/scratch.lisp +++ /dev/null @@ -1,16 +0,0 @@ -(in-package #:sod) - -(defun try-parse* (parser string) - (call-with-module-environment - (lambda () - (let* ((char-scanner (make-string-scanner string)) - (scanner (make-instance 'sod-token-scanner - :char-scanner char-scanner))) - (funcall parser scanner))))) - -(defmacro try-parse ((scanner string) &body parser) - `(try-parse* (lambda (,scanner) - (with-parser-context - (token-scanner-context :scanner ,scanner) - ,@parser)) - ,string))