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