# Makefile for exercises # requires gmake, tested with version 3.76.1 # NB do not try to use non-GNU make # Linux: tested on RH 5.0 with egcs-1.1.1 # Digital: tested on DU4.0D with CXX 6.1-027 # HP: tested on HP-UX 10.20 with aCC 1.21 # make `all' the default target; define it later. all:: # enter name of main (c++) source file here: SRC = test_random.cc # enter name of additional source files (c++ or fortran) here: CSRCS = random.cc FSRSC = #FSRCS = dummy2.f # Initialise compiler and preprocessor flags with OS-independent flags CPPFLAGS = CXXFLAGS = -g FFLAGS = -g F77LIBS = # link must be with c++ compiler if there is any c++ code LD = $(CXX) # CERN stuff # cern level is set explicitly here to avoid problems of # pro pointing to different versions on different machines CERNLVL = 99 CERN_ROOT = /cern/$(CERNLVL) CERNLIBS := $(shell CERN_LEVEL=$(CERNLVL) cernlib packlib genlib kernlib) CERNINCS := $(CERN_ROOT)/include CPPFLAGS += -I$(CERNINCS) # OS-specific compiler and preprocessor flags OS := $(shell uname -s) ifeq "$(OS)" "Linux" CXX = g++ FC = g77 CPPFLAGS += -Dextname -Df2cFortran CXXFLAGS += -D_GNU_SOURCE -pipe -ansi -pedantic F77LIBS += -L/usr/local/lib -lf2c -lm -ldl else ifeq "$(OS)" "OSF1" CXX = cxx FC = f77 CPPFLAGS += -Dextname CXXFLAGS += -no_implicit_include -D__USE_STD_IOSTREAM -std ansi F77LIBS += -lUfor -lfor -lFutil -lots -lm else ifeq "$(OS)" "HP-UX" CXX = aCC FC = f77 FFLAGS += +ppu +T CPPFLAGS += -Dextname CXXFLAGS += -z +p F77LIBS += -lm -lf -lisamstub -lcl -lm else # system unknown OS_UNKNOWN = true endif endif endif # derive object and exe file names OBJ = $(SRC:.cc=.o) OBJS = $(CSRCS:.cc=.o) $(FSRCS:.f=.o) EXE = $(OBJ:.o=) # Check that the OS is known oscheck: ifdef OS_UNKNOWN @echo "No settings available for OS=$(OS)" exit 1 else @echo "Using settings for $(OS)" # @echo "FC=$(FC) CXX=$(CXX) LD=$(LD)" endif # some debug info for the author of this makefile test: @echo "SRC=$(SRC) CSRCS=$(CSRCS) FSRCS=$(FSRCS) OBJ=$(OBJ) OBJS=$(OBJS) EXE=$(EXE)" # very basic dependencies $(EXE): $(OBJ) $(OBJS) $(LD) -o $@ $(CXXFLAGS) $(LDFLAGS) $+ $(CERNLIBS) $(F77LIBS) # define all all:: oscheck $(EXE) clean: -rm -f $(EXE) $(OBJ) $(OBJS) VPATH = ./:../