ncurses 6.2 - patch 20210522
[ncurses.git] / package / debian / rules
1 #!/usr/bin/make -f
2 # $Id: rules,v 1.40 2021/03/23 00:17:05 tom Exp $
3
4 # Uncomment this to turn on verbose mode.
5 #export DH_VERBOSE=1
6
7 # packages
8 PACKAGES.indep = ncurses6-doc ncurses6-doc-html
9 PACKAGES.arch  = ncurses6 ncursest6
10
11 # These are used for cross-compiling and for saving the configure script
12 # from having to guess our platform (since we know it already)
13 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
14 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
15
16 CC_NORMAL = -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wconversion
17 CC_STRICT = $(CC_NORMAL) -W -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-declarations -Wnested-externs -Wpointer-arith -Wwrite-strings -ansi -pedantic
18
19 MY_ABI=6
20 MY_DIR=/usr
21 MYDATA=/usr/local/ncurses/share/terminfo
22 NORMAL_DIR=$(CURDIR)/debian/ncurses$(MY_ABI)
23 THREAD_DIR=$(CURDIR)/debian/ncursest$(MY_ABI)
24
25 CFLAGS   = $(shell dpkg-buildflags --get CFLAGS) $(CC_NORMAL)
26 CXXFLAGS = $(shell dpkg-buildflags --get CXXFLAGS)
27 CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
28 LDFLAGS  = $(shell dpkg-buildflags --get LDFLAGS)
29
30 ifneq ($(MY_DIR),/usr)
31         RPATH_ENV = RPATH_LIST=../lib:$(MY_DIR)/lib
32         RPATH_OPT = --enable-rpath
33 else
34         RPATH_ENV =
35         RPATH_OPT = --disable-rpath --disable-rpath-hack
36 endif
37
38 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
39         CFLAGS += -O0
40 else
41         CFLAGS += -O2
42 endif
43 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
44         INSTALL_PROGRAM += -s
45 endif
46
47 verbose = # -v
48
49 configure = \
50         $(RPATH_ENV) \
51         CFLAGS="$(CFLAGS)" \
52         CPPFLAGS="$(CPPFLAGS)" \
53         LDFLAGS="$(LDFLAGS)" ../../configure $(RPATH_OPT) \
54                 --host=$(DEB_HOST_GNU_TYPE) \
55                 --build=$(DEB_BUILD_GNU_TYPE) \
56                 --prefix=$(MY_DIR) \
57                 --disable-echo \
58                 --disable-getcap \
59                 --disable-leaks \
60                 --disable-macros  \
61                 --disable-overwrite  \
62                 --disable-relink \
63                 --disable-termcap \
64                 --enable-hard-tabs \
65                 --enable-opaque-curses \
66                 --enable-opaque-form \
67                 --enable-opaque-menu \
68                 --enable-opaque-panel \
69                 --enable-pc-files \
70                 --enable-stdnoreturn \
71                 --enable-warnings \
72                 --enable-wgetch-events \
73                 --enable-widec \
74                 --enable-xmc-glitch \
75                 --program-suffix=$(MY_ABI) \
76                 --verbose \
77                 --with-abi-version=$(MY_ABI) \
78                 --with-config-suffix=dev \
79                 --with-cxx-shared \
80                 --with-default-terminfo-dir=$(MYDATA) \
81                 --with-develop \
82                 --with-extra-suffix=$(MY_ABI) \
83                 --with-shared \
84                 --with-terminfo-dirs=$(MYDATA):/lib/terminfo:/usr/share/terminfo \
85                 --with-termlib \
86                 --with-ticlib \
87                 --with-trace \
88                 --with-versioned-syms \
89                 --with-xterm-kbs=DEL \
90                 --without-ada \
91                 --without-debug \
92                 --without-manpage-aliases \
93                 --without-normal
94
95 NCURSES6_DIR = $(CURDIR)/debian/ncurses6
96 NCURSEST6_DIR = $(CURDIR)/debian/ncursest6
97
98 .PHONY: all config build install binary clean config-indep config-arch \
99     build-indep build-arch install-indep install-arch binary-indep \
100     binary-arch
101
102 all: build
103
104 config: config-indep config-arch
105 build: build-indep build-arch
106 install: install-indep install-arch
107 binary: binary-indep binary-arch
108 clean:
109         dh_testdir
110         dh_testroot
111         dh_clean $(verbose)
112         rm -rf t
113
114 config-indep: $(PACKAGES.indep:%=config-%-stamp)
115 config-arch: $(PACKAGES.arch:%=config-%-stamp)
116
117 build-indep: $(PACKAGES.indep:%=build-%-stamp)
118 build-arch: $(PACKAGES.arch:%=build-%-stamp)
119
120 install-indep: $(PACKAGES.indep:%=install-%-stamp)
121 install-arch: $(PACKAGES.arch:%=install-%-stamp)
122
123 # make the doc-package installable by renaming everything to avoid clashing
124 patch-ncurses6-stamp:
125         dh_testdir
126         sed -i.bak \
127                 -e 's/-config\.1$$/dev-config.1/;t' \
128                 -e 's/\.3ncurses$$/.3ncurses6/' \
129                 -e 's/\.3curses$$/.3curses6/' \
130                 -e 's/\.3form$$/.3form6/' \
131                 -e 's/\.3menu$$/.3menu6/' \
132                 -e 's/\.3panel$$/.3panel6/' \
133                 -e 's/\.\([157]\)$$/6.\1/' \
134                 man/man_db.renames
135         diff -u man/man_db.renames.bak man/man_db.renames || true
136         touch $@
137
138 config-ncurses6-stamp: patch-ncurses6-stamp
139         dh_testdir
140         rm -rf t/ncurses6
141         mkdir -p t/ncurses6
142         cd t/ncurses6; $(configure)
143         touch $@
144
145 config-ncursest6-stamp: patch-ncurses6-stamp
146         dh_testdir
147         rm -rf t/ncursest6
148         mkdir -p t/ncursest6
149         cd t/ncursest6; $(configure) \
150                 --enable-interop \
151                 --enable-sp-funcs \
152                 --program-suffix=t$(MY_ABI) \
153                 --with-pthread
154         touch $@
155
156 config-ncurses6-doc-stamp \
157 config-ncurses6-doc-html-stamp: config-ncurses6-stamp
158         touch $@
159
160 build-ncurses6-stamp: config-ncurses6-stamp
161         dh_testdir
162
163         $(MAKE) -C t/ncurses6
164
165         touch $@
166
167 build-ncursest6-stamp: config-ncursest6-stamp
168         dh_testdir
169
170         $(MAKE) -C t/ncursest6
171
172         touch $@
173
174 build-ncurses6-doc-stamp \
175 build-ncurses6-doc-html-stamp: build-ncurses6-stamp
176         touch $@
177
178 install-ncurses6-stamp: build-ncurses6-stamp
179         dh_testdir
180         dh_testroot
181         dh_installdirs $(verbose)
182         dh_prep        $(verbose) -pncurses6
183
184         $(MAKE) -C t/ncurses6 install.libs install.progs DESTDIR=$(NCURSES6_DIR)
185         $(MAKE) -C t/ncurses6/test ncurses LOCAL_LIBDIR=$(MY_DIR)/lib
186
187         mv t/ncurses6/test/ncurses $(NCURSES6_DIR)$(MY_DIR)/bin/ncurses$(MY_ABI)
188
189         touch $@
190
191 install-ncursest6-stamp: build-ncursest6-stamp
192         dh_testdir
193         dh_testroot
194         dh_installdirs $(verbose)
195         dh_prep        $(verbose) -pncursest6
196
197         $(MAKE) -C t/ncursest6 install.libs install.progs DESTDIR=$(NCURSEST6_DIR)
198         $(MAKE) -C t/ncursest6/test ncurses LOCAL_LIBDIR=$(MY_DIR)/lib
199
200         mv t/ncursest6/test/ncurses $(NCURSEST6_DIR)$(MY_DIR)/bin/ncursest$(MY_ABI)
201
202         touch $@
203
204 install-ncurses6-doc-stamp: build-ncurses6-stamp
205         dh_testdir
206         dh_testroot
207         dh_installdirs $(verbose)
208         dh_prep        $(verbose) -pncurses6-doc
209
210         $(MAKE) -C t/ncurses6 install.man DESTDIR=$(NCURSES6_DIR)-doc
211
212         touch $@
213
214 HTML_DESTDIR=$(NCURSES6_DIR)-doc-html/usr/share/ncurses6-doc-html
215 install-ncurses6-doc-html-stamp: build-ncurses6-stamp
216         dh_testdir
217         dh_testroot
218         dh_installdirs $(verbose)
219         dh_prep        $(verbose) -pncurses6-doc-html
220
221         cd doc/html && find * -type d | sort | xargs -I{} mkdir -p -v $(HTML_DESTDIR)/{}
222         cd doc/html && find * -type f -name '*.html' | sort | xargs -I{} install -m 644 -p -v -T {} $(HTML_DESTDIR)/{}
223
224         touch $@
225
226 # Build architecture-independent files here.
227 binary-indep: install-indep
228 ifneq ($(PACKAGES.indep),)
229         rm -f $(PACKAGES.indep:%=install-%-stamp)
230         dh_testdir
231         dh_testroot
232         dh_lintian           $(verbose) $(PACKAGES.arch:%=-p%)
233         dh_installdocs       $(verbose) $(PACKAGES.indep:%=-p%)
234         dh_installman        $(verbose) $(PACKAGES.indep:%=-p%)
235         dh_installexamples   $(verbose) $(PACKAGES.indep:%=-p%)
236         dh_installchangelogs $(verbose) $(PACKAGES.indep:%=-p%) NEWS
237         dh_compress          $(verbose) $(PACKAGES.indep:%=-p%)
238         dh_fixperms          $(verbose) $(PACKAGES.indep:%=-p%)
239         dh_installdeb        $(verbose) $(PACKAGES.indep:%=-p%)
240         dh_gencontrol        $(verbose) $(PACKAGES.indep:%=-p%)
241         dh_md5sums           $(verbose) $(PACKAGES.indep:%=-p%)
242         dh_builddeb          $(verbose) $(PACKAGES.indep:%=-p%)
243 endif
244
245 # Build architecture-dependent files here.
246 binary-arch: install-arch
247 ifneq ($(PACKAGES.arch),)
248         rm -f $(PACKAGES.arch:%=install-%-stamp)
249         dh_testdir
250         dh_testroot
251         dh_lintian           $(verbose) $(PACKAGES.arch:%=-p%)
252         dh_installdocs       $(verbose) $(PACKAGES.arch:%=-p%)
253         dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%)  NEWS
254         dh_strip             $(verbose) $(PACKAGES.arch:%=-p%)
255         dh_compress          $(verbose) $(PACKAGES.arch:%=-p%)
256         dh_fixperms          $(verbose) $(PACKAGES.arch:%=-p%)
257         dh_installdeb        $(verbose) $(PACKAGES.arch:%=-p%)
258         dh_makeshlibs        $(verbose) $(PACKAGES.arch:%=-p%)
259         dh_shlibdeps         $(verbose) $(PACKAGES.arch:%=-p%)
260         dh_gencontrol        $(verbose) $(PACKAGES.arch:%=-p%)
261         dh_md5sums           $(verbose) $(PACKAGES.arch:%=-p%)
262         dh_builddeb          $(verbose) $(PACKAGES.arch:%=-p%)
263 endif