rules 4.54 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


# main packaging script based on dh7 syntax
%:
22
	dh $@ --parallel --with=python3
23

24
25
26
# Find the LTO plugin, which we need to pass to ar, nm, and ranlib.
LTOPLUG := $(shell gcc -v 2>&1 | \
  sed -n 's:COLLECT_LTO_WRAPPER=\(/.*/\)[^/]*:\1:p')liblto_plugin.so
27
28
29
30
31
32
33
34

# ARFLAGS is for Automake
# AR_FLAGS is for Libtool
LTOSETUP =					\
  LDFLAGS='-fuse-linker-plugin'			\
  NM='nm --plugin $(LTOPLUG)'			\
  ARFLAGS='cru --plugin $(LTOPLUG)'		\
  AR_FLAGS='cru --plugin $(LTOPLUG)'		\
35
36
  RANLIB='ranlib --plugin $(LTOPLUG)'           \
  VALGRIND=false
37
38
39
40
41
42
PRO1SETUP =					\
  CFLAGS='-flto -fprofile-generate'		\
  CXXFLAGS='-flto -fprofile-generate'
PRO2SETUP =					\
  CFLAGS='-flto -fprofile-use'			\
  CXXFLAGS='-flto -fprofile-use'
43
44
PYDEFAULT=$(shell py3versions --default)
PYOTHERS=$(filter-out $(PYDEFAULT), $(shell py3versions --supported))
45

46
47
48
49
50
51
52
53
# There seem to be a problem with unwinding of exception handling when
# the binaries are compiled with -flto.  For instance in autfilt,
# argp_parse() calls the locally defined parse_opt() that calls
# remove_ap::add_ap() (in libspot).  The latter may throw an
# exception, which should be caught in main().  However If autfilt is
# compiled with -flto, the exception never traverses argp.  Moving
# the try/catch block inside parse_opt() also fixes this praticular
# problem, but who knows about other exceptions?   So as a workaround,
54
55
# we simply disable -flto in bin/.
FLTOWORKAROUND = perl -pi -e s/-flto// bin/Makefile
56

57
58
59
60
61
# We want to build Spot twice: once to get profile data, and a second
# time to use it.
override_dh_auto_configure:
	dh_auto_configure -- $(PRO1SETUP) $(LTOSETUP)	\
	  --disable-devel --enable-optimizations	\
62
	  --disable-static PYTHON=/usr/bin/$(PYDEFAULT)
63
	$(FLTOWORKAROUND)
64
65
66
67
68
	dh_auto_build
	dh_auto_test
	make clean
	dh_auto_configure -- $(PRO2SETUP) $(LTOSETUP)	\
	  --disable-devel --enable-optimizations	\
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
69
	  --disable-static PYTHON=/usr/bin/$(PYDEFAULT)
70
	$(FLTOWORKAROUND)
71
override_dh_auto_install: fix-js
72
	dh_auto_install --destdir=$(CURDIR)/debian/tmp
73
74
75
76
77
78
# Reconfigure for every other supported Python3 version,
# and build/install only the python code.
	for pyv in $(PYOTHERS); do			\
	  dh_auto_configure -- $(LTOSETUP)		\
	  --disable-devel --enable-optimizations	\
	  --disable-static PYTHON=/usr/bin/$$pyv;	\
79
80
81
	  dh_auto_build -- -C python clean;		\
	  dh_auto_build -- -C python all;		\
	  dh_auto_install -- -C python;			\
82
	done
83
84
85
86
# Reconfigure to build static libraries.  We can't build them
# alongside dynamic libraries, otherwise they will be stuffed with
# LTO stuff that is just two big to distribute.  And we cannot use
# the profile generated with LTO on, so we simply build without it.
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
87
88
#
# Since this is a last rebuild, we also construct the Doxygen doc.
89
90
	dh_auto_configure --  \
	  --disable-devel --enable-optimizations \
Alexandre Duret-Lutz's avatar
Alexandre Duret-Lutz committed
91
92
	  --disable-shared --enable-static --disable-python \
	  --enable-doxygen
93
94
95
96
97
	dh_auto_build -- clean
	dh_auto_build -- all
	dh_auto_install -- -C buddy
	dh_auto_install -- -C spot
# Just remove the Libtool libraries until someone asks for them.
98
99
100
	find debian/tmp -name '*.la' -exec rm -rv {} ';'
override_dh_python3:
	dh_python3 -p python3-spot
101
102
override_dh_auto_build:
	dh_auto_build
103
	$(MAKE) -C tests nb-html
104

105
106
107
108
109
# BuDDy has its own changelog
override_dh_installchangelogs:
	dh_installchangelogs -plibbddx0 -plibbddx-dev buddy/ChangeLog
	dh_installchangelogs -Nlibbddx0 -Nlibbddx-dev ChangeLog

110
111
112
113
# https://mail.scipy.org/pipermail/ipython-user/2015-August/014016.html
override_dh_compress:
	dh_compress -X.ipynb

114
fix-js:
115
	perl -pi -e 's|http://orgmode.org/mathjax/MathJax.js|file:///usr/share/javascript/mathjax/MathJax.js|' doc/userdoc/*.html
116
	perl -pi -e 's|https://cdn.mathjax.org/mathjax/.*/MathJax.js|file:///usr/share/javascript/mathjax/MathJax.js|' tests/python/*.html
117
	perl -pi -e 's|https://cdnjs.cloudflare.com/ajax/libs/mathjax/.*/mathjax.js|file:///usr/share/javascript/mathjax/MathJax.js|' tests/python/*.html
118
	perl -pi -e 's|https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js|file:///usr/share/javascript/jquery/jquery.min.js|' tests/python/*.html