summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2019-10-15 17:49:25 -0300
committerAdrian Thurston <thurston@colm.net>2019-10-15 18:01:10 -0300
commit49ad3f194f4b188abc663c83b05ba7908b773afa (patch)
tree7ffea2eaabe9ba9bc8c368609b52ca5f7e07c41f
parentb017550ee702067d43c9b20a22ec75997e270d25 (diff)
downloadcolm-49ad3f194f4b188abc663c83b05ba7908b773afa.tar.gz
added --with-colm option for building colm parser with an external colm
By default the package will bootstrap, but when working on the parser it is possible to break building of colm itself. This is a major nuisance, so allow building with an external colm, skipping the bootstrap process.
-rw-r--r--colm/Makefile.am42
-rw-r--r--colm/prog.lm13
-rw-r--r--configure.ac16
3 files changed, 54 insertions, 17 deletions
diff --git a/colm/Makefile.am b/colm/Makefile.am
index e1e758fd..cce19986 100644
--- a/colm/Makefile.am
+++ b/colm/Makefile.am
@@ -25,7 +25,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/aapl -Iinclude
AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = colm
-noinst_PROGRAMS = bootstrap0 bootstrap1
RUNTIME_SRC = \
map.c pdarun.c list.c input.c stream.c debug.c \
@@ -38,7 +37,6 @@ RUNTIME_HDR = \
pdarun.h map.h type.h tree.h struct.h program.h colm.h internal.h
lib_LTLIBRARIES = libcolm.la
-
noinst_LIBRARIES = libprog.a
libcolm_la_SOURCES = $(RUNTIME_SRC)
@@ -69,18 +67,6 @@ libprog_a_SOURCES = \
libprog_a_CXXFLAGS = $(common_CFLAGS)
-bootstrap0_CXXFLAGS = $(common_CFLAGS) -DCONS_INIT
-bootstrap0_SOURCES = consinit.cc consinit.h main.cc
-bootstrap0_LDADD = libprog.a libcolm.la
-
-bootstrap1_CXXFLAGS = $(common_CFLAGS) -DLOAD_INIT
-bootstrap1_CFLAGS = $(common_CFLAGS)
-bootstrap1_SOURCES = \
- loadinit.h loadinit.cc main.cc
-nodist_bootstrap1_SOURCES = \
- gen/if1.h gen/if1.cc gen/parse1.c
-bootstrap1_LDADD = libprog.a libcolm.la
-
colm_CXXFLAGS = $(common_CFLAGS) -DLOAD_COLM
colm_CFLAGS = $(common_CFLAGS)
colm_SOURCES = \
@@ -93,6 +79,32 @@ colmincdir = $(includedir)/colm
colminc_HEADERS = $(RUNTIME_HDR)
+if EXTERNAL_COLM
+
+gen/parse2.c: $(EXTERNAL_COLM)/bin/colm prog.lm
+ mkdir -p gen
+ $(EXTERNAL_COLM)/bin/colm -c -o gen/parse2.c -e gen/if2.h -x gen/if2.cc prog.lm
+
+gen/if2.h: gen/parse2.c
+gen/if2.cc: gen/parse2.c
+
+gen/colm-if2.$(OBJEXT): gen/if2.h gen/if2.cc gen/parse2.c
+colm-loadcolm.$(OBJEXT): gen/if2.h gen/if2.cc gen/parse2.c
+
+else
+
+noinst_PROGRAMS = bootstrap0 bootstrap1
+
+bootstrap0_CXXFLAGS = $(common_CFLAGS) -DCONS_INIT
+bootstrap0_SOURCES = consinit.cc consinit.h main.cc
+bootstrap0_LDADD = libprog.a libcolm.la
+
+bootstrap1_CXXFLAGS = $(common_CFLAGS) -DLOAD_INIT
+bootstrap1_CFLAGS = $(common_CFLAGS)
+bootstrap1_SOURCES = loadinit.h loadinit.cc main.cc
+nodist_bootstrap1_SOURCES = gen/if1.h gen/if1.cc gen/parse1.c
+bootstrap1_LDADD = libprog.a libcolm.la
+
gen/parse1.c: bootstrap0$(EXEEXT)
mkdir -p gen
$(builddir)/bootstrap0 -c -o gen/parse1.c -e gen/if1.h -x gen/if1.cc
@@ -113,6 +125,8 @@ bootstrap1-loadinit.$(OBJEXT): gen/if1.h gen/if1.cc gen/parse1.c
gen/colm-if2.$(OBJEXT): gen/if2.h gen/if2.cc gen/parse2.c
colm-loadcolm.$(OBJEXT): gen/if2.h gen/if2.cc gen/parse2.c
+endif
+
BUILT_SOURCES = version.h include/colm
include/colm:
diff --git a/colm/prog.lm b/colm/prog.lm
new file mode 100644
index 00000000..ab201e94
--- /dev/null
+++ b/colm/prog.lm
@@ -0,0 +1,13 @@
+include 'colm.lm'
+
+export ColmTree: start
+export ColmError: str
+
+A: str = argv->pop()
+F: stream = open( A, 'r' )
+parse P: start [ F ]
+
+ColmTree = P
+ColmError = error
+
+
diff --git a/configure.ac b/configure.ac
index bbf267bd..932e3af3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -275,12 +275,22 @@ SED_SUBST="$SED_SUBST -e 's|@CRACK_BIN@|${CRACK_BIN}|g'"
AC_SUBST(CRACK_BIN)
+dnl Generic dependency specification.
+AC_ARG_WITH(colm,
+ [AC_HELP_STRING([--with-colm], [colm install to build bootstrap programs])],
+ [EXTERNAL_COLM="$withval"],
+ []
+)
-AC_SUBST(SED_SUBST)
+AM_CONDITIONAL([EXTERNAL_COLM], [test "x$EXTERNAL_COLM" != x])
+AC_SUBST(EXTERNAL_COLM)
-AC_CONFIG_HEADERS([src/config.h colm/defs.h])
+dnl
+dnl Wrap up.
+dnl
-dnl write output files
+AC_SUBST(SED_SUBST)
+AC_CONFIG_HEADERS([src/config.h colm/defs.h])
AC_OUTPUT([
Makefile
aapl/Makefile