Commit f38362d8 authored by sebastien's avatar sebastien
Browse files

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
parent 80aa9562
include Makefile.include
CXXFLAGS = -Wall
ifeq ($(shell uname -o), Cygwin)
DYNARE_M = dynare_m.exe
# 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
DYNARE_M = dynare_m
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
DYNARE_M = dynare_m.exe
endif
OBJS = \
MAIN_OBJS = \
DynareFlex.o \
DynareBison.o \
ComputingTasks.o \
......@@ -36,35 +59,65 @@ OBJS = \
DynareMain.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
all: all-recursive $(DYNARE_M)
# Build rules
all-recursive:
make -C macro
.PHONY: all
all: $(DYNARE_M)
$(DYNARE_M): $(OBJS) macro/libmacro.a
$(CXX) $(CXXFLAGS) -o $(DYNARE_M) $(OBJS) -Lmacro -lmacro
$(DYNARE_M): $(MAIN_OBJS) $(MACRO_OBJS)
$(CXX) $(CXXFLAGS) -o $(DYNARE_M) $(MAIN_OBJS) $(MACRO_OBJS)
cp $(DYNARE_M) ../matlab/
# Dependencies
-include $(OBJS:.o=.P)
# Build rules for Flex and Bison files
DynareFlex.cc: DynareFlex.ll include/DynareBison.hh include/ParsingDriver.hh
DynareFlex.cc: DynareFlex.ll
flex -oDynareFlex.cc DynareFlex.ll
DynareBison.cc include/DynareBison.hh: DynareBison.yy include/ParsingDriver.hh
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
# 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 $@.$$$$
# These files are included in the .d files without their path, so we force them
vpath DynareBison.hh include
vpath MacroBison.hh macro
-include $(MAIN_OBJS:.o=.d)
-include $(MACRO_OBJS:.o=.d)
# Clean
clean: clean-recursive
rm -f *.o *.P \
.PHONY: clean
clean:
rm -f *.o *.d \
*~ include/*~ \
DynareFlex.cc \
DynareBison.output \
......@@ -74,8 +127,11 @@ clean: clean-recursive
include/location.hh \
include/DynareBison.hh \
$(DYNARE_M)
clean-recursive:
make -C macro clean
.PHONY: all all-recursive clean clean-recursive
cd macro && rm -f *.o *.d *~ \
MacroFlex.cc \
MacroBison.output \
MacroBison.cc \
MacroBison.hh \
location.hh \
stack.hh \
position.hh
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:
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment