Makefile 4.1 KB
Newer Older
1 2 3 4 5

ifndef MACH
	MACH := $(shell uname)
endif

6 7 8
ifeq ($(MACH), Linux)
	include Linux_g++_make.inc
	ifeq ($(BLAS), 1)
9
# ===== OpenBLAS ========
10
		BLASYES = -DCBLAS
11
		BLASDIR = /exp/opera/kits/OpenBLAS
12
		BLASINC = -I$(BLASDIR)/include
13
		BLASLIB = -L$(BLASDIR)/lib
14
		BLASLIBN = $(BLASLIB) -lopenblas
15
	endif
16
else
17 18 19 20
	include Darwin_g++_omp_make.inc
# ===== nNative BLAS (Darwin)
	BLASYES = -DCBLAS -flax-vector-conversions 
	BLASLIBN = -framework Accelerate
21 22 23 24
	ifeq ($(BLAS), 0)
		BLASYES =
		BLASLIBN =
	endif
25
endif
26

27

28

29
# ===== Libsharp =====
30 31
#SHARPDIR = <yourdir>/libsharp-code/auto/

32
SHARPDIR = /Users/campagne/Travail/kits/libsharp-code/auto
33
SHARPLIB = $(SHARPDIR)/lib
34 35
SHARPINC = -I$(SHARPDIR)/include
SHARPLIBN = -L$(SHARPLIB) -lsharp -lc_utils -lfftpack 
36

37 38 39 40 41
SRC = ./src/
LIB = ./lib/
OBJ = ./objs/
EXE = ./bin/
DATA = ./data/
42
INCL = ./include/LagSHT/
43 44 45

#  Define our target list
.PHONY: default
46
default: confcheck makedir lib lagsht_testsuite
47 48

.PHONY: all 
49
all : confcheck makedir lib lagsht_testsuite 
50

