File: rules

package info (click to toggle)
eccodes 2.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 480,184 kB
  • sloc: ansic: 163,815; makefile: 21,266; sh: 8,507; python: 6,026; f90: 5,762; perl: 2,891; yacc: 818; lex: 356; cpp: 305; fortran: 116; awk: 66
file content (143 lines) | stat: -rwxr-xr-x 6,097 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
#!/usr/bin/make -f

export DH_VERBOSE=1

include /usr/share/dpkg/pkg-info.mk
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
INCDIR=/usr/include/$(DEB_HOST_MULTIARCH)
BUILDDIR=$(CURDIR)/debian/build
DESTDIR=$(CURDIR)/debian/tmp

# For hardening
CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS) #  -fPIC
CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)


export LDFLAGS CFLAGS CPPFLAGS CXXFLAGS

PY3VERS:=$(shell py3versions -s)
PY3VERSD:=/usr/bin/$(shell py3versions -d)

# Don't do OMP_THREADS on some archs
OMP_THREADS:= On

# Don't test on mips. will time out most of the time on low-powered archs
DO_TEST:=true
ARCH:=$(shell dpkg --print-architecture)
ifeq ($(ARCH), mips)
DO_TEST:=false
endif
ifeq ($(ARCH),hppa)
DO_TEST:=false
OMP_THREADS:=Off
endif

BUILD_FLAGS =  \
	-DCMAKE_BUILD_TYPE=Release \
	-DDISABLE_OS_CHECK=ON \
	-DENABLE_INSTALL_ECCODES_DEFINITIONS=ON \
	-DENABLE_INSTALL_ECCODES_SAMPLES=ON \
	-DENABLE_PNG=ON \
	-DENABLE_AEC=ON \
	-DENABLE_RPATHS=OFF \
	-DENABLE_RELATIVE_RPATHS=OFF \
	-DHAVE_BIT_REPRODUCIBLE=ON \
	-DCMAKE_C_CFLAGS="${CFLAGS} ${LDFLAGS}" \
	-DENABLE_ALIGN_MEMORY=ON \
	-DENABLE_GRIB_TIMER=ON \
	-DENABLE_ECCODES_OMP_THREADS=$(OMP_THREADS) \
	-DENABLE_PYTHON=ON 

%:
	dh $@ --buildsystem=cmake --with=python3,fortran_mod --builddirectory=${BUILDDIR} --no-parallel

override_dh_auto_configure:
	dh_auto_configure -- \
	    ${BUILD_FLAGS} -DPYTHON_EXECUTABLE=$(PY3VERSD)
	( cd ${BUILDDIR}/data ; tar axpf $(CURDIR)/../eccodes_$(DEB_VERSION_UPSTREAM).orig-data.tar.xz )
	( cd python ; swig -python -module gribapi_swig -o swig_wrap_numpy.c gribapi_swig.i )

