The second makefile is Makefile.export.nox.macros. This file contains all the flags and compiler options that the Trilinos libraries were built with. One challenge in linking applications against Trilinos is using a consistent set of compiler flags. This file take all the guesswork out of the process. Just include this file in your own makefile and use the associated flags.
Below is an example of a Makefile a user can write to link against NOX. This example can be found in the directory Trilinos/packages/nox/examples/lapack/NOX_ExportMakefile. In this example the user has written an interface to the nox lapack support for soving the Rosenbrock exmaple. The code is found in the file Rosenbrock.C. The file Makefile includes the NOX export makefiles:
##################################################################### ## Example Makefile for a user application that does not use autoconf ## - Uses lapack concrete instations for group and vector ## - Must use gnu-make (gmake) if the "shell" command is invoked ##################################################################### ## ## Set the Trilinos install directory ## TRILINOS_INSTALL_DIR = /home/rppawlo/trilinos_local ## ## Include any direct Trilinos library dependencies - in this case only nox ## include $(TRILINOS_INSTALL_DIR)/include/Makefile.export.nox.macros include $(TRILINOS_INSTALL_DIR)/include/Makefile.export.nox ## ## Use one of the following lines (2nd line is for non-gnumake platforms) ## COMPILE_FLAGS = $(shell perl $(TRILINOS_INSTALL_DIR)/include/strip_dup_incl_paths.pl $(NOX_CXXFLAGS) $(NOX_DEFS) $(NOX_CPPFLAGS) $(NOX_INCLUDES)) #COMPILE_FLAGS = $(NOX_CXXFLAGS) $(NOX_DEFS) $(NOX_CPPFLAGS) $(NOX_INCLUDES) ## ## Use one of the following lines (2nd line is for non-gnumake platforms) ## LINK_FLAGS = $(shell perl $(TRILINOS_INSTALL_DIR)/include/strip_dup_libs.pl $(NOX_LIBS)) #LINK_FLAGS = $(NOX_LIBS) ## ## Build your application code ## Rosenbrock.exe: Rosenbrock.o $(NOX_CXXLD) $(NOX_CXXFLAGS) -o Rosenbrock.exe Rosenbrock.o $(LINK_FLAGS) Rosenbrock.o: $(NOX_CXX) $(COMPILE_FLAGS) -c Rosenbrock.C clean: rm -f *.o Rosenbrock.exe *~
In this example, we assume the user has installed Trilinos into the directory /home/rppawlo/trilinos_local. This directory is specified when configuring Trilinos with the --prefix=/home/rppawlo/trilinos_local.
The first thing a user does is include the two export makefiles generated by nox. Next, the compile and link flags are defined. Note that there exist 2 ways of defining the COMPILE_FLAGS and LINK_FLAGS. One is for users that use gnu's version of make and the second (commented out) is for non-gnumake users. The shell command is only supported in gnumake and is used to strip out duplicate headers. The export makefile system has the unfortuante side effect of generating duplicate include paths when being installed. Finally, the user's application uses the compile and link flags to build their own executable.
NOX_PREFIX = /usr/local LDFLAGS = -L$(NOX_PREFIX)/lib LIBS = -lnox CXXFLAGS = -I$(NOX_PREFIX)/include/
Compiling with LAPACK support:
NOX_PREFIX = /usr/local LDFLAGS = -L$(NOX_PREFIX)/lib LIBS = -lnox -lnoxlapack -llapack -lblas CXXFLAGS = -I$(NOX_PREFIX)/include/
Compiling with Epetra support:
We assume that Epetra, Aztec, and Ifpack are installed in the same place as NOX.
NOX_PREFIX = /usr/local LDFLAGS = -L$(NOX_PREFIX)/lib LIBS = -lnox -lnoxepetra -laztecoo -lifpack -lepetra -llapack -lblas CXXFLAGS = -I$(NOX_PREFIX)/include/