|
| 1 | +#-------------------------------------------------------- |
| 2 | +#-------------------------------------------------------- |
| 3 | +# |
| 4 | +# This is the hammurabi Makefile. The first part needs to be configured for your system. |
| 5 | +# |
| 6 | +# You can choose to build: |
| 7 | +# |
| 8 | +# hammurabi: by default, the basic hammurabi, pure C++, for constant or grid TEs and simple analytic models for CREs |
| 9 | +# hammurabi.ne2001: including linking to the (smooth) NE2001 Fortran code using cfortran.h |
| 10 | +# hammurabi.galprop: including both NE2001 and Galprop to simulate the CRE propagation with the hammurabi magnetic field first. |
| 11 | +# hammurabi.debug: including all code, debug flags. |
| 12 | +# all: builds all of these. |
| 13 | +# |
| 14 | +#-------------------------------------------------------- |
| 15 | +#-------------------------------------------------------- |
| 16 | + |
| 17 | +# |
| 18 | +# Give the locations of the various libraries. Should containt include and lib subdirectories. |
| 19 | +# |
| 20 | +BASE_DIR = $(HOME)/ |
| 21 | +HAMMURABI_HOME = $(BASE_DIR)/hammurabi |
| 22 | +GSL = /usr |
| 23 | +FFTW = /usr |
| 24 | +CFITSIO = /usr |
| 25 | +HEALPIX = $(HOME)/Healpix_3.31 |
| 26 | +HEALPIX_TARGET = basic_gcc |
| 27 | +SUBDIR = x86_64-linux-gnu |
| 28 | + |
| 29 | +# |
| 30 | +# These are needed if you build with Galprop |
| 31 | +# |
| 32 | +#GALPROP = $(BASE_DIR)/galprop/galprop/build |
| 33 | +CCFITS = /usr |
| 34 | +CLHEP = /usr |
| 35 | + |
| 36 | +# |
| 37 | +# What c++ compiler you are using? |
| 38 | +# |
| 39 | +CXX = g++ |
| 40 | +# |
| 41 | +# On OSX, maybe |
| 42 | +#CXX = g++-mp-5 |
| 43 | + |
| 44 | +# |
| 45 | +# Compile options? 64bit system (-m64), optimization (-O2), openMP (-fopenmp), warnings (-Wall), etc. |
| 46 | +# |
| 47 | +#CXXFLAGS = -m64 -O2 -fopenmp -Wall |
| 48 | +# |
| 49 | +# With OSX g++-mp-4.3 |
| 50 | +CXXFLAGS = -fopenmp -O2 -fno-inline-functions -Wall -Wextra -Wno-unknown-pragmas -ansi |
| 51 | + |
| 52 | +# |
| 53 | +# Which Fortran compiler you are using? Only if compiling with NE2001 and/or Galprop |
| 54 | +# |
| 55 | +FC = gfortran |
| 56 | +# |
| 57 | +# On OSX, maybe |
| 58 | +#FC = gfortran-mp-5 |
| 59 | + |
| 60 | +# For gfortran |
| 61 | +FCFLAGS = -O2 -ffixed-form -ffixed-line-length-132 -c |
| 62 | +# |
| 63 | +# For ifort |
| 64 | +#FCFLAGS =-O -extend-source -c |
| 65 | +# |
| 66 | +# For f77 ? |
| 67 | +#FCFLAGS = |
| 68 | + |
| 69 | +# |
| 70 | +# For linking to C++ with gcc |
| 71 | +# |
| 72 | +LFORTFLAGS= -Df2cFortran |
| 73 | + |
| 74 | +# |
| 75 | +# Additional options depending on how you want to run: |
| 76 | +# |
| 77 | +# Use openMP. Right now, this is mandatory. (Contact |
| 78 | +# [email protected] for help compiling without if for some reason you |
| 79 | +# need it.) |
| 80 | +#LFLAGS_CUSTOM = -fopenmp |
| 81 | +# |
| 82 | +# OSX with gfortran-mp-4.3 |
| 83 | +LFLAGS_CUSTOM = -fopenmp |
| 84 | +# |
| 85 | + |
| 86 | +# |
| 87 | +# |
| 88 | +# For J. West using f77 and gcc 4.1.2? |
| 89 | +# |
| 90 | +#LFORTFLAGS += -L/usr/lib/gcc/x86_64-redhat-linux/3.4.6/ -lgcc -lg2c |
| 91 | +#LFLAGS_CUSTOM += -lgcc_s |
| 92 | + |
| 93 | + |
| 94 | +#------------------------------------------------------------ |
| 95 | +#------------------------------------------------------------ |
| 96 | +# |
| 97 | +# From here onwards, nothing should need to be changed. |
| 98 | +# |
| 99 | +#------------------------------------------------------------ |
| 100 | +#------------------------------------------------------------ |
| 101 | + |
| 102 | +hammurabi.debug: CXXFLAGS=-m64 -g -Wall |
| 103 | + |
| 104 | + |
| 105 | +hammurabi: ALL_INC = -I$(CFITSIO)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/ |
| 106 | +#hammurabi: ALL_INC = -I$(CFITSIO)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/cxxsupport |
| 107 | +hammurabi.ne2001: ALL_INC = -I$(CFITSIO)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/ |
| 108 | +hammurabi.galprop: ALL_INC = -I$(CFITSIO)/include -I$(GALPROP)/.. -I$(GALPROP)/include/ -I$(CCFITS)/include/ -I$(CLHEP)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/ |
| 109 | +hammurabi.debug: ALL_INC = -I$(CFITSIO)/include -I$(GALPROP)/.. -I$(GALPROP)/include/ -I$(CCFITS)/include/ -I$(CLHEP)/include -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/ |
| 110 | +libhamprop.a: ALL_INC = -I$(CFITSIO)/include -I$(GALPROP)/.. -I$(GALPROP)/include/ -I$(GSL)/include -I. -I$(FFTW)/include -I$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/include/ |
| 111 | + |
| 112 | + |
| 113 | +hammurabi: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L. |
| 114 | +hammurabi.ne2001: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L. |
| 115 | +hammurabi.galprop: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GALPROP)/lib/ -L$(CCFITS)/lib/$(SUBDIR) -L$(CLHEP)/lib/$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L. |
| 116 | +hammurabi.debug: ALL_L = -L$(CFITSIO)/lib/$(SUBDIR) -L$(GALPROP)/lib/ -L$(CCFITS)/lib/$(SUBDIR) -L$(CLHEP)/lib /$(SUBDIR) -L$(GSL)/lib/$(SUBDIR) -L$(FFTW)/lib/$(SUBDIR) -L$(HEALPIX)/src/cxx/$(HEALPIX_TARGET)/lib/ -L. |
| 117 | + |
| 118 | + |
| 119 | +hammurabi : CXXFLAGS+= $(ALL_INC) -c |
| 120 | +hammurabi.ne2001: CXXFLAGS+= $(ALL_INC) -c -DNE2001 |
| 121 | +hammurabi.galprop: CXXFLAGS+= $(ALL_INC) -c -DGALDEF_PATH=\"./GALDEF\" -DFITSDATA_PATH=\"./FITS/\" -DDATA_PATH=\"./DATA\" -DGALPROP -DNE2001 |
| 122 | +hammurabi.debug : CXXFLAGS+= $(ALL_INC) -c -DGALDEF_PATH=\"./GALDEF\" -DFITSDATA_PATH=\"./FITS/\" -DDATA_PATH=\"./DATA\" -DGALPROP -DNE2001 -g -Wall |
| 123 | +# Turns off sanity check to avoid some circularity. See Galprop README.tess |
| 124 | +libhamprop.a: CXXFLAGS+= $(ALL_INC) -c -DGALDEF_PATH=\"./GALDEF\" -DFITSDATA_PATH=\"./FITS/\" -DDATA_PATH=\"./DATA\" -DLIBHAMPROP -DGALPROP -DNE2001 |
| 125 | + |
| 126 | + |
| 127 | +hammurabi: LFLAGS = $(ALL_L) -lhammurabi -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_threads $(LFLAGS_CUSTOM) |
| 128 | +hammurabi.ne2001: LFLAGS = $(ALL_L) -lhammurabi -lNE2001 -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_threads -lgfortran $(LFLAGS_CUSTOM) |
| 129 | +hammurabi.debug: LFLAGS = $(ALL_L) -lhammurabi -lNE2001 -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_omp -lgfortran -lgalprop -lskymap -lCCfits -lCLHEP $(LFLAGS_CUSTOM) |
| 130 | +hammurabi.galprop: LFLAGS = $(ALL_L) -lhammurabi -lNE2001 -lhealpix_cxx -lcxxsupport -lc_utils -lfftpack -lcfitsio -lgsl -lgslcblas -lm -lfftw3 -lfftw3_omp -lgfortran -lgalprop -lskymap -lCCfits -lCLHEP $(LFLAGS_CUSTOM) |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | +default: |
| 135 | + make hammurabi |
| 136 | +all: |
| 137 | + make clean ; make hammurabi ; make clean ; make hammurabi.ne2001; make clean; make hammurabi.galprop ; make clean ; make hammurabi.debug |
| 138 | + |
| 139 | +%.o : %.cpp |
| 140 | + $(CXX) $(CXXFLAGS) -o $@ $< |
| 141 | +%.o : %.cc |
| 142 | + $(CXX) $(CXXFLAGS) -o $@ $< |
| 143 | +%.o : %.c |
| 144 | + $(CXX) $(CXXFLAGS) -o $@ $< |
| 145 | +%.o : %.f |
| 146 | + $(FC) $(FCFLAGS) -o $@ $< |
| 147 | + |
| 148 | +class_TE_density.o: class_TE_density.cpp |
| 149 | + $(CXX) $(CXXFLAGS) $(LFORTFLAGS) -o $@ $< |
| 150 | + |
| 151 | +NE2001_OBJ = dmdsm.NE2001.o density.NE2001.o neclumpN.o nevoidN.o neLISM.NE2001.o |
| 152 | + |
| 153 | +HAMMURABI_OBJ = class_Integrator.o class_List.o class_B_field2.o tess_tools.o class_TE_density.o class_CRE.o namespace_Vec_Handling.o class_Dust.o |
| 154 | + |
| 155 | +run: |
| 156 | + mkdir run |
| 157 | + |
| 158 | +$(HAMMURABI_OBJ): hammurabi.h CGS_units_file.h proto*.h tess_tools.h |
| 159 | + |
| 160 | +libNE2001.a: $(NE2001_OBJ) |
| 161 | + ar rc $@ $(NE2001_OBJ) |
| 162 | + ranlib $@ |
| 163 | + |
| 164 | +hammurabi: $(HAMMURABI_OBJ) libhammurabi.a run hammurabi.o |
| 165 | + $(CXX) -o run/hammurabi hammurabi.o $(LFLAGS) $(LFORTFLAGS) |
| 166 | + |
| 167 | +hammurabi.ne2001: $(HAMMURABI_OBJ) $(NE2001_OBJ) $(NE2001_DATA) libNE2001.a libhammurabi.a run hammurabi.o |
| 168 | + $(CXX) -o run/hammurabi.ne2001 hammurabi.o $(LFLAGS) $(LFORTFLAGS) |
| 169 | + |
| 170 | +hammurabi.galprop: $(HAMMURABI_OBJ) $(NE2001_OBJ) $(NE2001_DATA) libNE2001.a libhammurabi.a run hammurabi.o |
| 171 | + $(CXX) -o run/hammurabi.galprop hammurabi.o $(LFLAGS) $(LFORTFLAGS) |
| 172 | + |
| 173 | +hammurabi.debug: $(HAMMURABI_OBJ) $(NE2001_DATA) libNE2001.a libhammurabi.a run hammurabi.o |
| 174 | + $(CXX) -o run/hammurabi.debug hammurabi.o $(LFLAGS) $(LFORTFLAGS) |
| 175 | +ifeq ($(OSTYPE),darwin) |
| 176 | + install_name_tool -change "@rpath/libCLHEP-2.3.3.1.dylib" "$(CLHEP)/lib/libCLHEP-2.3.3.1.dylib" run/hammurabi.debug |
| 177 | +endif |
| 178 | + |
| 179 | +print_constants: print_constants.o |
| 180 | + $(CXX) -o run/print_constants print_constants.o |
| 181 | + |
| 182 | +# To link in B_field to galprop, use this: |
| 183 | +libhamprop.a: class_B_field2.o tess_tools.o namespace_Vec_Handling.o |
| 184 | + ar cru libhamprop.a class_B_field2.o tess_tools.o namespace_Vec_Handling.o |
| 185 | + |
| 186 | +libhammurabi.a: $(HAMMURABI_OBJ) |
| 187 | + ar cru libhammurabi.a $(HAMMURABI_OBJ) |
| 188 | + |
| 189 | + |
| 190 | +clean: |
| 191 | + rm *.a *.o |
| 192 | + |
| 193 | +test: |
| 194 | + (cd unit_test; ./test.csh) |
| 195 | + |
| 196 | +test_big: |
| 197 | + (cd unit_test; ./test.csh big) |
| 198 | + |
| 199 | + |
| 200 | +tarfile: |
| 201 | + tar cvzf hammurabi.tgz *cpp *h Makefile *.f README hampy |
| 202 | + |
| 203 | +unittar: |
| 204 | + tar cvzf hammurabi_unit_test.tgz unit_test/inputs unit_test/GALDEF unit_test/FITS unit_test/negrid_n400.bin unit_test/ref.mini unit_test/ref unit_test/ref.big |
0 commit comments