51 52 53 54 55
.PHONY: install
install:
	mkdir -p $(INCL)
	cp $(SRC)/*.h $(INCL)

56 57

.PHONY: check
58
check : lagsht_testsuite
59 60 61
	$(EXE)lagsht_testsuite -t 1 -n 1024
	@paste lagWeights-1024-Func.txt $(DATA)lagWeights-1024-Func.txt.TEST | awk '{x=($$1-$$2)/$$2;y=(x<0?-x:x);if(max==""){max=y};if(y>max){max=y};sum+=(x<0?-x:x)} END {print "Weight Test: Max Err. ",max,"Abs. Relativ. Err =",sum/NR}'
	@paste lagNodes-1024-Func.txt $(DATA)lagNodes-1024-Func.txt.TEST | awk '{x=($$1-$$2)/$$2;y=(x<0?-x:x);if(max==""){max=y};if(y>max){max=y};sum+=(x<0?-x:x)} END {print "Nodes Test: Max Err. ",max,"Abs. Relativ. Err =",sum/NR}'
62 63 64 65


.PHONY: makedir
makedir :
66 67 68
	@mkdir -p $(OBJ)
	@mkdir -p $(EXE)
	@mkdir -p $(LIB)
69

70
confcheck :
71
	@echo "Config check mach=<$(MACH)> sharp=<$(SHARPDIR)> blas=<$(BLASDIR)>" 
72 73 74 75 76 77 78 79 80 81 82 83
ifeq ($(BLAS), 1)
	@if [ ! -d "$(BLASDIR)" ]; then \
		echo "BLAS directory not defined properly!"; \
		exit 1; \
	fi ; 
endif
	@if [ ! -d "$(SHARPDIR)" ]; then \
		echo "SHARP directory not defined properly!"; \
		exit 1; \
	fi ; 


84 85
.PHONY: tidy
tidy : 
86
	find . -name "*~" | xargs -I {} rm {}
87 88 89

.PHONY: clean
clean :
90
	rm -f $(OBJ)/*
91 92
	rm -f $(EXE)/*
	rm -f $(LIB)/*
93 94 95 96

#C++ common Objects
CXXOBJ = $(OBJ)laguerreBuilder.o \
	$(OBJ)laguerreTransform.o \
97
	$(OBJ)lagsht_spheregeom.o \
98
	$(OBJ)lagSphericTransform.o \
99 100 101
	$(OBJ)walltimer.o \
	$(OBJ)lagsht_bessel.o \
	$(OBJ)laguerre2bessel.o
102

103 104
CXXSHOBJ = laguerreBuilder.o \
	laguerreTransform.o \
105
	lagsht_spheregeom.o \
106
	lagSphericTransform.o \
107 108 109
	walltimer.o \
	lagsht_bessel.o \
	laguerre2bessel.o	
110

111 112

#C++ common Headers
113
CXXHDR = $(SRC)lagsht_exceptions.h \
114 115 116 117 118 119 120 121 122 123 124 125
	$(SRC)lagsht_numbers.h \
	$(SRC)lagsht_utils.h \
	$(SRC)lagsht_geom.h \
	$(SRC)lagsht_spheregeom.h \
	$(SRC)lagsht_healpixhelper.h \
	$(SRC)laguerreBuilder.h \
	$(SRC)laguerreTransform.h \
	$(SRC)lagSphericTransform.h \
	$(SRC)walltimer.h \
	$(SRC)lagsht_bessel.h \
	$(SRC)laguerre2bessel.h \
	$(SRC)quadinteg.h
126

127 128
CPPFLAGS  += $(BLASYES) $(SHARPINC) $(BLASINC)
LDFLAGS   += $(SHARPLIBN) $(BLASLIBN)  -lm
129 130 131


#C++ rule for compiling
132
$(OBJ)%.o: $(SRC)%.cc $(CXXHDR)
133
	echo "compile... $<"
134
	$(CXXCOMPILE) $< -o $@
135

136 137 138 139 140
######################
.PHONY: sharelib
sharelib : $(CXXOBJ)
	echo $(CXXSHOBJ) ; \
	cd $(OBJ); \
141
	$(CMDSHLCXX) -o $(LIB)liblagsht.$(SLEXT) $(CXXSHOBJ) $(LDFLAGS)
142
.PHONY: lib
143
lib : $(LIB)liblagsht.a
144

145
$(LIB)liblagsht.a : $(CXXOBJ)
146 147
	$(AR) $(ARFLAGS) $@ $?

148 149 150 151 152 153 154 155 156
######################
.PHONY:  lagsht_testsuite
lagsht_testsuite: $(EXE)lagsht_testsuite
	echo '---- lagsht_testsuite made'

$(EXE)lagsht_testsuite : $(OBJ)lagsht_testsuite.o $(CXXOBJ)
	echo "Link..."
	$(CXXLINK) -o $@ $(OBJ)lagsht_testsuite.o  $(CXXOBJ) $(LDFLAGS)

157
$(OBJ)lagsht_testsuite.o: $(SRC)lagsht_testsuite.cc $(CXXHDR)
158 159
	echo "compile... $<"
	$(CXXCOMPILE) $< -o $@
160

161 162 163
######################
.PHONY: fullcheck
fullcheck :
164 165 166 167 168 169 170 171 172
	$(EXE)lagsht_testsuite -t 0
	$(EXE)lagsht_testsuite -t 1 -n 1024
	$(EXE)lagsht_testsuite -t 2 -n 128	
	$(EXE)lagsht_testsuite -t 3 -l 512 -g ECP	
	$(EXE)lagsht_testsuite -t 3 -l 512 -g Gauss	
	$(EXE)lagsht_testsuite -t 3 -l 512 -g Healpix
	$(EXE)lagsht_testsuite -t 4 -l 1024 -n 128 -nphi 2048 -g ECP
	$(EXE)lagsht_testsuite -t 4 -l 1024 -n 128 -nphi 2048 -g Gauss	
	$(EXE)lagsht_testsuite -t 4 -l 1024 -n 128 -ntheta 512 -g Healpix
173 174 175 176 177