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