override_dh_install:
	# Hack for multiple pythons with CMake structure
	cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(DESTDIR)
	dh_auto_configure --  ${CMAKE_CFLAGS} -DPYTHON_EXECUTABLE=$(PY3VERSD)
	( cd python ; swig -python -module gribapi_swig -o swig_wrap_numpy.c gribapi_swig.i )
	cd $(BUILDDIR) && $(MAKE) install DESTDIR=$(DESTDIR)  
	# Move to multiarch dir
	mkdir -p debian/tmp/${LIBDIR} debian/tmp/${INCDIR}
	mv debian/tmp/usr/include/*.h debian/tmp/${INCDIR}
	mv debian/tmp/usr/include/*.mod debian/tmp/${INCDIR}
	cp -a debian/tmp/usr/lib/lib* debian/tmp/${LIBDIR}
	cp -a debian/tmp/usr/lib/pkgconfig debian/tmp/${LIBDIR}
	for d in libeccodes_f90.so	libeccodes.so ; do \
		cp debian/tmp/$(LIBDIR)/$$d.0 debian/tmp/$(LIBDIR)/$$d.0.0.0 ; \
		chrpath -d debian/tmp/$(LIBDIR)/$$d.0.0.0 ; done
	dh_link -p libeccodes0 $(LIBDIR)/libeccodes.so.0.0.0  $(LIBDIR)/libeccodes.so.0
	dh_link -p libeccodes0 $(LIBDIR)/libeccodes_f90.so.0.0.0  $(LIBDIR)/libeccodes_f90.so.0
	dh_link -p libeccodes-dev $(LIBDIR)/libeccodes.so.0.0.0 $(LIBDIR)/libeccodes.so
	dh_link -p libeccodes-dev $(LIBDIR)/libeccodes_f90.so.0.0.0 $(LIBDIR)/libeccodes_f90.so
	for py in $(PY3VERS); do \
		(cd debian/build/python3 && $$py ./setup.py install --prefix=$(CURDIR)/debian/tmp/usr ) ; \
		done
	chrpath -d ./debian/tmp/usr/lib/python*/site-packages/gribapi/*.so
	for d in debian/tmp/usr/bin/* ; do \
		( chrpath -d $$d || echo "Ignoring chrpath error for non-ELF $d" ); \
		done
	dh_numpy3
	dh_install
	#
	# Setup cmake files for magics++, metview, etc.
	#
	mkdir -p debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes
	cp debian/tmp/usr/share/eccodes/cmake/* debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes
	sed -e 's%$${_IMPORT_PREFIX}/lib%${LIBDIR}%g' \
		< debian/tmp/usr/share/eccodes/cmake/eccodes-targets-none.cmake  | \
	sed -e 's%$${_IMPORT_PREFIX}/bin%/usr/bin%g' \
		> debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes/eccodes-targets-none.cmake
	sed -e 's%$${_IMPORT_PREFIX}%/usr%' \
	       < debian/tmp/usr/share/eccodes/cmake/eccodes-targets-release.cmake | \
	sed -e 's%-l${PY3VERSD} %%g' | \
	sed -e 's%/usr/lib/libeccodes%${LIBDIR}/libeccodes%' | \
	sed -e 's%${LIBDIR}/libopenjpeg.so;%%' | sed -e 's%;${LIBDIR}/libpng.so%%g' \
	      > debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes/eccodes-targets-release.cmake
	sed -e 's%;${LIBDIR}/libopenjpeg.so%%g' \
		< debian/tmp/usr/share/eccodes/cmake/eccodes-config.cmake | \
	sed -e 's%-l${PY3VERSD} %%g' | \
	sed -s 's%/usr/include/${PY3VERSD};%%g' | sed -e 's%/usr/include/python2.7;%%g' | \
	sed -e 's%;${LIBDIR}/libpng.so%%g' \
		> debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes/eccodes-config.cmake
	# For bit-reproducibility, sanitize the build paths
	for f in eccodes-config.cmake eccodes-import.cmake ; do \
		sed -e 's%${CURDIR}%/build/eccodes%g' < debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes/$$f \
		> debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes/x; \
		mv debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes/x debian/libeccodes-dev/$(LIBDIR)/cmake/eccodes/$$f ; \
		done
	# file exists on full builds only
	[ - e debian/libeccodes-dev/$(INCDIR)/eccodes_ecbuild_config.h ] && ( \
		sed -e 's%${CURDIR}%/build/eccodes%g' < debian/libeccodes-dev/$(INCDIR)/eccodes_ecbuild_config.h \
			> debian/libeccodes-dev/$(INCDIR)/x ; \
		mv debian/libeccodes-dev/$(INCDIR)/x debian/libeccodes-dev/$(INCDIR)/eccodes_ecbuild_config.h ) || true

override_dh_auto_clean:
	dh_auto_clean
	# Things that upstream leaves behind
	find . -name '*.pyc' -delete
	rm -f configure.ac configure configure.in
	rm -f tests/bitmap.rules tests/out.grib1 tests/out.grib2 tests/out.gribidx \
	      tests/rules tests/simple_ieee_test.grib1.txt tests/statistics.filter \
	      tests/statistics.out tests/x.grib \
	      data/change_scanning_rotated_ll.filter examples/F90/index.idx

override_dh_fixperms:
	dh_fixperms
	test -e /usr/bin/dh_buildinfo && dh_buildinfo
	-chmod -x debian/libeccodes-dev/usr/share/doc/libeccodes-dev/examples/F90/include.sh
	-chmod +x debian/libeccodes-data/usr/share/eccodes/definitions/installDefinitions.sh
	rm -f debian/libeccodes-doc/usr/share/doc/libeccodes-doc/html/jquery.js
	-ln -s ../../../javascript/jquery/jquery.js debian/libeccodes-doc/usr/share/doc/libeccodes-doc/html/jquery.js

override_dh_auto_test:
	$(DO_TEST) && ( LD_LIBRARY_PATH=$(CURDIR)/debian/build/lib dh_auto_test  ) || true