From 1fb1c4367dd06af9081d9a5f8aab63eae5c88a44 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sun, 6 Jan 2008 19:30:15 +0000 Subject: [PATCH] Made the makefile.in usable from both the build and the install directory trees. --- test_problems/ChemEquil_red1/Makefile.in | 56 ++++++++++++-------- test_problems/ChemEquil_red1/basopt_red1.cpp | 13 ++--- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/test_problems/ChemEquil_red1/Makefile.in b/test_problems/ChemEquil_red1/Makefile.in index 5afbf98c5..1700a9650 100644 --- a/test_problems/ChemEquil_red1/Makefile.in +++ b/test_problems/ChemEquil_red1/Makefile.in @@ -17,14 +17,14 @@ PROG_NAME = basopt_red1 # and from C/C++ separately OBJS = basopt_red1.o -# Location of the current build. Will assume that tests are run -# in the source directory tree location -src_dir_tree = 0 - # additional flags to be passed to the linker. If your program # requires other external libraries, put them here LINK_OPTIONS = @EXTRA_LINK@ +# This variable determines whether we are making this example in the +# build tree environment or in the install tree environment. +in_CanteraBuildTree = 1 + ############################################################################# # Check to see whether we are in the msvc++ environment @@ -36,42 +36,53 @@ FORT_LIBS = @FLIBS@ # the C++ compiler CXX = @CXX@ +# the directory where Cantera include files may be found. +ifeq ($(in_CanteraBuildTree),1) +CANTERA_INCROOTDIR=@ctroot@/build/include +else +CANTERA_INCROOTDIR=@ct_incroot@ +endif +CANTERA_INCLUDES=-I$(CANTERA_INCROOTDIR) -I$(CANTERA_INCROOTDIR)/cantera + # LOCAL_DEFS = -DDEBUG_CHEMEQUIL # LOCAL_DEFS = -DEBUG_BASISOPTIMIZE # # C++ compile flags -ifeq ($(src_dir_tree), 1) -CXX_FLAGS = -DSRCDIRTREE @CXXFLAGS@ -else -CXX_FLAGS = @CXXFLAGS@ -endif +CXX_FLAGS = @CXXFLAGS@ $(CANTERA_INCLUDES) $(LOCAL_DEFS) # Ending C++ linking libraries LCXX_END_LIBS = @LCXX_END_LIBS@ # the directory where the Cantera libraries are located +ifeq ($(in_CanteraBuildTree),1) CANTERA_LIBDIR=@buildlib@ - -# required Cantera libraries -CANTERA_LIBS = @LOCAL_LIBS@ -lctcxx - -# the directory where Cantera include files may be found. -ifeq ($(src_dir_tree), 1) -CANTERA_INCDIR=../../Cantera/src else -CANTERA_INCDIR=@ctroot@/build/include/cantera +CANTERA_LIBDIR=@ct_libdir@ endif +# required Cantera libraries +CANTERA_LIBS = -L$(CANTERA_LIBDIR) @LOCAL_LIBS@ -lctcxx + +ifeq ($(in_CanteraBuildTree),1) +CANTERA_LIBS_DEP = @LOCAL_LIBS_DEP@ $(CANTERA_LIBDIR)/libctcxx.a +else +CANTERA_LIBS_DEP = @INSTALL_LIBS_DEP@ $(CANTERA_LIBDIR)/libctcxx.a +endif + +# +# Alternate form of dependencies: (uses a gnu make extensions) +ALT_LIBS_DEP := $(addprefix $(CANTER_LIBDIR), @RAW_LIBS_DEP@ libctcxx.a) + # flags passed to the C++ compiler/linker for the linking step -LCXX_FLAGS = -L$(CANTERA_LIBDIR) @LOCAL_LIB_DIRS@ @CXXFLAGS@ +LCXX_FLAGS = @CXXFLAGS@ # How to compile C++ source files to object files -.@CXX_EXT@.@OBJ_EXT@: - $(CXX) -c $< -I$(CANTERA_INCDIR) $(CXX_FLAGS) +.cpp.o: + $(CXX) -c $< $(CXX_FLAGS) # How to compile the dependency file .cpp.d: - @CXX_DEPENDS@ -I$(CANTERA_INCDIR) $(CXX_FLAGS) $*.cpp > $*.d + @CXX_DEPENDS@ $(CXX_FLAGS) $*.cpp > $*.d # List of dependency files to be created DEPENDS=$(OBJS:.o=.d) @@ -81,12 +92,11 @@ PROGRAM = $(PROG_NAME)$(EXE_EXT) all: $(PROGRAM) -$(PROGRAM): $(OBJS) $(CANTERA_LIBDIR)/libctbase.a +$(PROGRAM): $(OBJS) $(CANTERA_LIBS_DEP) $(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(LINK_OPTIONS) \ $(CANTERA_LIBS) @LIBS@ $(FORT_LIBS) \ $(LCXX_END_LIBS) - # Add an additional target for stability: $(OBJS): $(CANTERA_LIBDIR)/libctbase.a $(CANTERA_LIBDIR)/libthermo.a diff --git a/test_problems/ChemEquil_red1/basopt_red1.cpp b/test_problems/ChemEquil_red1/basopt_red1.cpp index 0d76875b4..3a31ba098 100644 --- a/test_problems/ChemEquil_red1/basopt_red1.cpp +++ b/test_problems/ChemEquil_red1/basopt_red1.cpp @@ -5,16 +5,9 @@ * */ -#ifdef SRCDIRTREE -#include "ct_defs.h" -#include "ThermoPhase.h" -#include "IdealGasMix.h" -#include "equil.h" -#else -#include "Cantera.h" -#include "IdealGasMix.h" -#include "equilibrium.h" -#endif +#include "cantera/Cantera.h" +#include "cantera/IdealGasMix.h" +#include "cantera/equilibrium.h" using namespace std; using namespace Cantera;