File: rules

package info (click to toggle)
blas 1.2.20110419-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,956 kB
  • ctags: 9,692
  • sloc: fortran: 34,951; ansic: 25,931; makefile: 635; sh: 47
file content (297 lines) | stat: -rwxr-xr-x 8,285 bytes parent folder | download
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

# xerblas_ and LAPACK_xerblas must be overrideable by applications
# --dynamic-list does not work with gold, so drop the flag completely
BUILDFLAGS_ENV:=DEB_LDFLAGS_MAINT_STRIP="-Wl,-Bsymbolic-functions"
LDFLAGS:=$(shell $(BUILDFLAGS_ENV) dpkg-buildflags --get LDFLAGS)

F77:=gfortran
FFLAGS:=$(shell dpkg-buildflags --get FFLAGS)

CC:=cc
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)

ARCH:=$(shell dpkg --print-architecture)
CPU:=$(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)

ifeq ($(ARCH),alpha)
  FFLAGS += -mieee
endif

# Necessary to avoid test failures
ifneq (,$(filter $(CPU),i386 m68k))
  FFLAGS_EXTRA := -ffloat-store
endif


SO=3
VERS=$(SO).0

VN:=$(shell pwd)
VO:=$(VN).orig
UD:=$(shell dirname $$(pwd))

PDF:=cinterface
PDD:=debian/patched-docs
PDP:=$(addprefix $(PDD)/,$(PDF))
PDS:=$(addsuffix .tex,$(PDP))
PDO:=$(addsuffix .pdf,$(PDP))

# Support parallel build                                                                                                                                                                
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))                                                                                                     
	MAKEFLAGS += -j$(NUMJOBS)                                                                                                                                                        
endif


# Rules for recreating the source tarball
# TODO: fix the rules and convert them to a get-orig-source rule

$(UD)/blas.tgz:
	mkdir -p $(@D)
	cd $(@D) && wget -N ftp://ftp.netlib.org/blas/$(@F)

$(UD)/cblas.tgz:
	mkdir -p $(@D)
	cd $(@D) && wget -N ftp://ftp.netlib.org/blas/blast-forum/$(@F)

$(UD)/manpages.tgz:
	mkdir -p $(@D)
	cd $(@D) && wget -N ftp://ftp.netlib.org/lapack/$(@F)

$(VO)/src: $(UD)/blas.tgz
	mkdir -p $@
	cd $@ && tar zxf $<

TF:=s d c z
TF:=$(addsuffix blat1,$(TF)) $(addsuffix blat2,$(TF)) $(addsuffix blat3,$(TF)) \
	$(addsuffix blat2d,$(TF)) $(addsuffix blat3d,$(TF))

$(addprefix $(VO)/test/,$(TF)):
	mkdir -p $(@D)
	cd $(@D) && wget -N ftp://ftp.netlib.org/blas/$(@F)

$(VO)/test: $(addprefix $(VO)/test/,$(TF))

$(VO)/man: $(UD)/manpages.tgz
	mkdir -p $(@D)
	cd $(VO) && tar zxf $< blas
	rm -rf $@
	mv $(VO)/blas/man $@
	rmdir $(VO)/blas

$(VO)/cblas: $(UD)/cblas.tgz
	cd $(VO) && tar zxf $<
	rm -rf $@
	mv $(VO)/CBLAS $@

DF:=faq.html 
$(addprefix $(VO)/doc/,$(DF)):
	mkdir -p $(@D)
	cd $(@D) && wget -N ftp://ftp.netlib.org/blas/$(@F)

$(VO)/doc/cinterface.pdf:
	mkdir -p $(@D)
	cd $(@D) && wget -N ftp://ftp.netlib.org/blas/blast-forum/$(@F)

$(VO)/doc/blue.gif:
	mkdir -p $(@D)
	cd $(@D) && wget -N ftp://ftp.netlib.org/scalapack/html/gif/$(@F)

%.png: %.gif
	gif2png $<

$(VO)/doc: $(addprefix $(VO)/doc/,$(DF)) $(VO)/doc/blue.png

ori: $(addprefix $(VO)/,src test man cblas doc)


# Compilation rules

