summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 69639376adb2dd93698c2a8149b58b07525b7202 (plain)
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
#! /usr/bin/make -f
%:
	dh $@ --builddirectory=debian/build

export DH_OPTIONS

export LC_ALL := C.UTF-8

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND := -D_FILE_OFFSET_BITS=64
export DEB_CFLAGS_MAINT_APPEND := -Wall
export DEB_CXXFLAGS_MAINT_APPEND := -Wall -std=gnu++98

# Based loosely on /usr/share/dpkg/buildflags.mk, but we need to do this
# ourselves in order to get flags for both build and host architectures.
# Compare https://bugs.debian.org/644412.

export_envvar := \
	DEB_BUILD_MAINT_OPTIONS="$(DEB_BUILD_MAINT_OPTIONS)" \
	DEB_CPPFLAGS_MAINT_APPEND="$(DEB_CPPFLAGS_MAINT_APPEND)" \
	DEB_CFLAGS_MAINT_APPEND="$(DEB_CFLAGS_MAINT_APPEND)" \
	DEB_CXXFLAGS_MAINT_APPEND="$(DEB_CXXFLAGS_MAINT_APPEND)"

buildflags := YACC='bison -y' PSPRINT=lpr PAGE=A4
buildflags_native := $(buildflags)
buildflags += $(shell $(export_envvar) dpkg-buildflags --export=cmdline)
buildflags_native += $(shell \
	DEB_HOST_ARCH="$(DEB_BUILD_ARCH)" $(export_envvar) \
	dpkg-buildflags --export=cmdline)
buildflags_native += DEB_HOST_GNU_TYPE=$(DEB_BUILD_GNU_TYPE)
buildflags_native += env -u CONFIG_SITE

export UPSTREAM_VERSION := $(shell \
	sed 's/^\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/' \
	.tarball-version)
datadir  = usr/share/groff/$(UPSTREAM_VERSION)

gbtmp = debian/groff-base
gtmp  = debian/groff

include /usr/share/dpkg/architecture.mk

confflags = \
	--libdir=\$${prefix}/lib --with-appdefdir=/etc/X11/app-defaults \
	BASH_PROG=/bin/bash GREP=/bin/grep

override_dh_autoreconf:
	dh_autoreconf autoreconf -- -f -i -I m4

override_dh_auto_configure:
	-rm -f config.log config.cache
	$(buildflags) dh_auto_configure -- $(confflags)
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	$(buildflags_native) dh_auto_configure \
		--builddirectory=debian/build-native -- \
		$(confflags)
endif
	# Work around an unfortunate interaction between the
	# non-recursive-gnulib-prefix-hack module and out-of-tree builds.
	mkdir -p debian/build/lib
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	mkdir -p debian/build-native/lib
endif

ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
  cross :=
else
  native_tmp := $(CURDIR)/debian/build-native
  cross := \
	GROFFBIN=$(native_tmp)/groff \
	GROFF_BIN_PATH=$(native_tmp)
endif

override_dh_auto_build:
	# Always rebuild documentation from source.
	mkdir -p debian/doc-save
	find doc \( -name \*.dvi -or -name \*.info -or -name \*.pdf \) \
		-exec mv -f -t debian/doc-save '{}' +
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	dh_auto_build --builddirectory=debian/build-native -- \
		extratmacdirs=/usr/share/groff/tmac \
		docdir=\$${prefix}/share/doc/groff-base
endif
	GROFF_NO_SGR=1 dh_auto_build --builddirectory=debian/build -- \
		extratmacdirs=/usr/share/groff/tmac \
		docdir=\$${prefix}/share/doc/groff-base $(cross)

override_dh_auto_install:
	dh_auto_install -- \
		docdir=\$${prefix}/share/doc/groff-base \
		INSTALL_INFO=:

execute_after_dh_install:
	# Debian additions to *.local
	cat debian/mandoc.local >> $(gbtmp)/etc/groff/man.local
	cat debian/mandoc.local >> $(gbtmp)/etc/groff/mdoc.local
	# Scripts should be executable
	chmod +x $(gbtmp)/$(datadir)/font/devps/generate/afmname \
		 $(gbtmp)/$(datadir)/font/devps/generate/symbol.sed
	chmod +x $(gtmp)/$(datadir)/font/devdvi/generate/CompileFonts \
		 $(gtmp)/$(datadir)/font/devlj4/generate/special.awk
	# Debian Policy 10.4 specifies the #! line for Perl scripts
	grep -rlZ '#! */usr/bin/env perl' $(gbtmp) $(gtmp) | \
		xargs -0r sed -i 's,\(#! *\)/usr/bin/env perl,\1/usr/bin/perl,'

override_dh_installdocs:
	dh_installdocs -pgroff-base
	dh_installdocs -pgroff -Xcopyright --link-doc=groff-base

override_dh_installchangelogs:
	dh_installchangelogs -pgroff-base

override_dh_compress:
	dh_compress -X.mom

execute_before_dh_auto_clean:
	[ ! -d debian/doc-save ] || \
		find debian/doc-save -type f -exec mv -f -t doc '{}' +
	rm -rf debian/doc-save