trunk preprocessor: simplified build system (only one Makefile now)

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2455 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
sebastien 2009-03-12 11:02:56 +00:00
parent 47a4550144
commit b502d94145
3 changed files with 81 additions and 88 deletions

View File

@ -1,16 +1,39 @@
include Makefile.include CXXFLAGS = -Wall
ifeq ($(shell uname -o), Cygwin) ifeq ($(shell uname -o), Cygwin)
DYNARE_M = dynare_m.exe # Detection of uninitialized variables is buggy in Cygwin and generates spurious warnings
else CXXFLAGS += -Wno-uninitialized
DYNARE_M = dynare_m CXXFLAGS += -mno-cygwin
endif endif
ifeq ($(CROSS_WIN32), yes) ifeq ($(CROSS_WIN32), yes)
DYNARE_M = dynare_m.exe CXX = i586-mingw32msvc-g++
AR = i586-mingw32msvc-ar
# Detection of uninitialized variables is buggy in MinGW and generates spurious warnings
CXXFLAGS += -Wno-uninitialized
endif endif
OBJS = \ ifeq ($(DEBUG),yes)
CXXFLAGS += -ggdb
else
CXXFLAGS += -O3
endif
ifeq ($(VALGRIND), yes)
CXXFLAGS = -Wall -O -g -fno-inline
endif
ifeq ($(shell uname -o), Cygwin)
DYNARE_M = dynare_m.exe
else
DYNARE_M = dynare_m
endif
ifeq ($(CROSS_WIN32), yes)
DYNARE_M = dynare_m.exe
endif
MAIN_OBJS = \
DynareFlex.o \ DynareFlex.o \
DynareBison.o \ DynareBison.o \
ComputingTasks.o \ ComputingTasks.o \
@ -36,35 +59,65 @@ OBJS = \
DynareMain.o \ DynareMain.o \
DynareMain2.o DynareMain2.o
MACRO_OBJS = \
macro/MacroFlex.o \
macro/MacroBison.o \
macro/MacroDriver.o \
macro/MacroValue.o
$(MAIN_OBJS) $(MAIN_OBJS:.o=.d): CPPFLAGS = -Iinclude
# Build rules # Build rules
all: all-recursive $(DYNARE_M) .PHONY: all
all: $(DYNARE_M)
all-recursive: $(DYNARE_M): $(MAIN_OBJS) $(MACRO_OBJS)
make -C macro $(CXX) $(CXXFLAGS) -o $(DYNARE_M) $(MAIN_OBJS) $(MACRO_OBJS)
$(DYNARE_M): $(OBJS) macro/libmacro.a
$(CXX) $(CXXFLAGS) -o $(DYNARE_M) $(OBJS) -Lmacro -lmacro
cp $(DYNARE_M) ../matlab/ cp $(DYNARE_M) ../matlab/
# Build rules for Flex and Bison files
DynareFlex.cc: DynareFlex.ll
flex -oDynareFlex.cc DynareFlex.ll
DynareBison.cc include/DynareBison.hh include/location.hh include/stack.hh include/position.hh: DynareBison.yy
bison --verbose -o DynareBison.cc DynareBison.yy
mv DynareBison.hh location.hh stack.hh position.hh include/
macro/MacroFlex.cc: macro/MacroFlex.ll
cd macro && flex -oMacroFlex.cc MacroFlex.ll
macro/MacroBison.cc macro/MacroBison.hh macro/location.hh macro/stack.hh macro/position.hh: macro/MacroBison.yy
cd macro && bison --verbose -o MacroBison.cc MacroBison.yy
# Dependencies # Dependencies
-include $(OBJS:.o=.P) # General rule for creating per-source dependencies Makefile
# We use -MG to avoid failing on generated headers (MacroBison.hh, DynareBison.hh)
# As a consequence, these headers are included without path-prefix
%.d: %.cc
@set -e; rm -f $@; \
$(CXX) -MM -MG $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
DynareFlex.cc: DynareFlex.ll include/DynareBison.hh include/ParsingDriver.hh # These files are included in the .d files without their path, so we force them
flex -oDynareFlex.cc DynareFlex.ll vpath DynareBison.hh include
vpath MacroBison.hh macro
DynareBison.cc include/DynareBison.hh: DynareBison.yy include/ParsingDriver.hh -include $(MAIN_OBJS:.o=.d)
bison --verbose -o DynareBison.cc DynareBison.yy -include $(MACRO_OBJS:.o=.d)
mv DynareBison.hh location.hh stack.hh position.hh include/
# Clean # Clean
clean: clean-recursive .PHONY: clean
rm -f *.o *.P \ clean:
rm -f *.o *.d \
*~ include/*~ \ *~ include/*~ \
DynareFlex.cc \ DynareFlex.cc \
DynareBison.output \ DynareBison.output \
@ -74,8 +127,11 @@ clean: clean-recursive
include/location.hh \ include/location.hh \
include/DynareBison.hh \ include/DynareBison.hh \
$(DYNARE_M) $(DYNARE_M)
cd macro && rm -f *.o *.d *~ \
clean-recursive: MacroFlex.cc \
make -C macro clean MacroBison.output \
MacroBison.cc \
.PHONY: all all-recursive clean clean-recursive MacroBison.hh \
location.hh \
stack.hh \
position.hh

View File

@ -1,36 +0,0 @@
CXXFLAGS = -Wall
ifeq ($(shell uname -o), Cygwin)
# Detection of uninitialized variables is buggy in Cygwin and generates spurious warnings
CXXFLAGS += -Wno-uninitialized
CXXFLAGS += -mno-cygwin
endif
ifeq ($(CROSS_WIN32), yes)
CXX = i586-mingw32msvc-g++
AR = i586-mingw32msvc-ar
# Detection of uninitialized variables is buggy in MinGW and generates spurious warnings
CXXFLAGS += -Wno-uninitialized
endif
ifeq ($(DEBUG),yes)
CXXFLAGS += -ggdb
else
CXXFLAGS += -O3
endif
ifeq ($(VALGRIND), yes)
CXXFLAGS = -Wall -O -g -fno-inline
endif
# General rule for compilation
%.o : %.cc
$(CXX) $(CXXFLAGS) -MD -I include -c $<
@cp $*.d $*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
rm -f $*.d
# Local variables:
# mode: makefile
# End:

View File

@ -1,27 +0,0 @@
include ../Makefile.include
OBJ = MacroFlex.o MacroBison.o MacroDriver.o MacroValue.o
libmacro.a: $(OBJ)
$(AR) crs libmacro.a $(OBJ)
-include $(OBJ:.o=.P)
MacroFlex.cc: MacroFlex.ll MacroBison.hh MacroDriver.hh
flex -oMacroFlex.cc MacroFlex.ll
MacroBison.cc MacroBison.hh: MacroBison.yy MacroDriver.hh
bison --verbose -o MacroBison.cc MacroBison.yy
clean:
rm -f *.o *.P *~ \
MacroFlex.cc \
MacroBison.output \
MacroBison.cc \
MacroBison.hh \
location.hh \
stack.hh \
position.hh \
libmacro.a
.PHONY: clean