1TOPDIR	= ..
2
3include ../Makefile.system
4
5ifndef EXPRECISION
6EXPRECISION	= 0
7endif
8
9ifndef NO_CBLAS
10NO_CBLAS	= 0
11endif
12
13ifndef NO_LAPACK
14NO_LAPACK	= 0
15endif
16
17ifndef NO_LAPACKE
18NO_LAPACKE	= 0
19endif
20
21ifndef NEED2UNDERSCORES
22NEED2UNDERSCORES=0
23endif
24
25ifndef ONLY_CBLAS
26ONLY_CBLAS	= 0
27endif
28
29ifndef BUILD_LAPACK_DEPRECATED
30BUILD_LAPACK_DEPRECATED = 0
31endif
32
33ifndef BUILD_BFLOAT16
34BUILD_BFLOAT16 = 0
35endif
36ifndef BUILD_SINGLE
37BUILD_SINGLE = 0
38endif
39ifndef BUILD_DOUBLE
40BUILD_DOUBLE = 0
41endif
42ifndef BUILD_COMPLEX
43BUILD_COMPLEX = 0
44endif
45ifndef BUILD_COMPLEX16
46BUILD_COMPLEX16 = 0
47endif
48
49ifeq ($(OSNAME), WINNT)
50ifeq ($(F_COMPILER), GFORTRAN)
51ifndef ONLY_CBLAS
52EXTRALIB += -lgfortran
53endif
54endif
55ifeq ($(USE_OPENMP), 1)
56ifeq ($(C_COMPILER), GCC)
57EXTRALIB += -lgomp
58endif
59endif
60endif
61
62ifeq ($(OSNAME), CYGWIN_NT)
63ifeq ($(F_COMPILER), GFORTRAN)
64ifndef ONLY_CBLAS
65EXTRALIB += -lgfortran
66endif
67endif
68endif
69
70ifeq ($(C_COMPILER), PGI)
71EXTRALIB += -pgf90libs
72endif
73
74ifneq (,$(filter 1 2,$(NOFORTRAN)))
75FEXTRALIB =
76endif
77
78all::
79
80libs::
81
82prof::
83
84hpl:: libgoto_hpl.$(LIBSUFFIX)
85
86hpl_p:: libgoto_hpl_p.$(LIBSUFFIX)
87
88libgoto_hpl.$(LIBSUFFIX) : ../$(LIBNAME)
89	rm -f $(@F)
90	$(LD) -r $(LDFLAGS) -o goto.$(SUFFIX) --whole-archive $< --no-whole-archive
91	$(AR) cq $(@F) goto.$(SUFFIX)
92	$(RANLIB) libgoto_hpl.$(LIBSUFFIX)
93
94libgoto_hpl_p.$(LIBSUFFIX) :  ../$(LIBNAME_P)
95	rm -f $(@F)
96	$(LD) -r  $(LDFLAGS) -o goto.$(PSUFFIX)  --whole-archive $< --no-whole-archive
97	$(AR) cq $(@F) goto.$(PSUFFIX)
98	$(RANLIB) libgoto_hpl_p.$(LIBSUFFIX)
99
100libgoto_hpl.dll : libgoto_hpl.$(LIBSUFFIX) dllinit.$(SUFFIX) libgoto_hpl.def
101	$(DLLWRAP) -o $(@F) --def libgoto_hpl.def --entry _dllinit -s dllinit.$(SUFFIX) --dllname libgoto_hpl.dll libgoto_hpl.$(LIBSUFFIX)
102	lib /machine:X64 /def:libgoto_hpl.def
103
104dyn : $(LIBDYNNAME)
105
106zip : dll
107	zip $(LIBZIPNAME) $(LIBDLLNAME) $(LIBNAME)
108
109dll  : ../$(LIBDLLNAME)
110
111# On Windows, we only generate a DLL without a version suffix.  This is because
112# applications which link against the dynamic library reference a fixed DLL name
113# in their import table.  By instead using a stable name it is possible to
114# upgrade between library versions, without needing to re-link an application.
115# For more details see: https://github.com/xianyi/OpenBLAS/issues/127.
116../$(LIBDLLNAME) : ../$(LIBNAME) $(LIBPREFIX).def dllinit.$(SUFFIX)
117	$(RANLIB) ../$(LIBNAME)
118	$(CC) $(CFLAGS) $(LDFLAGS) $(LIBPREFIX).def dllinit.$(SUFFIX) \
119	-shared -o ../$(LIBDLLNAME) -Wl,--out-implib,../$(IMPLIBNAME) \
120	-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(FEXTRALIB) $(EXTRALIB)
121
122$(LIBPREFIX).def : gensymbol
123	perl ./gensymbol win2k    $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
124
125libgoto_hpl.def : gensymbol
126	perl ./gensymbol win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
127
128ifeq ($(OSNAME), Darwin)
129INTERNALNAME = $(LIBPREFIX).$(MAJOR_VERSION).dylib
130endif
131
132ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
133$(LIBDYNNAME) : ../$(LIBNAME) osx.def
134else
135../$(LIBNAME).osx.renamed : ../$(LIBNAME) objconv.def
136	$(OBJCONV) @objconv.def ../$(LIBNAME) ../$(LIBNAME).osx.renamed
137$(LIBDYNNAME) : ../$(LIBNAME).osx.renamed osx.def
138endif
139ifneq (,$(filter 1 2,$(NOFORTRAN)))
140#only build without Fortran
141	$(CC) $(CFLAGS) $(LDFLAGS) -all_load -headerpad_max_install_names -install_name "$(CURDIR)/../$(INTERNALNAME)" -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def  $(FEXTRALIB)
142else
143ifeq ($(F_COMPILER), INTEL)
144	$(FC) $(FFLAGS) $(LDFLAGS) -all-load -headerpad_max_install_names -install_name "$(CURDIR)/../$(INTERNALNAME)" -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def
145else
146	$(FC) $(FFLAGS) $(LDFLAGS) -all_load -headerpad_max_install_names -install_name "$(CURDIR)/../$(INTERNALNAME)" -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def  $(FEXTRALIB)
147endif
148endif
149
150dllinit.$(SUFFIX) : dllinit.c
151	$(CC) $(CFLAGS) -c -o $(@F) -s $<
152
153ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS Android Haiku FreeBSD DragonFly))
154
155so : ../$(LIBSONAME)
156
157ifeq ($(OSNAME), Android)
158INTERNALNAME = $(LIBPREFIX).so
159FEXTRALIB += -lm
160EXTRALIB += -lm
161else
162INTERNALNAME = $(LIBPREFIX).so.$(MAJOR_VERSION)
163endif
164
165ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
166../$(LIBSONAME) : ../$(LIBNAME) linktest.c
167else
168../$(LIBNAME).renamed : ../$(LIBNAME) objcopy.def
169	$(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME) ../$(LIBNAME).renamed
170../$(LIBSONAME) : ../$(LIBNAME).renamed linktest.c
171endif
172
173ifeq ($(F_COMPILER), INTEL)
174	$(FC) $(FFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
175	-Wl,--whole-archive $< -Wl,--no-whole-archive \
176	-Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
177	$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
178else ifeq ($(F_COMPILER), FLANG)
179	$(FC) $(FFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
180	-Wl,--whole-archive $< -Wl,--no-whole-archive \
181	-Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
182	$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
183else
184ifneq ($(C_COMPILER), LSB)
185	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
186	-Wl,--whole-archive $< -Wl,--no-whole-archive \
187	-Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
188	$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
189else
190#for LSB
191	env LSBCC_SHAREDLIBS=gfortran $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
192	-Wl,--whole-archive $< -Wl,--no-whole-archive \
193	-Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
194	$(FC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
195endif
196endif
197	rm -f linktest
198
199endif
200
201#http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
202ifeq ($(OSNAME), $(filter $(OSNAME),OpenBSD NetBSD))
203
204so : ../$(LIBSONAME)
205
206ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
207../$(LIBSONAME) : ../$(LIBNAME) linktest.c
208else
209../$(LIBNAME).renamed : ../$(LIBNAME) objcopy.def
210	$(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME) ../$(LIBNAME).renamed
211../$(LIBSONAME) : ../$(LIBNAME).renamed linktest.c
212endif
213	$(CC) $(CFLAGS) $(LDFLAGS)  -shared -o ../$(LIBSONAME) \
214	-Wl,--whole-archive $< -Wl,--no-whole-archive \
215	-Wl,-soname,$(LIBSONAME) $(FEXTRALIB) $(EXTRALIB)
216	$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
217	rm -f linktest
218
219endif
220
221ifeq ($(OSNAME), OSF1)
222
223so : ../$(LIBSONAME)
224
225../$(LIBSONAME) :
226	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) ../$(LIBNAME)
227endif
228
229ifeq ($(OSNAME), SunOS)
230
231so : ../$(LIBSONAME)
232	$(CC) $(CFLAGS) $(LDFLAGS)  -shared -o ../$(LIBSONAME) \
233	-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(EXTRALIB)
234	$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
235	rm -f linktest
236
237endif
238
239ifeq ($(OSNAME), AIX)
240
241ifeq ($(COMPILER_F77), xlf)
242
243goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
244	ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lxlf90 -lc -lm  -lpthread
245
246goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
247	ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lxlf90 -lc -lm -lpthread
248else
249goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
250	ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lg2c -lc -lm
251
252goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
253	ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lg2c -lc -lm
254endif
255endif
256
257static : ../$(LIBNAME)
258	$(LD) $(LDFLAGS) -r -o goto.$(SUFFIX) \
259	--whole-archive ../$(LIBNAME) --no-whole-archive
260	rm -f ../$(LIBNAME)
261	$(AR) -cq ../$(LIBNAME) goto.$(SUFFIX)
262	rm -f goto.$(SUFFIX)
263
264osx.def : gensymbol ../Makefile.system ../getarch.c
265	perl ./gensymbol osx $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
266
267aix.def : gensymbol ../Makefile.system ../getarch.c
268	perl ./gensymbol aix $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
269
270objcopy.def : gensymbol ../Makefile.system ../getarch.c
271	perl ./gensymbol objcopy $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
272
273objconv.def : gensymbol ../Makefile.system ../getarch.c
274	perl ./gensymbol objconv $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > $(@F)
275
276test : linktest.c
277	$(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) -lm && echo OK.
278	rm -f linktest
279
280linktest.c : gensymbol ../Makefile.system ../getarch.c
281	perl ./gensymbol linktest  $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) $(BUILD_BFLOAT16) $(BUILD_SINGLE) $(BUILD_DOUBLE) $(BUILD_COMPLEX) $(BUILD_COMPLEX16) > linktest.c
282
283clean ::
284	@rm -f *.def *.dylib __.SYMDEF* *.renamed
285
286include ../Makefile.tail
287
288
289