summaryrefslogtreecommitdiff
path: root/PyGan/src/Makefile
blob: f48c98a497c4668339e028f3f23e72fa0dcc37e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#---------------------------------------------------------------------------
#
#  Makefile for building the PyGan extension modules
#  Author : A. Hebert (2020-7-3)
#
#---------------------------------------------------------------------------
#
OS = $(shell uname -s | cut -d"_" -f1)
ifeq ($(OS),AIX)
  DIRNAME = AIX
else
  DIRNAME = $(shell uname -sm | sed 's/[ ]/_/')
endif
pylib = $(shell python3 ../../script/find_pylib.py)
PYTHONPATH = $(pylib)/python
$(info set PYTHONPATH="$(PYTHONPATH)")
export PYTHONPATH

ifeq ($(intel),1)
  ifeq ($(INTELTOOLS),)
    $(error INTELTOOLS is not set)
  endif
  COMPILER = INTELTOOLS
  lib = ../lib/$(DIRNAME)_intel
  libGan = ../../Ganlib/lib/$(DIRNAME)_intel
else
  ifeq ($(nvidia),1)
    ifeq ($(NVTOOLS),)
      $(error NVTOOLS is not set)
    endif
    COMPILER = NVTOOLS
    lib = ../lib/$(DIRNAME)_nvidia
    libGan = ../../Ganlib/lib/$(DIRNAME)_nvidia
  else
    ifeq ($(llvm),1)
      ifeq ($(LLVMTOOLS),)
        $(error LLVMTOOLS is not set)
      endif
      COMPILER = LLVMTOOLS
      lib = ../lib/$(DIRNAME)_llvm
      libGan = ../../Ganlib/lib/$(DIRNAME)_llvm
    else
      ifeq ($(FORTRANPATH),)
        $(error FORTRANPATH is not set)
      endif
      COMPILER = FORTRANPATH
      lib = ../lib/$(DIRNAME)
      libGan = ../../Ganlib/lib/$(DIRNAME)
    endif
  endif
endif
export COMPILER

all:
	$(MAKE) donjon
checkPython: ; @which python3 > /dev/null
ganlib: clean sub-make-ganlib pygan-ganlib
ifeq ($(openmp),1)
	@echo 'pygan_ganlib: openmp is defined'
endif
ifeq ($(intel),1)
	@echo 'pygan_ganlib: intel is defined'
endif
ifeq ($(nvidia),1)
	@echo 'pygan_ganlib: nvidia is defined'
endif
ifeq ($(llvm),1)
	@echo 'pygan_ganlib: llvm is defined'
endif
ifeq ($(hdf5),1)
	@echo 'pygan_ganlib: hdf5 is defined'
endif
trivac: clean sub-make-trivac pygan-trivac
ifeq ($(openmp),1)
	@echo 'pygan_trivac: openmp is defined'
endif
ifeq ($(intel),1)
	@echo 'pygan_trivac: intel is defined'
endif
ifeq ($(nvidia),1)
	@echo 'pygan_trivac: nvidia is defined'
endif
ifeq ($(llvm),1)
	@echo 'pygan_trivac: llvm is defined'
endif
ifeq ($(hdf5),1)
	@echo 'pygan_trivac: hdf5 is defined'
endif
dragon: clean sub-make-dragon pygan-dragon
ifeq ($(openmp),1)
	@echo 'pygan_dragon: openmp is defined'
endif
ifeq ($(intel),1)
	@echo 'pygan_dragon: intel is defined'
endif
ifeq ($(nvidia),1)
	@echo 'pygan_dragon: nvidia is defined'
endif
ifeq ($(llvm),1)
	@echo 'pygan_dragon: llvm is defined'
endif
ifeq ($(hdf5),1)
	@echo 'pygan_dragon: hdf5 is defined'
endif
donjon: clean sub-make-donjon pygan-donjon
ifeq ($(openmp),1)
	@echo 'pygan_donjon: openmp is defined'
endif
ifeq ($(intel),1)
	@echo 'pygan_donjon: intel is defined'
endif
ifeq ($(nvidia),1)
	@echo 'pygan_donjon: nvidia is defined'
endif
ifeq ($(llvm),1)
	@echo 'pygan_donjon: llvm is defined'
endif
ifeq ($(hdf5),1)
	@echo 'pygan_donjon: hdf5 is defined'
endif
sub-make-ganlib:
	$(MAKE) openmp=$(openmp) hdf5=$(hdf5) -C ../../Ganlib/src
sub-make-trivac: sub-make-ganlib
	$(MAKE) openmp=$(openmp) -C ../../Utilib/src
	$(MAKE) openmp=$(openmp) hdf5=$(hdf5) -C ../../Trivac/src
sub-make-dragon: sub-make-trivac
	$(MAKE) openmp=$(openmp) hdf5=$(hdf5) -C ../../Dragon/src
sub-make-donjon: sub-make-dragon
	$(MAKE) openmp=$(openmp) hdf5=$(hdf5) -C ../../Donjon/src
libGanlib.a: $(lib)/ sub-make-ganlib
	cp $(libGan)/libGanlib.a .
	ar -d libGanlib.a xabort_c.o
	mv libGanlib.a $(lib)
$(lib)/:
	mkdir -p $(lib)/
pygan-ganlib: libGanlib.a sub-make-ganlib checkPython
	mkdir -p $(DIRNAME)
	cp *.[ch] $(DIRNAME)
	cp *.py $(DIRNAME)
	cd $(DIRNAME); python3 setup_lcm.py install --home=.
	cd $(DIRNAME); python3 setup_lifo.py install --home=.
ifeq ($(openmp),1)
	export CODE_EMBEDDED=GANLIB_OMP; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
else
	export CODE_EMBEDDED=GANLIB; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
endif
	mv $(DIRNAME)/$(pylib)/* $(lib)/
	/bin/rm -r $(DIRNAME)
pygan-trivac: libGanlib.a sub-make-trivac checkPython
	mkdir -p $(DIRNAME)
	cp *.[ch] $(DIRNAME)
	cp *.py $(DIRNAME)
	cd $(DIRNAME); python3 setup_lcm.py install --home=.
	cd $(DIRNAME); python3 setup_lifo.py install --home=.
ifeq ($(openmp),1)
	export CODE_EMBEDDED=TRIVAC_OMP; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
else
	export CODE_EMBEDDED=TRIVAC; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
endif
	mv $(DIRNAME)/$(pylib)/* $(lib)/
	/bin/rm -r $(DIRNAME)
pygan-dragon: libGanlib.a sub-make-dragon checkPython
	mkdir -p $(DIRNAME)
	cp *.[ch] $(DIRNAME)
	cp *.py $(DIRNAME)
	cd $(DIRNAME); python3 setup_lcm.py install --home=.
	cd $(DIRNAME); python3 setup_lifo.py install --home=.
ifeq ($(openmp),1)
	export CODE_EMBEDDED=DRAGON_OMP; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
else
	export CODE_EMBEDDED=DRAGON; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
endif
	mv $(DIRNAME)/$(pylib)/* $(lib)/
	/bin/rm -r $(DIRNAME)
pygan-donjon: libGanlib.a sub-make-donjon checkPython
	mkdir -p $(DIRNAME)
	cp *.[ch] $(DIRNAME)
	cp *.py $(DIRNAME)
	cd $(DIRNAME); python3 setup_lcm.py install --home=.
	cd $(DIRNAME); python3 setup_lifo.py install --home=.
ifeq ($(openmp),1)
	export CODE_EMBEDDED=DONJON_OMP; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
else
	export CODE_EMBEDDED=DONJON; cd $(DIRNAME); python3 setup_cle2000.py install --home=.
endif
	mv $(DIRNAME)/$(pylib)/* $(lib)/
	/bin/rm -r $(DIRNAME)
	@echo 'makefile PYTHONPATH=' $(PYTHONPATH)
clean:
	@echo 'clean PyGan'
	@echo '**********************************************'
	@echo '*** You should also clean Dragon or Donjon ***'
	@echo '**********************************************'
	/bin/rm -r -f ../lib
	/bin/rm -f sub-make*