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
|
#!/usr/bin/make -f
export DH_VERBOSE=1
BUILDDIR=debian/build
BUILDDIR_FLANG=debian/build-flang
# The magic debhelper rule
%:
dh $@ --builddirectory=$(BUILDDIR)
DESTDIR=$(CURDIR)/debian/tmp/
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
LIBDIR:=/usr/lib/$(DEB_HOST_MULTIARCH)
# To enable all, uncomment following line
DEB_BUILD_MAINT_OPTIONS:= hardening=+all
DEB_CFLAGS_MAINT_APPEND:= -Wall -pedantic -fPIC
export DEB_BUILD_MAINT_OPTIONS
export DEB_CFLAGS_MAINT_APPEND DEB_CFLAGS_MAINT_APPEND
# FC set to f77 by default in make
# Read default compiler name unless FC is actually set
ifeq ($(F77),f77)
F77:=$(shell basename $(shell readlink /etc/alternatives/f77))
endif
DO_FLANG:=$(if $(wildcard /usr/bin/flang),true, false)
# Flang has problems with -g on some code
FFLAGS_FLANG:=$(shell dpkg-buildflags --get FFLAGS | sed -e 's/-g //')
FFLAGS_GFORTRAN:=$(shell dpkg-buildflags --get FFLAGS )
LIBDIR_GFORTRAN=$(LIBDIR)/fortran/$(shell basename $(shell readlink -f /usr/bin/gfortran))
LIBDIR_FLANG=$(LIBDIR)/fortran/$(shell basename $(shell readlink -f /usr/bin/flang))
ifneq ($(filter gfortran,$(F77)),)
CPPFLAGS += -DgFortran
endif
ifneq ($(filter flang,$(F77)),)
CPPFLAGS += -DflangFortran
endif
CPPFLAGS += -I/usr/include/cdTime
ARCH:=$(shell dpkg --print-architecture)
AS_NEEDED= -Wl,--as-needed
# On powerpc, amd64, arm*, don't do fPIE, only relro
ifeq ($(ARCH), amd64)
export LDFLAGS= -Wl,-z,relro -Wl,-z,now
endif
ifeq ($(ARCH), armel)
export LDFLAGS= -Wl,-z,relro -Wl,-z,now
export AS_NEEDED=
export CFLAGS= -g -O2 -Wall
endif
ifeq ($(ARCH), armhf)
export LDFLAGS= -Wl,-z,relro -Wl,-z,now
endif
ifeq ($(ARCH),powerpc)
export LDFLAGS= -Wl,-z,relro -Wl,-z,now
export AS_NEEDED=
export CFLAGS= -g -O2 -Wall
endif
ifneq ($(wildcard /usr/lib/$(DEB_HOST_MULTIARCH)/hdf5/serial/libhdf5.so),)
WITH_HDF5:=--with-hdf5=/usr/lib/$(DEB_HOST_MULTIARCH)/hdf5/serial
else
WITH_HDF5:=--with-hdf5=/usr
endif
ifeq ($(ARCH),hppa)
WITH_OPENMP:=--disable-openmp
else
WITH_OPENMP:=--enable-openmp
endif
BUILD_FLAGS = \
--prefix=/usr --libdir=$(LIBDIR) \
--enable-cdi-lib --with-zlib=/usr --with-netcdf=/usr --with-proj=/usr \
$(WITH_OPENMP) $(WITH_HDF5) \
--enable-iso-c-interface --with-fftw3 --with-curl=/usr --with-udunits2=/usr \
--with-szlib \
--with-libxml2=usr/ \
--with-eccodes=/usr --disable-cgribex --with-magics=/usr
override_dh_auto_clean:
dh_auto_clean || echo "distclean ok"
rm -rf debian/build debian/build-flang
override_dh_auto_configure:
ln -sf /usr/include/cfortran.h libcdi/src/cfortran.h
dh_auto_configure --builddirectory=$(BUILDDIR) -- \
FC=gfortran $(BUILD_FLAGS) \
LIBS="-lm -ljpeg -lz -lcurl" LDFLAGS="$(LDFLAGS) $(AS_NEEDED)"
$(DO_FLANG) && dh_auto_configure --builddirectory=$(BUILDDIR_FLANG) -- \
LIBS="-lm -ljpeg -lz -lcurl" LDFLAGS="$(LDFLAGS) $(AS_NEEDED)" \
FC=flang FFLAGS="$(FFLAGS_FLANG)" \
|| true
override_dh_auto_build:
dh_auto_build --builddirectory=$(BUILDDIR)
$(DO_FLANG) && $(MAKE) -C $(BUILDDIR_FLANG)/libcdi/src || true
# Ignore error here ; it mostly works
- (cd contrib && LC_ALL=C.UTF-8 ruby makecompl.rb )
override_dh_auto_install:
dh_auto_install
for d in debian/tmp/$(LIBDIR)/pkgconfig/cdi.pc $(BUILDDIR)/libcdi/src/pkgconfig/cdi_f2003.pc ; do \
sed -e 's%${CURDIR}%/build/cdo%g' < $$d > debian/tmp/x ; \
mv debian/tmp/x $$d ; \
done
$(DO_FLANG) && ( \
sed -e 's%${CURDIR}%/build/cdo%g' < $(BUILDDIR_FLANG)/libcdi/src/pkgconfig/cdi_f2003.pc > debian/tmp/x ; \
mv debian/tmp/x $(BUILDDIR_FLANG)/libcdi/src/pkgconfig/cdi_f2003.pc ) || true
mkdir -p $(DESTDIR)/usr/share/bash-completions/completions $(DESTDIR)//usr/share/zsh/functions/Completion/Linux
cp contrib/cdoCompletion.bash $(DESTDIR)/usr/share/bash-completions/completions/cdo
cp contrib/cdoCompletion.zsh $(DESTDIR)//usr/share/zsh/functions/Completion/Linux/_cdo
find $(DESTDIR) -name '*.la' -delete -o -name '*.so' -delete -o -name '*.so.0' -delete
mkdir -p $(DESTDIR)/$(LIBDIR)/fortran/gfortran
mv $(DESTDIR)/$(LIBDIR)/libcdi_f2003.so.0.0.0 $(DESTDIR)/$(LIBDIR)//libcdi_f2003-gfortran.so.0.0.0
mv $(DESTDIR)/$(LIBDIR)/libcdi_f2003.a $(DESTDIR)/$(LIBDIR)/fortran/gfortran
patchelf --set-soname libcdi_f2003-gfortran.so.0 $(DESTDIR)/$(LIBDIR)//libcdi_f2003-gfortran.so.0.0.0
$(DO_FLANG) && ( \
mkdir -p $(DESTDIR)/$(LIBDIR)/fortran/flang ; \
cp ./debian/build-flang/libcdi/src/.libs/libcdi_f2003.a $(DESTDIR)/$(LIBDIR)/fortran/flang ; \
) || true
override_dh_dwz:
@echo "DWZ currently breaks because of patchelf"
override_dh_auto_test:
# Need to define path to 'cdo' for python tests
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
export PATH=$(PATH):$(CURDIR)/src make check
endif
|