BSRC:=$(shell echo src/*.f)
BOBJ:=$(BSRC:.f=.o)
BOBJ1:=$(filter-out src/izamax.o,$(filter-out src/icamax.o,$(BOBJ)))
BOBJ2:=src/icamax.o src/izamax.o

debian/shared_dir debian/static_dir debian/test_dir:
	mkdir -p $(subst _dir,,$(@))
	touch $@

$(subst src/,debian/static/,$(BOBJ1)): \
	debian/static/%.o : src/%.f debian/static_dir

	$(F77) $(FFLAGS) -c $< -o $@	

$(subst src/,debian/shared/,$(BOBJ1)): \
	debian/shared/%.o : src/%.f debian/shared_dir

	$(F77) $(FFLAGS) -fPIC -c $< -o $@	

$(subst src/,debian/static/,$(BOBJ2)): \
	debian/static/%.o : src/%.f debian/static_dir

	$(F77) $(FFLAGS) $(FFLAGS_EXTRA) -c $< -o $@	

$(subst src/,debian/shared/,$(BOBJ2)): \
	debian/shared/%.o : src/%.f debian/shared_dir

	$(F77) $(FFLAGS) $(FFLAGS_EXTRA) -fPIC -c $< -o $@	

libblas.a: cblas/libcblas.a $(subst src/,debian/static/,$(BOBJ)) debian/static_dir
	cd debian/static && ar x ../../$<
	ar r $@ debian/static/*.o

libblas.so.$(VERS): cblas/libcblas_pic.a $(subst src/,debian/shared/,$(BOBJ)) debian/shared_dir
	cd debian/shared && ar x ../../$<
	$(F77) $(LDFLAGS) -shared -Wl,-soname=libblas.so.$(SO) -o $@ debian/shared/*.o

libblas.so.$(SO): libblas.so.$(VERS)
	ln -snf $< $@

libblas.so: libblas.so.$(SO)
	ln -snf $< $@

cblas/Makefile.in: cblas/Makefile.LINUX
	cat $< | sed -e "s,^BLLIB = .*,BLLIB = -L $$(pwd) -lblas,1" \
		     -e "s,^CBDIR = .*,CBDIR = $$(pwd)/cblas,1" \
		     -e "s,^CC = .*,CC = $(CC) ,1" \
		     -e "s,^FC = .*,FC = $(F77) ,1" \
		     -e "s,^CFLAGS = .*,CFLAGS = $(CPPFLAGS) $(CFLAGS) \$$(PICOPTS) -DADD_,1" \
		     -e "s,^FFLAGS = .*,FFLAGS = $(FFLAGS) \$$(PICOPTS) ,1" \
			>$@
	echo "LOADFLAGS = $(LDFLAGS)" >>$@

cblas/libcblas.a: cblas/Makefile.in
	cd $(@D) && $(MAKE) cleanobj 
	cd $(@D) && $(MAKE) rmlib
	mkdir -p cblas/lib/LINUX
	cd $(@D) && $(MAKE) alllib
	cp cblas/lib/LINUX/cblas_LINUX.a $@

cblas/libcblas_pic.a: cblas/Makefile.in
	cd $(@D) && $(MAKE) cleanobj 
	cd $(@D) && $(MAKE) rmlib
	mkdir -p cblas/lib/LINUX
	cd $(@D) && $(MAKE) PICOPTS=-fPIC alllib
	cp cblas/lib/LINUX/cblas_LINUX.a $@

BIN:=s d c z
BIN:=$(addsuffix cblat1,$(BIN)) $(addsuffix cblat2,$(BIN)) $(addsuffix cblat3,$(BIN))
BIN:=$(addprefix cblas/testing/x,$(BIN))

$(BIN): libblas.so
	cd cblas && $(MAKE) alltst CBLIB= FFLAGS="$(FFLAGS) $(FFLAGS_EXTRA)"

FBN:=s d c z
FBN:=$(addsuffix blat1,$(FBN)) $(addsuffix blat2,$(FBN)) $(addsuffix blat3,$(FBN))
FBN:=$(addprefix test/x,$(FBN))

test/%.f: test/%
	cp $< $@

test/x%: test/%.f libblas.so 
	$(F77) $(FFLAGS) $(FFLAGS_EXTRA) $(LDFLAGS) -o $@ $< -L $$(pwd) -lblas

OUT:=$(subst cblas/testing/,debian/test/,$(BIN))
OUT1:=$(filter %1,$(OUT))
OUT23:=$(filter-out %1,$(OUT))

$(OUT1): \
	debian/test/%: cblas/testing/% debian/test_dir libblas.so
	LD_LIBRARY_PATH=$$(pwd):$$LD_LIBRARY_PATH $< > $@
	awk '/fail/ || /FAIL/ {exit 1}' $@ || (cat $@ && false)

$(OUT23): \
	debian/test/%: cblas/testing/% debian/test_dir libblas.so
	LD_LIBRARY_PATH=$$(pwd):$$LD_LIBRARY_PATH $< \
		< cblas/testing/$(subst x,,$(subst cblat,in,$*)) > $@
	awk '/fail/ || /FAIL/ {exit 1}' $@ || (cat $@ && false)

FOT:=$(subst test/,debian/test/,$(FBN))
FOT1:=$(filter %1,$(FOT))
FOT23:=$(filter-out %1,$(FOT))

$(FOT1): \
	debian/test/%: test/% debian/test_dir libblas.so
	LD_LIBRARY_PATH=$$(pwd):$$LD_LIBRARY_PATH $< > $@
	awk '/fail/ || /FAIL/ {exit 1}' $@ || (cat $@ && false)

$(FOT23): \
	debian/test/%: test/% debian/test_dir libblas.so
	rm -f *.SUMM
	LD_LIBRARY_PATH=$$(pwd):$$LD_LIBRARY_PATH $< \
		< test/$(subst x,,$*)d
	cat *.SUMM >$@
	awk '/fail/ || /FAIL/ {exit 1}' $@ || (cat $@ && false)

debian/test_results: $(OUT) $(FOT)
	cat $^ > $@
	cat $@ | awk '/fail/ || /FAIL/ {exit 1}'

MFL:=$(shell echo man/manl/*)
%.3: %.l
	cat $< | sed "s,^.TH  *\([^ ]*\)  *l  *\(.*\),.TH \1 3 \2,1" >$@
	echo Converted $< to $@, diff: 
	diff -u $< $@ || true
MF:=$(subst .l,.3,$(MFL))

$(PDO): %.pdf: %.tex
	cd $(@D) && pdflatex $(<F) && pdflatex $(<F)

debian/blas-netlib.pc: debian/blas-netlib.pc.in
	sed -e "s%@DEB_VERSION_UPSTREAM@%$(DEB_VERSION_UPSTREAM)%" < $< > $@


# Packaging rules

%:
	dh $@ --parallel

override_dh_auto_build-arch: libblas.so libblas.a $(BIN) $(FBN) debian/blas-netlib.pc

override_dh_auto_build-indep: $(MF) $(PDO)

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test-arch: debian/test_results
else
override_dh_auto_test-arch:
	touch debian/test_results
endif

override_dh_auto_clean: cblas/Makefile.in
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -f debian/static/* debian/shared/* test/x* test/*.f libblas* cblas/libcblas* man/manl/*.3
	rm -f *SUMM
	rm -rf debian/test* debian/shared* debian/static*
	cd $(PDD) && rm -rf *.pdf *.log *.aux *.ps *.dvi
	rm -f debian/blas-netlib.pc

	-rm -rf static shared
	cd cblas && $(MAKE) clean && $(MAKE) rmlib
	rm -f $<

override_dh_installman-indep:
	dh_installman -p libblas-doc man/manl/*.3

override_dh_installman-arch:
	dh_installman -p libblas-test debian/*.1

override_dh_makeshlibs:
	dh_makeshlibs -a -V "libblas3 | libblas.so.3" -n

override_dh_shlibdeps:
	dh_shlibdeps -a -l $$(pwd)


.PHONY: $(addprefix $(UD)/,blas.tgz cblas.tgz manpages.tgz)
.SUFFIXES:
.INTERMEDIATE: $(VO)/doc/blue.gif

# This Makefile must be run serially (because non-PIC and PIC versions must be
# built sequentially), but the sub-makes can still be parallelized
.NOTPARALLEL: