Haiku supporting patches
[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 ifneq (,$(filter 1 2,$(NOFORTRAN)))
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 ifneq (,$(filter 1 2,$(NOFORTRAN)))
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 Haiku))
126
127 so : ../$(LIBSONAME)
128
129 ifeq ($(OSNAME), Android)
130 INTERNALNAME = $(LIBPREFIX).so
131 FEXTRALIB += -lm
132 EXTRALIB += -lm
133 else
134 INTERNALNAME = $(LIBPREFIX).so.$(MAJOR_VERSION)
135 endif
136
137 ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
138 ../$(LIBSONAME) : ../$(LIBNAME) linktest.c
139 else
140 ../$(LIBNAME).renamed : ../$(LIBNAME) objcopy.def
141         $(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME) ../$(LIBNAME).renamed
142 ../$(LIBSONAME) : ../$(LIBNAME).renamed linktest.c
143 endif
144 ifneq ($(C_COMPILER), LSB)
145         $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
146         -Wl,--whole-archive $< -Wl,--no-whole-archive \
147         -Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
148         $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
149 else
150 #for LSB
151         env LSBCC_SHAREDLIBS=gfortran $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) \
152         -Wl,--whole-archive $< -Wl,--no-whole-archive \
153         -Wl,-soname,$(INTERNALNAME) $(EXTRALIB)
154         $(FC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
155 endif
156         rm -f linktest
157
158 endif
159
160 #http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
161 ifeq ($(OSNAME), $(filter $(OSNAME),FreeBSD OpenBSD NetBSD DragonFly))
162
163 so : ../$(LIBSONAME)
164
165 ifeq (, $(SYMBOLPREFIX)$(SYMBOLSUFFIX))
166 ../$(LIBSONAME) : ../$(LIBNAME) linktest.c
167 else
168 ../$(LIBNAME).renamed : ../$(LIBNAME) objcopy.def
169         $(OBJCOPY) --redefine-syms objcopy.def ../$(LIBNAME) ../$(LIBNAME).renamed
170 ../$(LIBSONAME) : ../$(LIBNAME).renamed linktest.c
171 endif
172         $(CC) $(CFLAGS) $(LDFLAGS)  -shared -o ../$(LIBSONAME) \
173         -Wl,--whole-archive $< -Wl,--no-whole-archive \
174         $(FEXTRALIB) $(EXTRALIB)
175         $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
176         rm -f linktest
177
178 endif
179
180 ifeq ($(OSNAME), OSF1)
181
182 so : ../$(LIBSONAME)
183
184 ../$(LIBSONAME) :
185         $(CC) $(CFLAGS) $(LDFLAGS) -shared -o ../$(LIBSONAME) ../$(LIBNAME)
186 endif
187
188 ifeq ($(OSNAME), SunOS)
189
190 so : ../$(LIBSONAME)
191         $(CC) $(CFLAGS) $(LDFLAGS)  -shared -o ../$(LIBSONAME) \
192         -Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(EXTRALIB)
193         $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
194         rm -f linktest
195
196 endif
197
198 ifeq ($(OSNAME), AIX)
199
200 ifeq ($(COMPILER_F77), xlf)
201
202 goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
203         ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lxlf90 -lc -lm  -lpthread
204
205 goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
206         ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lxlf90 -lc -lm -lpthread
207 else
208 goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
209         ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lg2c -lc -lm
210
211 goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
212         ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lg2c -lc -lm
213 endif
214 endif
215
216 static : ../$(LIBNAME)
217         $(LD) $(LDFLAGS) -r -o goto.$(SUFFIX) \
218         --whole-archive ../$(LIBNAME) --no-whole-archive
219         rm -f ../$(LIBNAME)
220         $(AR) -cq ../$(LIBNAME) goto.$(SUFFIX)
221         rm -f goto.$(SUFFIX)
222
223 osx.def : gensymbol ../Makefile.system ../getarch.c
224         perl ./gensymbol osx $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
225
226 aix.def : gensymbol ../Makefile.system ../getarch.c
227         perl ./gensymbol aix $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
228
229 objcopy.def : gensymbol ../Makefile.system ../getarch.c
230         perl ./gensymbol objcopy $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
231
232 objconv.def : gensymbol ../Makefile.system ../getarch.c
233         perl ./gensymbol objconv $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > $(@F)
234
235 test : linktest.c
236         $(CC) $(CFLAGS) $(LDFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) -lm && echo OK.
237         rm -f linktest
238
239 linktest.c : gensymbol ../Makefile.system ../getarch.c
240         perl ./gensymbol linktest  $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) $(NEED2UNDERSCORES) $(ONLY_CBLAS) "$(SYMBOLPREFIX)" "$(SYMBOLSUFFIX)" $(BUILD_LAPACK_DEPRECATED) > linktest.c
241
242 clean ::
243         @rm -f *.def *.dylib __.SYMDEF* *.renamed
244
245 include ../Makefile.tail
246
247