summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--Makefile17
-rwxr-xr-xconfigure4
-rw-r--r--dep.mk19
-rw-r--r--depend.txr8
5 files changed, 47 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 4710cc7f..ed7530bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2009-10-22 Kaz Kylheku <kkylheku@gmail.com>
+ Got build to work in separate build directory.
+
+ * Makefile (CFLAGS): Added -I flag to point header inclusion to the
+ source directory.
+ (PROG): New variable to hold program name.
+ (VPATH): Variable set, as a quick and dirty way to get GNU make
+ to find the prerequisites back in the source directory.
+ * configure: Added steps to symlink the tests directory and dep.mk.
+ * depend.txr: Modified to generate the dependencies with
+ correct references to the top_srcdir, with the exception of
+ locally generated headers.
+ * dep.mk: Regenerated.
+
+2009-10-22 Kaz Kylheku <kkylheku@gmail.com>
+
Build configuration via configure script, with cross compiling support.
(Tested by cross-compiling txr on an x86 GNU/Linux system
to run on a MIPS-based GNU/Linux system).
diff --git a/Makefile b/Makefile
index c4eac356..ffa9f2ac 100644
--- a/Makefile
+++ b/Makefile
@@ -28,12 +28,17 @@
-include config.make
-CFLAGS := $(LANG_FLAGS) $(DIAG_FLAGS) $(OPT_FLAGS) $(DBG_FLAGS)
+CFLAGS := -I$(top_srcdir) $(LANG_FLAGS) $(DIAG_FLAGS) $(OPT_FLAGS) $(DBG_FLAGS)
OBJS := txr.o lex.yy.o y.tab.o match.o lib.o regex.o gc.o unwind.o stream.o
-txr: $(OBJS)
+
+PROG := ./txr
+
+$(PROG): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LEXLIB)
+VPATH := $(top_srcdir)
+
-include dep.mk
lex.yy.c: parser.l
@@ -43,18 +48,18 @@ y.tab.c y.tab.h: parser.y
if $(YACC) -v -d $< ; then true ; else rm $@ ; false ; fi
clean:
- rm -f txr $(OBJS) \
+ rm -f $(PROG) $(OBJS) \
y.tab.c lex.yy.c y.tab.h y.output $(TESTS:.ok=.out)
distclean: clean
rm -f config.make
-depend: txr
- ./txr depend.txr > dep.mk
+depend: $(PROG)
+ $(PROG) depend.txr > dep.mk
TESTS := $(patsubst %.txr,%.ok,$(shell find tests -name '*.txr' | sort))
-tests: txr $(TESTS)
+tests: $(PROG) $(TESTS)
@echo "** tests passed!"
tests/001/%: TXR_ARGS := tests/001/data
diff --git a/configure b/configure
index c96841aa..6847c85c 100755
--- a/configure
+++ b/configure
@@ -382,6 +382,10 @@ esac
if [ "$source_dir" != "." ] ; then
printf "symlinking Makefile -> $source_dir/Makefile\n"
ln -sf "$source_dir/Makefile" .
+ printf "symlinking tests -> $source_dir/tests\n"
+ ln -sf "$source_dir/tests" .
+ printf "symlinking dep.mk -> $source_dir/dep.mk\n"
+ ln -sf "$source_dir/dep.mk" .
else
printf "warning: its recommended to build in a separate directory\n"
fi
diff --git a/dep.mk b/dep.mk
index b7b76fce..8c94e995 100644
--- a/dep.mk
+++ b/dep.mk
@@ -1,9 +1,10 @@
-lib.o: lib.h gc.h unwind.h stream.h
-lex.yy.o: y.tab.h lib.h gc.h stream.h parser.h
-regex.o: lib.h unwind.h regex.h
-y.tab.o: lib.h regex.h parser.h
-unwind.o: lib.h gc.h stream.h txr.h unwind.h
-txr.o: lib.h stream.h gc.h unwind.h parser.h match.h txr.h
-match.o: lib.h gc.h unwind.h regex.h stream.h parser.h txr.h match.h
-stream.o: lib.h gc.h unwind.h stream.h
-gc.o: lib.h stream.h txr.h gc.h
+parser.tab.o: $(top_srcdir)/lib.h $(top_srcdir)/regex.h $(top_srcdir)/parser.h
+lib.o: $(top_srcdir)/lib.h $(top_srcdir)/gc.h $(top_srcdir)/unwind.h $(top_srcdir)/stream.h
+lex.yy.o: y.tab.h $(top_srcdir)/lib.h $(top_srcdir)/gc.h $(top_srcdir)/stream.h $(top_srcdir)/parser.h
+regex.o: $(top_srcdir)/lib.h $(top_srcdir)/unwind.h $(top_srcdir)/regex.h
+y.tab.o: $(top_srcdir)/lib.h $(top_srcdir)/regex.h $(top_srcdir)/parser.h
+unwind.o: $(top_srcdir)/lib.h $(top_srcdir)/gc.h $(top_srcdir)/stream.h $(top_srcdir)/txr.h $(top_srcdir)/unwind.h
+txr.o: $(top_srcdir)/lib.h $(top_srcdir)/stream.h $(top_srcdir)/gc.h $(top_srcdir)/unwind.h $(top_srcdir)/parser.h $(top_srcdir)/match.h $(top_srcdir)/txr.h
+match.o: $(top_srcdir)/lib.h $(top_srcdir)/gc.h $(top_srcdir)/unwind.h $(top_srcdir)/regex.h $(top_srcdir)/stream.h $(top_srcdir)/parser.h $(top_srcdir)/txr.h $(top_srcdir)/match.h
+stream.o: $(top_srcdir)/lib.h $(top_srcdir)/gc.h $(top_srcdir)/unwind.h $(top_srcdir)/stream.h
+gc.o: $(top_srcdir)/lib.h $(top_srcdir)/stream.h $(top_srcdir)/txr.h $(top_srcdir)/gc.h
diff --git a/depend.txr b/depend.txr
index 7fa2183c..23feba6b 100644
--- a/depend.txr
+++ b/depend.txr
@@ -3,7 +3,13 @@
@file.c
@(next)@file.c
@(collect)
-#include "@header"
+#include "@hdr"
+@(cases)
+@(bind hdr ("y.tab.h"))
+@(bind header hdr)
+@(or)
+@(bind header `$(top_srcdir)/@hdr`)
+@(end)
@(end)
@(output)
@file.o:@(rep) @header@(end)