From c2eb4dc313104e4917ee7e1c7d783cb27404b91c Mon Sep 17 00:00:00 2001 From: thurston Date: Fri, 2 Feb 2007 18:34:52 +0000 Subject: [PATCH] The common code is now a library (no more #include "common.cpp"). Improvements to the recurisve calls to make. Now using phony targets instead of shell script code which iterates over a list of items. git-svn-id: http://svn.complang.org/ragel/trunk@58 052ea7fc-9027-0410-9066-f65837a77df0 --- Makefile.in | 56 ++++++++++++++++++++++++++++++++++++--------------- common/Makefile.in | 35 +++++++++++++++++++++++++++++--- common/common.cpp | 3 ++- javagen/Makefile.in | 7 +------ ragel/Makefile.in | 11 +++++----- ragel/main.cpp | 3 +-- redfsm/Makefile.in | 3 +++ rlcodegen/Makefile.in | 14 ++++--------- rlcodegen/main.cpp | 4 +--- 9 files changed, 90 insertions(+), 46 deletions(-) diff --git a/Makefile.in b/Makefile.in index b51f6e0..6f18e87 100644 --- a/Makefile.in +++ b/Makefile.in @@ -18,7 +18,9 @@ # along with Ragel; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -SUBDIRS = common ragel rlcodegen javagen test examples doc + +BUILD_SUBDIRS = common ragel redfsm rlcodegen javagen +ALL_SUBDIRS = $(BUILD_SUBDIRS) test examples doc #************************************* @@ -28,30 +30,52 @@ CXX = @CXX@ # Get the version info. include version.mk -# Rules. -all: - @cd common && $(MAKE) && cd ../ragel && $(MAKE) && \ - cd ../rlcodegen && $(MAKE) && cd ../javagen && $(MAKE) +# build targets +all: $(BUILD_SUBDIRS) + +.PHONY: $(BUILD_SUBDIRS) + +$(BUILD_SUBDIRS): + @cd $@ && $(MAKE) + +# new version new-version: sed 's/^\(Version:[[:space:]]*\)[0-9.]*$$/\1$(VERSION)/' ragel.spec > spec-new cat spec-new > ragel.spec && rm spec-new -distclean: distclean-rec distclean-local +# clean targets. -distclean-rec: - for dir in $(SUBDIRS); do cd $$dir; $(MAKE) distclean; cd ..; done +CLEAN_SUBDIRS = $(ALL_SUBDIRS:%=%-clean) + +.PHONY: $(CLEAN_SUBDIRS) + +$(CLEAN_SUBDIRS): + cd $(@:%-clean=%) && $(MAKE) clean + +clean: $(CLEAN_SUBDIRS) + rm -f tags -distclean-local: clean-local +# distcleaan targets + +DISTCLEAN_SUBDIRS = $(ALL_SUBDIRS:%=%-distclean) + +.PHONY: $(DISTCLEAN_SUBDIRS) + +$(DISTCLEAN_SUBDIRS): + cd $(@:%-distclean=%) && $(MAKE) clean + +distclean: $(DISTCLEAN_SUBDIRS) rm -f Makefile config.cache config.status config.log -clean: clean-rec clean-local +#install targets -clean-rec: - for dir in $(SUBDIRS); do cd $$dir; $(MAKE) clean; cd ..; done +INSTALL_SUBDIRS = $(BUILD_SUBDIRS:%=%-install) -clean-local: - rm -f tags +.PHONY: $(INSTALL_SUBDIRS) + +$(INSTALL_SUBDIRS): + cd $(@:%-install=%) && $(MAKE) install + +install: $(INSTALL_SUBDIRS) -install: - @cd ragel && $(MAKE) install && cd ../rlcodegen && $(MAKE) install diff --git a/common/Makefile.in b/common/Makefile.in index 7c1ba7d..47dc356 100644 --- a/common/Makefile.in +++ b/common/Makefile.in @@ -18,21 +18,50 @@ # along with Ragel; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +INCS += +DEFS += + +CFLAGS += -g -Wall +LDFLAGS += + +CC_SRCS = common.cpp + GEN_SRC = version.h #************************************* +# Programs +CXX = @CXX@ + +# Get objects and dependencies from sources. +OBJS = $(CC_SRCS:%.cpp=%.o) +DEPS = $(CC_SRCS:%.cpp=.%.d) + +# Get the version info. include ../version.mk -# Rules. -all: $(GEN_SRC) +# rules + +all: common.a + +common.a: $(GEN_SRC) $(OBJS) + ar -cr $@ $(OBJS) version.h: ../version.mk echo '#define VERSION "$(VERSION)"' > version.h echo '#define PUBDATE "$(PUBDATE)"' >> version.h +%.o: %.cpp + @$(CXX) -M $(DEFS) $(INCS) $< > .$*.d + $(CXX) -c $(CFLAGS) $(DEFS) $(INCS) -o $@ $< + distclean: clean rm -f Makefile config.h clean: - rm -f tags version.h + rm -f tags version.h .*.d *.o common.a + +install: + @true + +-include $(DEPS) diff --git a/common/common.cpp b/common/common.cpp index db23235..60c49ff 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006 Adrian Thurston + * Copyright 2006-2007 Adrian Thurston */ /* This file is part of Ragel. @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pcheck.h" #include "common.h" HostType hostTypesC[] = diff --git a/javagen/Makefile.in b/javagen/Makefile.in index ca92848..9c0e91c 100644 --- a/javagen/Makefile.in +++ b/javagen/Makefile.in @@ -44,16 +44,11 @@ DEPS = $(CC_SRCS:%.cpp=.%.d) include ../version.mk # Rules. -all: redfsm rlcodegen-java +all: rlcodegen-java rlcodegen-java: $(REDFSM) $(OBJS) $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(REDFSM) $(LIBS) -.PHONY: redfsm - -redfsm: - @cd ../redfsm && $(MAKE) - %.o: %.cpp @$(CXX) -M $(DEFS) $(INCS) $< > .$*.d $(CXX) -c $(CFLAGS) $(DEFS) $(INCS) -o $@ $< diff --git a/ragel/Makefile.in b/ragel/Makefile.in index 9b252a7..5a96b98 100644 --- a/ragel/Makefile.in +++ b/ragel/Makefile.in @@ -1,5 +1,5 @@ # -# Copyright 2001-2006 Adrian Thurston +# Copyright 2001-2007 Adrian Thurston # # This file is part of Ragel. @@ -31,13 +31,14 @@ CC_SRCS = \ GEN_SRC = rlscan.cpp rlparse.h rlparse.cpp -LIBS += @LIBS@ +LIBS = ../common/common.a + +#************************************* + PREFIX = @prefix@ BUILD_PARSERS = @BUILD_PARSERS@ -#************************************* - # Programs CXX = @CXX@ @@ -48,7 +49,7 @@ DEPS = $(CC_SRCS:%.cpp=.%.d) # Rules. all: ragel -ragel: $(GEN_SRC) $(OBJS) +ragel: $(GEN_SRC) $(OBJS) $(LIBS) $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ifeq ($(BUILD_PARSERS),true) diff --git a/ragel/main.cpp b/ragel/main.cpp index 7a124f9..29f28ca 100644 --- a/ragel/main.cpp +++ b/ragel/main.cpp @@ -34,8 +34,7 @@ #include "pcheck.h" #include "vector.h" #include "version.h" - -#include "common.cpp" +#include "common.h" using std::istream; using std::ostream; diff --git a/redfsm/Makefile.in b/redfsm/Makefile.in index f086338..46971e3 100644 --- a/redfsm/Makefile.in +++ b/redfsm/Makefile.in @@ -78,4 +78,7 @@ endif clean: rm -f tags .*.d *.o rlcodegen $(EXTRA_CLEAN) +install: + @true + -include $(DEPS) diff --git a/rlcodegen/Makefile.in b/rlcodegen/Makefile.in index c263da9..bb47c18 100644 --- a/rlcodegen/Makefile.in +++ b/rlcodegen/Makefile.in @@ -31,9 +31,8 @@ CC_SRCS = main.cpp gvdotgen.cpp fsmcodegen.cpp \ GEN_SRC = xmltags.cpp xmlscan.cpp xmlparse.cpp xmlparse.h -REDFSM = ../redfsm/redfsm.a +LIBS = ../common/common.a ../redfsm/redfsm.a -LIBS += @LIBS@ PREFIX += @prefix@ #************************************* @@ -49,15 +48,10 @@ DEPS = $(CC_SRCS:%.cpp=.%.d) include ../version.mk # Rules. -all: redfsm rlcodegen +all: rlcodegen -rlcodegen: $(REDFSM) $(OBJS) - $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(REDFSM) $(LIBS) - -.PHONY: redfsm - -redfsm: - @cd ../redfsm && $(MAKE) +rlcodegen: $(LIBS) $(OBJS) + $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) %.o: %.cpp @$(CXX) -M $(DEFS) $(INCS) $< > .$*.d diff --git a/rlcodegen/main.cpp b/rlcodegen/main.cpp index 7977728..8924389 100644 --- a/rlcodegen/main.cpp +++ b/rlcodegen/main.cpp @@ -26,7 +26,7 @@ #include #include -#include "rlcodegen.h" +#include "common.h" #include "rlcodegen.h" #include "xmlparse.h" #include "pcheck.h" @@ -45,8 +45,6 @@ #include "gvdotgen.h" -#include "common.h" -#include "common.cpp" using std::istream; using std::ifstream; -- 2.7.4