summaryrefslogtreecommitdiff
path: root/exports/Makefile
blob: 6502d5d01f9136e33edf7c068ed5d830f32ba2bd (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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
TOPDIR	= ..

include ../Makefile.system

ifndef EXPRECISION
EXPRECISION	= 0
endif

ifndef NO_CBLAS
NO_CBLAS	= 0
endif

ifndef NO_LAPACK
NO_LAPACK	= 0
endif

ifndef NO_LAPACKE
NO_LAPACKE	= 0
endif

ifeq ($(OSNAME), WINNT)
ifeq ($(F_COMPILER), GFORTRAN)
EXTRALIB += -lgfortran
endif
ifeq ($(USE_OPENMP), 1)
ifeq ($(C_COMPILER), GCC)
EXTRALIB += -lgomp
endif
endif
endif

ifeq ($(OSNAME), CYGWIN_NT)
ifeq ($(F_COMPILER), GFORTRAN)
EXTRALIB += -lgfortran
endif
endif

all::

libs::

prof::

hpl:: libgoto_hpl.$(LIBSUFFIX)

hpl_p:: libgoto_hpl_p.$(LIBSUFFIX)

libgoto_hpl.$(LIBSUFFIX) : ../$(LIBNAME)
	rm -f $(@F)
	$(LD) -r $(LDFLAGS) -o goto.$(SUFFIX) --whole-archive $< --no-whole-archive
	$(AR) cq $(@F) goto.$(SUFFIX)
	$(RANLIB) libgoto_hpl.$(LIBSUFFIX)

libgoto_hpl_p.$(LIBSUFFIX) :  ../$(LIBNAME_P)
	rm -f $(@F)
	$(LD) -r  $(LDFLAGS) -o goto.$(PSUFFIX)  --whole-archive $< --no-whole-archive
	$(AR) cq $(@F) goto.$(PSUFFIX)
	$(RANLIB) libgoto_hpl_p.$(LIBSUFFIX)

libgoto_hpl.dll : libgoto_hpl.$(LIBSUFFIX) dllinit.$(SUFFIX) libgoto_hpl.def
	$(DLLWRAP) -o $(@F) --def libgoto_hpl.def --entry _dllinit -s dllinit.$(SUFFIX) --dllname libgoto_hpl.dll libgoto_hpl.$(LIBSUFFIX)
	lib /machine:X64 /def:libgoto_hpl.def

dyn : $(LIBDYNNAME)

zip : dll
	zip $(LIBZIPNAME) $(LIBDLLNAME) $(LIBNAME)

dll  : ../$(LIBDLLNAME)
#libgoto2.dll

dll2 : libgoto2_shared.dll

# On Windows, we only generate a DLL without a version suffix.  This is because
# applications which link against the dynamic library reference a fixed DLL name
# in their import table.  By instead using a stable name it is possible to
# upgrade between library versions, without needing to re-link an application.
# For more details see: https://github.com/xianyi/OpenBLAS/issues/127.
../$(LIBDLLNAME) : ../$(LIBNAME) libopenblas.def dllinit.$(SUFFIX)
	$(RANLIB) ../$(LIBNAME)
ifeq ($(BINARY32), 1)
	$(DLLWRAP) -o ../$(LIBDLLNAME) --def libopenblas.def \
	--entry _dllinit@12 -s dllinit.$(SUFFIX) --dllname $(@F) ../$(LIBNAME) $(EXTRALIB)
	-lib /machine:i386 /def:libopenblas.def
else
	$(DLLWRAP) -o ../$(LIBDLLNAME) --def libopenblas.def \
	--entry $(FU)dllinit    -s dllinit.$(SUFFIX) --dllname $(@F) ../$(LIBNAME) $(EXTRALIB)
	-lib /machine:X64 /def:libopenblas.def 
endif

libgoto2_shared.dll : ../$(LIBNAME) libgoto2_shared.def
	$(CC) $(CFLAGS) libgoto2_shared.def -shared -o $(@F) \
	-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive \
	-Wl,--out-implib,libgoto2_shared.lib $(FEXTRALIB)

libopenblas.def : gensymbol
	perl ./gensymbol win2k    $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) > $(@F)

libgoto2_shared.def : gensymbol
	perl ./gensymbol win2k    $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) > $(@F)

libgoto_hpl.def : gensymbol
	perl ./gensymbol win2khpl $(ARCH) dummy $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) > $(@F)

