## |*----------------------------------------------------------------------*| ## | Description: ## | ## | This makefile defines all of the basic rules for g++ ## | compilation of RESOLVE/C++ code. To use it, do one of the ## | following: ## | ## | 1. Invoke gmake as follows: ## | ## | gmake -f /Makefile.rcpp -f ## | ## | where is the directory where this file is located, ## | and is the file defining your target ## | rules. make/gmake will read all of the makefiles ## | specified via -f, treating them like one big concatenated ## | makefile. This will cause make/gmake to use the default ## | rules defined here to process the targets defined in ## | . ## | ## | 2. At the top of , place a line like the ## | following: ## | ## | include /Makefile.rcpp ## | ## | This will cause this file to be included at that point in ## | the processing of your makefile by make/gmake. ## | ## | This file is broken into two parts. The first part documents ## | the user-tailorable features of this file, which are ## | controlled through makefile macros. By redefining these ## | macros in your own makefile, you can affect the behavior of ## | various default rules. ## | ## | The second part gives the actual rules defined in this file. ## | ## | ## | Typical rules for RESOLVE/C++ programs: ## | --------------------------------------- ## | ## | The following examples show typical ways that RESOLVE/C++ ## | makefile rules can be given. These examples assume that you ## | will be using "gmake" (GNU's version of make) instead of ## | "make". In most cases, there is no difference, but one ## | default rule (the one for generating an executable directly ## | from a single .cpp file) will not be processed correctly by ## | "make" due to a bug it has. ## | ## | 1. Compiling an executable from a single source file: ## | ## | myprogram: myprogram.cpp ## | ## | That's all there is to it! ## | ## | 2. Compiling an executable from a single object file: ## | ## | myprogram: myprogram.o ## | myprogram.o: myprogram.cpp ## | ## | 3. Compiling an executable from a several object files: ## | ## | myprogram: part1.o part2.o part3.o ## | $(LINK.cpp) -o myprogram \ ## | part1.o part2.o part3.o $(LDLIBS) ## | part1.o: part1.cpp ## | part2.o: part2.cpp ## | part3.o: part3.cpp ## | ## | Here, the $(LINK.cpp) macro defines the basic options for ## | linking together a .cpp executable, and $(LDLIBS) defines ## | the libraries included during linking. Both are given ## | definitions in this file, so the above 6 lines are really ## | a self-contained, working makefile. ## | ## | 4. Compiling a source file with custom options: ## | ## | myprogram.o: myprogram.cpp ## | $(COMPILE.cpp) myprogram.cpp ## | ## | Again, the $(COMPILE.cpp) macro defines the basic options ## | for compiling a .cpp file, and it is given a definition in ## | this file. ## | ## | For the advanced user, look at the definitions of ## | $(COMPILE.cpp), $(LINK.cpp), and the default rules specified ## | in part 2 below. ## | ## | ## | Some Simple Settings: ## | --------------------- ## | ## | Either place these lines in your Makefile.rcpp, or add them ## | directly on the rcpp-make command line. ## | ## | To turn on debugging info in generated files, use: ## | DEBUG=-g ## | ## | To allow profiling, use: ## | DEBUG=-g -pg ## | ## | ## \*----------------------------------------------------------------------*/ ## /*----------------------------------------------------------------------*\ ## | Part 1: Default macros and rules ## \*----------------------------------------------------------------------*/ #---------- # This macro defines the location of the component library. #---------- ifndef RCPP_HOME RCPP_HOME=/class/sce/rcpp endif RCPP=$(RCPP_HOME)$(RCPPVERSION) HOSTTYPE:=$(shell uname -p) HOSTOS:=$(shell uname -s) HOSTNAME:=$(shell uname -n) LIBDIR:=$(HOSTOS)-$(HOSTTYPE) #---------- # These suffixes are extended with .cpp and .cpp~ for our naming # conventions. #---------- SUFFIXES = .o .c .c~ .cc .cc~ .s .s~ .S .S~ .ln .f .f~ .F .F~ .l .l~ \ .mod .mod~ .sym .def .def~ .p .p~ .r .r~ .y .y~ .h .h~ .sh .sh~ \ .cps .cps~ .cpp .cpp~ .d .d~ .so .etc .etc~ .SUFFIXES: $(SUFFIXES) #---------- # These macros define the compiler to use, the basic command line # options, and the preprocessor command line options. #---------- # if the string "cse.ohio-state.edu" is part of the hostname # (i.e., the result returned by findstring is not the empty string) # assume user is student using SCE setup ifneq (,$(findstring cse.ohio-state.edu,$(HOSTNAME))) CXX=$(RCPP)/tools/wrapper/$(LIBDIR)/rcpp-c++ CX=$(RCPP)/tools/wrapper/$(LIBDIR)/rcpp-gcc else # this is a hack because on solaris the hostname does not contain the domain ifeq ($(HOSTTYPE),sparc) CXX=$(RCPP)/tools/wrapper/$(LIBDIR)/rcpp-c++ CX=$(RCPP)/tools/wrapper/$(LIBDIR)/rcpp-gcc else CXX=c++ CX=gcc endif endif CCC=$(CXX) CC=$(CX) ifeq ($(HOSTOS),Darwin) # DEBUG=-g -O2 DEBUG=-g else # Not Darwin # DEBUG=-s -O2 DEBUG=-s endif CCFLAGS=$(DEBUG) MMDFLAGS=-MMD INCLUDES=-I. -I$(RCPP) -I$(HOME)/rcpp/Personal_Catalog -I$(RCPP)/RESOLVE_Catalog -I$(RCPP)/Bugs_Catalog #Add -w flag to CPPFLAGS to disable warnings; on newer versions of gcc #you can also disable specific catagories of warnings, if necessary ifeq ($(HOSTTYPE),sparc) ifdef LOG CPPFLAGS=-ftemplate-depth-99 -finstrument-functions $(INCLUDES) else CPPFLAGS=-ftemplate-depth-99 $(INCLUDES) endif else # $(HOSTTYPE) = i386 CPPFLAGS=-ftemplate-depth-99 $(INCLUDES) endif ifeq ($(HOSTOS),Linux) CPPFLAGS += -m32 endif #---------- # These macros define the linker options. #---------- ifeq ($(HOSTTYPE),sparc) LDFLAGS=-L$(RCPP)/lib/$(HOSTOS)-$(HOSTTYPE) -R/class/sce/gcc-3.4.1/lib ifdef LOG LDLIBS=-lfound-log -ldl -lnsl -lsocket -lm else LDLIBS=-lfound -ldl -lnsl -lsocket -lm endif else # $(HOSTTYPE) = i386 LDFLAGS=-L$(RCPP)/lib/$(HOSTOS)-$(HOSTTYPE) LDLIBS=-lfound -lm endif ifeq ($(HOSTOS),Linux) LDFLAGS += -rdynamic endif #---------- # These macros define the standard "command lines" to use for # compiling and linking. #---------- COMPILE.cpp=$(CCC) $(CCFLAGS) $(CPPFLAGS) $(MMDFLAGS) -c COMPILE.c=$(CC) -c COMPILE_SO.cpp=$(CCC) $(CCFLAGS_SL) $(CPPFLAGS) $(MMDFLAGS) -c LINK.cpp=$(CCC) $(REPO) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) BARE_LINK.cpp=$(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) #---------- # This default rule covers the generation of executables directly from # a single source file. For some reason it doesn't work under "make" # (maybe the suffix is too long?). It works fine under "gmake", # however. #---------- .cpp: @echo "" @echo "==== Compiling" $< / Linking $@ "====" $(BARE_LINK.cpp) -o $@ $< $(LDLIBS) #---------- # This default rule covers the generation of executables directly from # a single object file. #---------- .o: @echo "" @echo "==== Linking" $@ "====" $(BARE_LINK.cpp) -o $@ $< $(LDLIBS) #---------- # This default rule covers the generation of object files from single # source files. #---------- .cpp.o: @echo "" @echo "==== Compiling" $< "====" $(COMPILE.cpp) $(OUTPUT_OPTION) $< #---------- # This default rule covers the generation of make dependency rule # files (used by rcpp-make) from single source files. #---------- #.cpp.d: # $(CCC) $(CPPFLAGS) -MM $< > $@ .cpp.d: @echo "" @echo "==== Creating initial" $@ "file for" $< "====" @echo $<: $< | sed -e 's/\.[^:]*//' > $@ ## |*----------------------------------------------------------------------*|