From d96a1fa869072053d943badb6e3904a7d7a2d4de Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 4 Nov 2009 12:29:52 -0800 Subject: Got build to work in separate build directory. --- ChangeLog | 15 +++++++++++++++ Makefile | 17 +++++++++++------ configure | 4 ++++ dep.mk | 19 ++++++++++--------- depend.txr | 8 +++++++- 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4710cc7f..ed7530bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-10-22 Kaz Kylheku + + 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 Build configuration via configure script, with cross compiling support. 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) -- cgit v1.2.3