$(LIBDYNNAME) : ../$(LIBNAME) osx.def
	$(CC) $(CFLAGS) -all_load -headerpad_max_install_names -install_name $(CURDIR)/../$(LIBDYNNAME) -dynamiclib -o ../$(LIBDYNNAME) $< -Wl,-exported_symbols_list,osx.def  $(FEXTRALIB)

symbol.$(SUFFIX) : symbol.S
	$(CC) $(CFLAGS) -c -o $(@F) $^

dllinit.$(SUFFIX) : dllinit.c
	$(CC) $(CFLAGS) -c -o $(@F) -s $<

ifeq ($(OSNAME), Linux)

so : ../$(LIBSONAME)

../$(LIBSONAME) : ../$(LIBNAME) linux.def linktest.c
	$(CC) $(CFLAGS) -shared -o ../$(LIBSONAME) \
	-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive \
	-Wl,--retain-symbols-file=linux.def -Wl,-soname,$(LIBPREFIX).so.$(MAJOR_VERSION) $(EXTRALIB)
ifneq ($(C_COMPILER), LSB)
	$(CC) $(CFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
else
#Use FC on LSB
	$(FC) $(FFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
endif
	rm -f linktest

endif

#http://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or
ifeq ($(OSNAME), $(filter $(OSNAME),FreeBSD NetBSD))

so : ../$(LIBSONAME)

../$(LIBSONAME) : ../$(LIBNAME) linux.def linktest.c
	$(CC) $(CFLAGS)  -shared -o ../$(LIBSONAME) \
	-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive \
	-Wl,--retain-symbols-file=linux.def $(FEXTRALIB) $(EXTRALIB)
	$(CC) $(CFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
	rm -f linktest

endif

ifeq ($(OSNAME), OSF1)

so : ../$(LIBSONAME)

../$(LIBSONAME) :
	$(CC) -shared -o ../$(LIBSONAME) ../$(LIBNAME)
endif

ifeq ($(OSNAME), SunOS)

so : ../$(LIBSONAME)
	$(CC) $(CFLAGS)  -shared -o ../$(LIBSONAME) \
	-Wl,--whole-archive ../$(LIBNAME) -Wl,--no-whole-archive $(EXTRALIB)
	$(CC) $(CFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) $(FEXTRALIB) && echo OK.
	rm -f linktest

endif

ifeq ($(OSNAME), AIX)

ifeq ($(COMPILER_F77), xlf)

goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
	ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lxlf90 -lc -lm  -lpthread

goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
	ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lxlf90 -lc -lm -lpthread
else
goto32.$(SUFFIX) : ../$(LIBNAME) aix.def
	ld -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib -lg2c -lc -lm 

goto64.$(SUFFIX) : ../$(LIBNAME) aix.def
	ld -b64 -o $(@F) ../$(LIBNAME) -bE:aix.def -bM:SRE -bnoexpall -bnoentry -L$(HOME)/misc/lib/ppc64 -lg2c -lc -lm 
endif
endif

static : ../$(LIBNAME)
	$(LD) $(LDFLAGS) -r -o goto.$(SUFFIX) \
	--whole-archive ../$(LIBNAME) --no-whole-archive
	rm -f ../$(LIBNAME)
	$(AR) -cq ../$(LIBNAME) goto.$(SUFFIX)
	rm -f goto.$(SUFFIX)

linux.def : gensymbol ../Makefile.system ../getarch.c
	perl ./gensymbol linux $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) > $(@F)

osx.def : gensymbol ../Makefile.system ../getarch.c
	perl ./gensymbol osx $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) > $(@F)

aix.def : gensymbol ../Makefile.system ../getarch.c
	perl ./gensymbol aix $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) > $(@F)

symbol.S : gensymbol
	perl ./gensymbol win2kasm noarch dummy $(EXPRECISION) $(NO_CBLAS)  $(NO_LAPACK) $(NO_LAPACKE) > symbol.S

test : linktest.c
	$(CC) $(CFLAGS) -w -o linktest linktest.c ../$(LIBSONAME) -lm && echo OK.
	rm -f linktest

linktest.c : gensymbol ../Makefile.system ../getarch.c
	perl ./gensymbol linktest  $(ARCH) $(BU) $(EXPRECISION) $(NO_CBLAS) $(NO_LAPACK) $(NO_LAPACKE) > linktest.c

clean ::
	@rm -f *.def *.dylib __.SYMDEF*

include ../Makefile.tail