File: rules

package info (click to toggle)
blis 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 41,224 kB
  • sloc: ansic: 367,246; fortran: 21,763; sh: 7,912; cpp: 6,979; makefile: 1,615; asm: 1,480; python: 602
file content (209 lines) | stat: -rwxr-xr-x 9,169 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
#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export PYTHON=/usr/bin/python3  # for the upstream build system

# Select target architecture
# armhf: upstream's armv7a kernel assumes NEON. Using generic kernels currently.
CONFIG_amd64      = x86_64
CONFIG_arm64      = cortexa57
CONFIG_ppc64el    = generic
CONFIG_kfreebsd-amd64 = x86_64
CONFIG            = $(word 1, $(CONFIG_$(DEB_HOST_ARCH)) generic)

# Update-Alternatives Priority Settings
UAPRI_O = 80
UAPRI_P = 75
UAPRI_S = 70

# SOVERSION (Following upstream)
SOVER := 4

# Threading + Indexing Flavours
ifneq (,$(filter $(DEB_HOST_ARCH), amd64 kfreebsd-amd64 arm64 mips64el ppc64el s390x ppc64 riscv64 sparc64))
FLAVORS := $(SOVER)-openmp $(SOVER)-pthread $(SOVER)-serial 64-$(SOVER)-openmp 64-$(SOVER)-pthread 64-$(SOVER)-serial
else
FLAVORS := $(SOVER)-openmp $(SOVER)-pthread $(SOVER)-serial
endif

# Common flags for every variant
FLAGS := \
	--enable-verbose-make \
	--prefix=/usr \
	--enable-cblas \
	--enable-static \
	--enable-shared \
	--libdir=/usr/lib/$(DEB_HOST_MULTIARCH)

# FLAG Tweaks
export CFLAGS = $(filter-out -O2, $(shell dpkg-buildflags --get CFLAGS)) \
               $(shell dpkg-buildflags --get CPPFLAGS)

