blob: 648939b22fbac080e2301fac36fca05f6af20ddc [file] [log] [blame]
Steve Kondikae271bc2015-11-15 02:50:53 +01001#!/usr/bin/make -f
micky3879b9f5e72025-07-08 18:04:53 -04002# $Id: rules,v 1.53 2024/04/08 15:31:32 tom Exp $
Steve Kondikae271bc2015-11-15 02:50:53 +01003
4# Uncomment this to turn on verbose mode.
5#export DH_VERBOSE=1
6
micky3879b9f5e72025-07-08 18:04:53 -04007SHELL = /bin/bash
8DPKG_EXPORT_BUILDFLAGS = 1
9
10export DEB_BUILD_MAINT_OPTIONS = hardening=+all
11
12include /usr/share/dpkg/buildflags.mk
13
Steve Kondikae271bc2015-11-15 02:50:53 +010014# packages
micky3879b9f5e72025-07-08 18:04:53 -040015PACKAGES.indep = ncurses6-doc ncurses6-doc-html
Steve Kondikae271bc2015-11-15 02:50:53 +010016PACKAGES.arch = ncurses6 ncursest6
17
18# These are used for cross-compiling and for saving the configure script
19# from having to guess our platform (since we know it already)
20DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
21DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
micky3879b9f5e72025-07-08 18:04:53 -040022DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
Steve Kondikae271bc2015-11-15 02:50:53 +010023
24CC_NORMAL = -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wconversion
25CC_STRICT = $(CC_NORMAL) -W -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wnested-externs -Wpointer-arith -Wwrite-strings -ansi -pedantic
26
27MY_ABI=6
28MY_DIR=/usr
micky3879b9f5e72025-07-08 18:04:53 -040029BINDIR=$(MY_DIR)/bin
30LIBDIR=$(MY_DIR)/lib/$(DEB_HOST_MULTIARCH)
Steve Kondikae271bc2015-11-15 02:50:53 +010031MYDATA=/usr/local/ncurses/share/terminfo
32NORMAL_DIR=$(CURDIR)/debian/ncurses$(MY_ABI)
33THREAD_DIR=$(CURDIR)/debian/ncursest$(MY_ABI)
34
micky3879b9f5e72025-07-08 18:04:53 -040035CFLAGS += $(CC_NORMAL)
Steve Kondikae271bc2015-11-15 02:50:53 +010036
37ifneq ($(MY_DIR),/usr)
micky3879b9f5e72025-07-08 18:04:53 -040038 RPATH_ENV = RPATH_LIST=../lib:$(LIBDIR)
Steve Kondikae271bc2015-11-15 02:50:53 +010039 RPATH_OPT = --enable-rpath
40else
41 RPATH_ENV =
42 RPATH_OPT = --disable-rpath --disable-rpath-hack
43endif
44
45ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
46 CFLAGS += -O0
47else
48 CFLAGS += -O2
49endif
50ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
51 INSTALL_PROGRAM += -s
52endif
53
54verbose = # -v
55
56configure = \
57 $(RPATH_ENV) \
58 CFLAGS="$(CFLAGS)" \
59 CPPFLAGS="$(CPPFLAGS)" \
60 LDFLAGS="$(LDFLAGS)" ../../configure $(RPATH_OPT) \
61 --host=$(DEB_HOST_GNU_TYPE) \
62 --build=$(DEB_BUILD_GNU_TYPE) \
63 --prefix=$(MY_DIR) \
micky3879b9f5e72025-07-08 18:04:53 -040064 --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
Steve Kondikae271bc2015-11-15 02:50:53 +010065 --disable-echo \
66 --disable-getcap \
67 --disable-leaks \
68 --disable-macros \
69 --disable-overwrite \
micky3879b9f5e72025-07-08 18:04:53 -040070 --disable-relink \
71 --disable-root-access \
72 --disable-root-environ \
Steve Kondikae271bc2015-11-15 02:50:53 +010073 --disable-termcap \
micky3879b9f5e72025-07-08 18:04:53 -040074 --enable-check-size \
Steve Kondikae271bc2015-11-15 02:50:53 +010075 --enable-hard-tabs \
micky3879b9f5e72025-07-08 18:04:53 -040076 --enable-opaque-curses \
77 --enable-opaque-form \
78 --enable-opaque-menu \
79 --enable-opaque-panel \
Steve Kondikae271bc2015-11-15 02:50:53 +010080 --enable-pc-files \
micky3879b9f5e72025-07-08 18:04:53 -040081 --enable-stdnoreturn \
Steve Kondikae271bc2015-11-15 02:50:53 +010082 --enable-warnings \
83 --enable-wgetch-events \
84 --enable-widec \
micky3879b9f5e72025-07-08 18:04:53 -040085 --enable-xmc-glitch \
Steve Kondikae271bc2015-11-15 02:50:53 +010086 --program-suffix=$(MY_ABI) \
87 --verbose \
88 --with-abi-version=$(MY_ABI) \
micky3879b9f5e72025-07-08 18:04:53 -040089 --with-config-suffix=dev \
90 --with-cxx-shared \
91 --with-default-terminfo-dir=$(MYDATA) \
Steve Kondikae271bc2015-11-15 02:50:53 +010092 --with-develop \
93 --with-extra-suffix=$(MY_ABI) \
94 --with-shared \
micky3879b9f5e72025-07-08 18:04:53 -040095 --with-terminfo-dirs=$(MYDATA):/lib/terminfo:/usr/share/terminfo \
Steve Kondikae271bc2015-11-15 02:50:53 +010096 --with-termlib \
97 --with-ticlib \
98 --with-trace \
Steve Kondikae271bc2015-11-15 02:50:53 +010099 --with-versioned-syms \
100 --with-xterm-kbs=DEL \
101 --without-ada \
102 --without-debug \
micky3879b9f5e72025-07-08 18:04:53 -0400103 --with-manpage-aliases \
104 --with-manpage-symlinks \
Steve Kondikae271bc2015-11-15 02:50:53 +0100105 --without-normal
106
107NCURSES6_DIR = $(CURDIR)/debian/ncurses6
108NCURSEST6_DIR = $(CURDIR)/debian/ncursest6
109
110.PHONY: all config build install binary clean config-indep config-arch \
111 build-indep build-arch install-indep install-arch binary-indep \
112 binary-arch
113
114all: build
115
116config: config-indep config-arch
117build: build-indep build-arch
118install: install-indep install-arch
119binary: binary-indep binary-arch
120clean:
121 dh_testdir
122 dh_testroot
123 dh_clean $(verbose)
124 rm -rf t
125
126config-indep: $(PACKAGES.indep:%=config-%-stamp)
127config-arch: $(PACKAGES.arch:%=config-%-stamp)
128
129build-indep: $(PACKAGES.indep:%=build-%-stamp)
130build-arch: $(PACKAGES.arch:%=build-%-stamp)
131
132install-indep: $(PACKAGES.indep:%=install-%-stamp)
133install-arch: $(PACKAGES.arch:%=install-%-stamp)
134
micky3879b9f5e72025-07-08 18:04:53 -0400135# make the doc-package installable by renaming everything to avoid clashing
136patch-ncurses6-stamp:
137 dh_testdir
138 sed -i.bak \
139 -e 's/-config\.1$$/dev-config.1/;t' \
140 -e 's/\.3ncurses$$/.3ncurses6/' \
141 -e 's/\.3curses$$/.3curses6/' \
142 -e 's/\.3form$$/.3form6/' \
143 -e 's/\.3menu$$/.3menu6/' \
144 -e 's/\.3panel$$/.3panel6/' \
145 -e 's/\.\([157]\)$$/6.\1/' \
146 man/man_db.renames.in
147 diff -u man/man_db.renames.in.bak man/man_db.renames.in || true
148 touch $@
149
150config-ncurses6-stamp: patch-ncurses6-stamp
Steve Kondikae271bc2015-11-15 02:50:53 +0100151 dh_testdir
152 rm -rf t/ncurses6
153 mkdir -p t/ncurses6
154 cd t/ncurses6; $(configure)
155 touch $@
156
micky3879b9f5e72025-07-08 18:04:53 -0400157config-ncursest6-stamp: patch-ncurses6-stamp
Steve Kondikae271bc2015-11-15 02:50:53 +0100158 dh_testdir
159 rm -rf t/ncursest6
160 mkdir -p t/ncursest6
161 cd t/ncursest6; $(configure) \
162 --enable-interop \
163 --enable-sp-funcs \
164 --program-suffix=t$(MY_ABI) \
165 --with-pthread
166 touch $@
167
micky3879b9f5e72025-07-08 18:04:53 -0400168config-ncurses6-doc-stamp \
169config-ncurses6-doc-html-stamp: config-ncurses6-stamp
170 touch $@
171
Steve Kondikae271bc2015-11-15 02:50:53 +0100172build-ncurses6-stamp: config-ncurses6-stamp
173 dh_testdir
174
175 $(MAKE) -C t/ncurses6
176
177 touch $@
178
179build-ncursest6-stamp: config-ncursest6-stamp
180 dh_testdir
181
182 $(MAKE) -C t/ncursest6
183
184 touch $@
185
micky3879b9f5e72025-07-08 18:04:53 -0400186build-ncurses6-doc-stamp \
187build-ncurses6-doc-html-stamp: build-ncurses6-stamp
188 touch $@
189
Steve Kondikae271bc2015-11-15 02:50:53 +0100190install-ncurses6-stamp: build-ncurses6-stamp
191 dh_testdir
192 dh_testroot
193 dh_installdirs $(verbose)
194 dh_prep $(verbose) -pncurses6
195
196 $(MAKE) -C t/ncurses6 install.libs install.progs DESTDIR=$(NCURSES6_DIR)
micky3879b9f5e72025-07-08 18:04:53 -0400197 $(MAKE) -C t/ncurses6/test ncurses LOCAL_LIBDIR=$(LIBDIR)
Steve Kondikae271bc2015-11-15 02:50:53 +0100198
micky3879b9f5e72025-07-08 18:04:53 -0400199 mv t/ncurses6/test/ncurses $(NCURSES6_DIR)$(BINDIR)/ncurses$(MY_ABI)
Steve Kondikae271bc2015-11-15 02:50:53 +0100200
201 touch $@
202
203install-ncursest6-stamp: build-ncursest6-stamp
204 dh_testdir
205 dh_testroot
206 dh_installdirs $(verbose)
207 dh_prep $(verbose) -pncursest6
208
209 $(MAKE) -C t/ncursest6 install.libs install.progs DESTDIR=$(NCURSEST6_DIR)
micky3879b9f5e72025-07-08 18:04:53 -0400210 $(MAKE) -C t/ncursest6/test ncurses LOCAL_LIBDIR=$(LIBDIR)
Steve Kondikae271bc2015-11-15 02:50:53 +0100211
micky3879b9f5e72025-07-08 18:04:53 -0400212 mv t/ncursest6/test/ncurses $(NCURSEST6_DIR)$(BINDIR)/ncursest$(MY_ABI)
213
214 touch $@
215
216install-ncurses6-doc-stamp: build-ncurses6-stamp
217 dh_testdir
218 dh_testroot
219 dh_installdirs $(verbose)
220 dh_prep $(verbose) -pncurses6-doc
221
222 $(MAKE) -C t/ncurses6 install.man DESTDIR=$(NCURSES6_DIR)-doc
223 find $(NCURSES6_DIR)-doc -name 'ncursesw6-config.*' -print -delete
224
225 cd $(NCURSES6_DIR)-doc/usr/share/man/man1 && ln -sf tset6.1.gz reset6.1.gz
226
227 touch $@
228
229HTML_DESTDIR=$(NCURSES6_DIR)-doc-html/usr/share/doc/ncurses6-doc-html
230install-ncurses6-doc-html-stamp: build-ncurses6-stamp
231 dh_testdir
232 dh_testroot
233 dh_installdirs $(verbose)
234 dh_prep $(verbose) -pncurses6-doc-html
235
236 cd doc/html && find * -type d | sort | xargs -I{} mkdir -p -v $(HTML_DESTDIR)/{}
237 cd doc/html && find * -type f -name '*.html' | sort | xargs -I{} install -m 644 -p -v -T {} $(HTML_DESTDIR)/{}
238 find $(HTML_DESTDIR) -type d -empty -delete -print
239 find $(HTML_DESTDIR) -type d -empty -delete -print
Steve Kondikae271bc2015-11-15 02:50:53 +0100240
241 touch $@
242
243# Build architecture-independent files here.
244binary-indep: install-indep
245ifneq ($(PACKAGES.indep),)
246 rm -f $(PACKAGES.indep:%=install-%-stamp)
247 dh_testdir
248 dh_testroot
micky3879b9f5e72025-07-08 18:04:53 -0400249 dh_lintian $(verbose) $(PACKAGES.arch:%=-p%)
Steve Kondikae271bc2015-11-15 02:50:53 +0100250 dh_installdocs $(verbose) $(PACKAGES.indep:%=-p%)
251 dh_installman $(verbose) $(PACKAGES.indep:%=-p%)
252 dh_installexamples $(verbose) $(PACKAGES.indep:%=-p%)
253 dh_installchangelogs $(verbose) $(PACKAGES.indep:%=-p%) NEWS
254 dh_compress $(verbose) $(PACKAGES.indep:%=-p%)
255 dh_fixperms $(verbose) $(PACKAGES.indep:%=-p%)
256 dh_installdeb $(verbose) $(PACKAGES.indep:%=-p%)
257 dh_gencontrol $(verbose) $(PACKAGES.indep:%=-p%)
258 dh_md5sums $(verbose) $(PACKAGES.indep:%=-p%)
259 dh_builddeb $(verbose) $(PACKAGES.indep:%=-p%)
260endif
261
262# Build architecture-dependent files here.
263binary-arch: install-arch
264ifneq ($(PACKAGES.arch),)
265 rm -f $(PACKAGES.arch:%=install-%-stamp)
266 dh_testdir
267 dh_testroot
micky3879b9f5e72025-07-08 18:04:53 -0400268
269 version=`set -x; awk 'BEGIN{major=minor=0} /^NCURSES_MAJOR/{major=$$3} /^NCURSES_MINOR/{minor=$$3} END{print major "." minor}' < dist.mk`; \
270 sed -i \
271 -e "s, usr/lib, usr/lib/$(DEB_HOST_MULTIARCH)," \
272 -e "s,6\.1,$${version}," \
273 debian/*.lintian-overrides
274
275 dh_lintian $(verbose) $(PACKAGES.arch:%=-p%)
276 dh_installdocs $(verbose) $(PACKAGES.arch:%=-p%)
Steve Kondikae271bc2015-11-15 02:50:53 +0100277 dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%) NEWS
278 dh_strip $(verbose) $(PACKAGES.arch:%=-p%)
279 dh_compress $(verbose) $(PACKAGES.arch:%=-p%)
280 dh_fixperms $(verbose) $(PACKAGES.arch:%=-p%)
281 dh_installdeb $(verbose) $(PACKAGES.arch:%=-p%)
282 dh_makeshlibs $(verbose) $(PACKAGES.arch:%=-p%)
283 dh_shlibdeps $(verbose) $(PACKAGES.arch:%=-p%)
284 dh_gencontrol $(verbose) $(PACKAGES.arch:%=-p%)
285 dh_md5sums $(verbose) $(PACKAGES.arch:%=-p%)
286 dh_builddeb $(verbose) $(PACKAGES.arch:%=-p%)
287endif