##
SRCS := $(filter-out debian $(FLAVORS), $(wildcard ./*))

##


%:
	dh $@ -Smakefile

create_symlinks:
	# BLIS/BLAS
	set -e; cd debian; for j in openmp pthread serial; do \
		ln -sr libblis$(SOVER)-XXX.symbols.generic libblis$(SOVER)-$$j.symbols ;\
		for i in kfreebsd-amd64 amd64 arm64; do  \
			ln -sr libblis$(SOVER)-XXX.symbols.$$i libblis$(SOVER)-$$j.symbols.$$i ;\
		done;\
		for i in i386 x32; do \
			ln -sr libblis$(SOVER)-XXX.symbols.i386 libblis$(SOVER)-$$j.symbols.$$i ;\
		done;\
	done;
	# BLIS64/BLAS64
	set -e; cd debian; for j in openmp pthread serial; do \
		ln -sr libblis64-$(SOVER)-XXX.symbols.generic libblis64-$(SOVER)-$$j.symbols ;\
		for i in kfreebsd-amd64 amd64 arm64; do \
			ln -sr libblis64-$(SOVER)-XXX.symbols.$$i libblis64-$(SOVER)-$$j.symbols.$$i ;\
		done;\
	done;

config_%:
	# Generate maintainer scripts from templates
	set -e; cd debian; if test -z "$$(echo $* | grep 64)"; then \
		cp libblis$(SOVER)-XXX.postinst     libblis$*.postinst; \
		cp libblis$(SOVER)-XXX.prerm        libblis$*.prerm; \
		cp libblis-XXX-dev.postinst  libblis$(subst $(SOVER),,$*)-dev.postinst; \
		cp libblis-XXX-dev.prerm     libblis$(subst $(SOVER),,$*)-dev.prerm; \
		for SCRIPT in libblis$*.postinst libblis$*.prerm \
			libblis$(subst $(SOVER),,$*)-dev.postinst \
			libblis$(subst $(SOVER),,$*)-dev.prerm; do \
			sed -i -e "s/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g" \
				-e "s/@SUBDIR@/blis$(subst $(SOVER),,$*)/g" \
				-e "s/@SOVER@/$(SOVER)/g" \
				$$SCRIPT; \
			if test -n "$$(echo $* | grep openmp)"; then \
				sed -i -e "s/@BLIS_PRI@/$(UAPRI_O)/g" $$SCRIPT; \
			elif test -n "$$(echo $* | grep pthread)"; then \
				sed -i -e "s/@BLIS_PRI@/$(UAPRI_P)/g" $$SCRIPT; \
			else \
				sed -i -e "s/@BLIS_PRI@/$(UAPRI_S)/g" $$SCRIPT; \
			fi; \
		done; \
	else \
		cp libblis64-$(SOVER)-XXX.postinst     libblis$*.postinst; \
		cp libblis64-$(SOVER)-XXX.prerm        libblis$*.prerm; \
		cp libblis64-XXX-dev.postinst   libblis$(subst -$(SOVER)-,-,$*)-dev.postinst; \
		cp libblis64-XXX-dev.prerm      libblis$(subst -$(SOVER)-,-,$*)-dev.prerm; \
		for SCRIPT in libblis$*.postinst libblis$*.prerm \
			libblis$(subst -$(SOVER)-,-,$*)-dev.postinst \
			libblis$(subst -$(SOVER)-,-,$*)-dev.prerm; do \
			sed -i -e "s/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g" \
				-e "s/@SUBDIR@/blis$(subst -$(SOVER)-,-,$*)/g" \
				-e "s/@SOVER@/$(SOVER)/g" \
				$$SCRIPT; \
			if test -n "$$(echo $* | grep openmp)"; then \
				sed -i -e "s/@BLIS_PRI@/$(UAPRI_O)/g" $$SCRIPT; \
			elif test -n "$$(echo $* | grep pthread)"; then \
				sed -i -e "s/@BLIS_PRI@/$(UAPRI_P)/g" $$SCRIPT; \
			else \
				sed -i -e "s/@BLIS_PRI@/$(UAPRI_S)/g" $$SCRIPT; \
			fi; \
		done; \
	fi;
	# Run upstream configure script in duplicated source root directories
	mkdir $*
	cp -r $(SRCS) $*/
	set -e; cd $*; if test -z "$$(echo $* | grep 64)"; then \
		if test -z "$$(echo $* | grep serial)"; then \
			./configure $(FLAGS) -t $(subst $(SOVER)-,,$*) $(CONFIG); \
		else \
			./configure $(FLAGS) --disable-threading $(CONFIG); \
		fi; \
		echo "$*/usr/lib/*/libblis.so.* usr/lib/$(DEB_HOST_MULTIARCH)/" > \
			debian/libblis$*.install; \
	else \
		if test -z "$$(echo $* | grep serial)"; then \
			./configure $(FLAGS) -b 64 -i 64 -t $(subst 64-$(SOVER)-,,$*) $(CONFIG); \
		else \
			./configure $(FLAGS) -b 64 -i 64 --disable-threading $(CONFIG); \
		fi; \
		echo "$*/usr/lib/*/libblis64.so.* usr/lib/$(DEB_HOST_MULTIARCH)/" > \
			debian/libblis$*.install; \
	fi;

override_dh_auto_configure: $(addprefix config_, $(FLAVORS)) create_symlinks
	:

build_%:
	set -e; if test -n "$$(echo $* | grep 64)"; then \
		dh_auto_build -B$* -- DEB_LIBBLAS=libblas64.so.3 LIBBLIS=libblis64 ; \
	else \
		dh_auto_build -B$* -- DEB_LIBBLAS=libblas.so.3; \
	fi;

override_dh_auto_build: $(addprefix build_, $(FLAVORS))
	:

test_%:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -e; if test -n "$$(echo $* | grep 64)"; then \
		$(MAKE) -C$* check LIBBLIS=libblis64; \
	else \
		$(MAKE) -C$* check; \
	fi;
else
	true  # Or Make won't be able to find the test_% target.
endif

ifeq (,$(filter hurd-i386,$(DEB_HOST_ARCH)))
override_dh_auto_test: $(addprefix test_, $(FLAVORS))
	:
else
override_dh_auto_test:
	:
endif

install_%:
	# Don't use the debian/tmp directory
	-$(RM) -rf debian/tmp/*
	# In case we forgot to compile something
	-set -e; if test -n "$$(echo $* | grep 64)"; then \
		dh_auto_install -B$* -- LIBBLIS=libblis64; \
	else \
		dh_auto_install -B$*; \
	fi;
	# Don't use the debian/tmp directory
	-$(RM) -rf debian/tmp/*

	# Install things manually
	set -e; if test -z "$$(echo $* | grep 64)"; then \
		install -Dm0644 $*/lib/*/libblis.so     debian/libblis$*/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst $(SOVER),,$*)/libblis.so.$(SOVER) ;\
		install -Dm0644 $*/lib/*/libblas.so.3   debian/libblis$*/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst $(SOVER),,$*)/libblas.so.3 ;\
		ln -s libblas.so.3                      debian/libblis$*/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst $(SOVER),,$*)/libblas.so ;\
		install -Dm0644 $*/lib/*/libblis.a      debian/libblis$(subst $(SOVER),,$*)-dev/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst $(SOVER),,$*)/libblis.a ;\
		ln -s libblis.so.$(SOVER)               debian/libblis$(subst $(SOVER),,$*)-dev/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst $(SOVER),,$*)/libblis.so ;\
		install -Dm0644 $*/include/*/blis.h     debian/libblis$(subst $(SOVER),,$*)-dev/usr/include/$(DEB_HOST_MULTIARCH)/blis$(subst $(SOVER),,$*)/blis.h ;\
		install -Dm0644 $*/include/*/cblas.h    debian/libblis$(subst $(SOVER),,$*)-dev/usr/include/$(DEB_HOST_MULTIARCH)/blis$(subst $(SOVER),,$*)/cblas.h ;\
		mkdir -p            debian/libblis$(subst $(SOVER),,$*)-dev/usr/share/blis$(subst $(SOVER),,$*)-$(DEB_HOST_MULTIARCH)/config/$(CONFIG)/;\
		cp -v $*/common.mk  debian/libblis$(subst $(SOVER),,$*)-dev/usr/share/blis$(subst $(SOVER),,$*)-$(DEB_HOST_MULTIARCH)/;\
		cp -v $*/config.mk  debian/libblis$(subst $(SOVER),,$*)-dev/usr/share/blis$(subst $(SOVER),,$*)-$(DEB_HOST_MULTIARCH)/;\
		cp -v config/$(CONFIG)/make_defs.mk debian/libblis$(subst $(SOVER),,$*)-dev/usr/share/blis$(subst $(SOVER),,$*)-$(DEB_HOST_MULTIARCH)/config/$(CONFIG)/;\
	else \
		install -Dm0644 $*/lib/*/libblis64.so   debian/libblis$*/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst -$(SOVER)-,-,$*)/libblis64.so.$(SOVER) ;\
		install -Dm0644 $*/lib/*/libblas64.so.3 debian/libblis$*/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst -$(SOVER)-,-,$*)/libblas64.so.3 ;\
		ln -s libblas64.so.3                    debian/libblis$*/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst -$(SOVER)-,-,$*)/libblas64.so ;\
		install -Dm0644 $*/lib/*/libblis64.a    debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst -$(SOVER)-,-,$*)/libblis64.a ;\
		ln -s libblis64.so.$(SOVER)             debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/lib/$(DEB_HOST_MULTIARCH)/blis$(subst -$(SOVER)-,-,$*)/libblis64.so ;\
		install -Dm0644 $*/include/*/blis.h     debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/include/$(DEB_HOST_MULTIARCH)/blis$(subst -$(SOVER)-,-,$*)/blis64.h ;\
		install -Dm0644 $*/include/*/cblas.h    debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/include/$(DEB_HOST_MULTIARCH)/blis$(subst -$(SOVER)-,-,$*)/cblas64.h ;\
		mkdir -p            debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/share/blis$(subst -$(SOVER)-,-,$*)-$(DEB_HOST_MULTIARCH)/config/$(CONFIG)/;\
		cp -v $*/common.mk  debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/share/blis$(subst -$(SOVER)-,-,$*)-$(DEB_HOST_MULTIARCH);\
		cp -v $*/config.mk  debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/share/blis$(subst -$(SOVER)-,-,$*)-$(DEB_HOST_MULTIARCH);\
		cp -v config/$(CONFIG)/make_defs.mk debian/libblis$(subst -$(SOVER)-,-,$*)-dev/usr/share/blis$(subst -$(SOVER)-,-,$*)-$(DEB_HOST_MULTIARCH)/config/$(CONFIG)/;\
	fi;

override_dh_auto_install: $(addprefix install_, $(FLAVORS))
	# Don't use the debian/tmp directory
	-$(RM) -rf debian/tmp/*

override_dh_dwz:
	dh_dwz --no-dwz-multifile