File: rules

package info (click to toggle)
readline5 5.0-10
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 5,508 kB
  • ctags: 2,651
  • sloc: ansic: 19,931; sh: 5,061; perl: 4,105; makefile: 1,353
file content (394 lines) | stat: -rwxr-xr-x 10,769 bytes parent folder | download
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
#!/usr/bin/make -f
# -*- makefile -*-

soversion = 5
libversion = $(soversion).0

# architecture dependent variables
DEB_HOST_ARCH		?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_CPU	?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_GNU_SYSTEM	?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
DEB_HOST_GNU_TYPE	?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

ifeq ($(DEB_HOST_GNU_TYPE),sparc-linux)
  build64 = yes
  CC64 = gcc -m64
  HOST64 = sparc64-linux
endif

ifeq ($(DEB_HOST_GNU_SYSTEM),gnu)
  LD_PRELOAD_STUB = ""
else
  LD_PRELOAD_STUB = $(d_rl)/lib/readline/libreadline.so.$(soversion)
endif

ifeq ($(DEB_HOST_GNU_SYSTEM),netbsdelf-gnu)
  CC_LINK_FLAGS =
else
  CC_LINK_FLAGS = -Wl,
endif
CC	= gcc

SHELL	= bash

PWD	:= $(shell pwd)
p_rl	= libreadline$(soversion)
p_rl64	= lib64readline$(soversion)
p_comm	= libreadline-common
p_rld	= $(p_rl)-dev
p_rld64	= $(p_rl)-dev
p_rlg	= $(p_rl)-dbg
p_doc	= $(p_rl)-doc
p_rlfe	= rlfe

d	= debian/tmp
d64	= debian/tmp64
d_rl	= debian/$(p_rl)
d_rl64	= debian/$(p_rl64)
d_comm	= debian/$(p_comm)
d_rld	= debian/$(p_rld)
d_rld64	= debian/$(p_rld64)
d_rlg	= debian/$(p_rlg)
d_doc	= debian/$(p_doc)
d_rlfe	= debian/$(p_rlfe)

srcdir		= $(PWD)
builddir	= $(PWD)/build
builddir64	= $(PWD)/build64

default: build

configure: configure-stamp
configure-stamp: patch-stamp
	dh_testdir
	cp -p /usr/share/misc/config.* ./support/
	rm -rf $(builddir)
	mkdir $(builddir)
	find . -type d | xargs chmod g-s
	cd $(builddir) && \
	  CC=$(CC) $(srcdir)/configure \
		--host=$(DEB_HOST_GNU_TYPE) --with-curses --prefix=/usr

ifneq ($(build64),)
	rm -rf $(builddir64)
	mkdir $(builddir64)
	cd $(builddir64) && \
	  CC="$(CC64)" $(srcdir)/configure \
		--host=$(HOST64) --with-curses --prefix=/usr
endif

	touch configure-stamp

build: build-stamp build-rlfe-stamp

build-stamp: configure-stamp
	dh_testdir
	$(MAKE) -C $(builddir) \
	    CFLAGS="-g -O2 -D_REENTRANT" \
	    SHLIB_LIBS=-lncurses

ifneq ($(build64),)
	$(MAKE) -C $(builddir64) \
	    CC="$(CC64)" \
	    CFLAGS="-g -O2 -D_REENTRANT" \
	    SHOBJ_LDFLAGS='-shared' \
	    SHLIB_XLDFLAGS='$(CC_LINK_FLAGS)-soname,`echo $$@ | sed s/\\..$$$$//`' \
	    SHLIB_LIBS=-lncurses
endif
	cd $(builddir)/doc \
	    && makeinfo --no-split -I ../../doc -o rl5userman.info \
		../../doc/rluserman.texi

	touch build-stamp

build-rlfe-stamp: configure-stamp
	dh_testdir
	ln -sf libhistory.so.$(libversion) \
	    $(builddir)/shlib/libhistory.so.$(soversion)
	ln -sf libhistory.so.$(soversion) $(builddir)/shlib/libhistory.so
	ln -sf libreadline.so.$(libversion) \
	    $(builddir)/shlib/libreadline.so.$(soversion)
	ln -sf libreadline.so.$(soversion) $(builddir)/shlib/libreadline.so
	$(MAKE) -C $(builddir)/examples \
	    CFLAGS="-g -O2" LDFLAGS="-g -L../shlib" rlfe
	touch build-rlfe-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f configure*-stamp build*-stamp install-stamp
	rm -rf $(builddir)
ifneq ($(build64),)
	rm -rf $(builddir64) $(d64)
endif
	rm -f doc/*.dvi
	$(MAKE) -f debian/rules unpatch
	rm -f patch-stamp*
	find . -type d | xargs chmod g-s
	rm -f support/config.guess support/config.sub
	dh_clean

install: install-stamp
install-stamp:
	dh_testdir
	dh_testroot
	dh_clean -k
	rm -rf $(d)
	mkdir -p $(d)/usr
	$(MAKE) -C $(builddir) install \
	    CFLAGS="-g -O2 -D_REENTRANT" \
	    prefix=$(PWD)/$(d)/usr \
	    mandir=$(PWD)/$(d)/usr/share/man \
	    infodir=$(PWD)/$(d)/usr/share/info

	: # move $(p_rl)
	dh_installdirs -p$(p_rl) \
		etc \
		lib \
		usr/share/info \
		usr/share/doc
	cp -a $(d)/usr/lib/lib{history,readline}.so.$(libversion) $(d_rl)/lib/
	ln -s libhistory.so.$(libversion) \
		$(d_rl)/lib/libhistory.so.$(soversion)
	ln -s libreadline.so.$(libversion) \
		$(d_rl)/lib/libreadline.so.$(soversion)

ifeq (0,1)
	: # move $(p_comm)
	dh_installdirs -p$(p_comm) \
		etc \
		usr/share/info \
		usr/share/doc
	mv $(d)/usr/share/man $(d_comm)/usr/share/.
	mv $(d_comm)/usr/share/man/man3/history.3 \
		$(d_comm)/usr/share/man/man3/history.3readline
	mv $(d_comm)/usr/share/man/man3/readline.3 \
		$(d_comm)/usr/share/man/man3/readline.3readline
	mv $(d)/usr/share/info/rluserman.info $(d_comm)/usr/share/info/.
endif
	rm -f $(d)/usr/share/info/rluserman.info
	mkdir -p $(d_rl)/usr/share/info $(d_rl)/usr/share/man/man3
	cp -p $(builddir)/doc/rl5userman.info $(d_rl)/usr/share/info/
	mv $(d)/usr/share/man/man3/history.3 \
		$(d_rl)/usr/share/man/man3/history5.3readline
	mv $(d)/usr/share/man/man3/readline.3 \
		$(d_rl)/usr/share/man/man3/readline5.3readline

	: # move $(p_rlg)
	dh_installdirs -p$(p_rlg) \
		usr/lib/debug \
		usr/share/doc
	mv $(d)/usr/lib/lib{history,readline}.so.$(libversion) \
		$(d_rlg)/usr/lib/debug/.
	ln -s libhistory.so.$(libversion) \
		$(d_rlg)/usr/lib/debug/libhistory.so.$(soversion)
	ln -s libreadline.so.$(libversion) \
		$(d_rlg)/usr/lib/debug/libreadline.so.$(soversion)

	: # move $(p_rld)
	dh_installdirs -p$(p_rld) \
		usr/lib \
		usr/share/doc \
		usr/share/info
	ln -s /lib/libhistory.so.$(soversion) $(d_rld)/usr/lib/libhistory.so
	ln -s /lib/libreadline.so.$(soversion) $(d_rld)/usr/lib/libreadline.so
	mv $(d)/usr/lib/lib{history,readline}.a	$(d_rld)/usr/lib/.
	mv $(d)/usr/include $(d_rld)/usr/.
	mv $(d)/usr/share/info/{readline.info,history.info} \
		$(d_rld)/usr/share/info/.

# remove HAVE_CONFIG_H from installed headers
	awk '/^#if defined \(HAVE_CONFIG_H\)/, /^#endif/ \
	     {if ($$0 == "#else") print "#include <string.h>"; next} {print}' \
	  $(d_rld)/usr/include/readline/chardefs.h \
	  > $(d_rld)/usr/include/readline/chardefs.h.new
	if diff -u $(d_rld)/usr/include/readline/chardefs.h \
		$(d_rld)/usr/include/readline/chardefs.h.new; \
	then \
	  rm -f $(d_rld)/usr/include/readline/chardefs.h.new; \
	else \
	  mv -f $(d_rld)/usr/include/readline/chardefs.h.new \
	    $(d_rld)/usr/include/readline/chardefs.h; \
	fi

	awk '/^#if defined \(HAVE_CONFIG_H\)/, /^#endif/ {next} {print}' \
	  $(d_rld)/usr/include/readline/tilde.h \
	  > $(d_rld)/usr/include/readline/tilde.h.new
	if diff -u $(d_rld)/usr/include/readline/tilde.h \
		$(d_rld)/usr/include/readline/tilde.h.new; \
	then \
	  rm -f $(d_rld)/usr/include/readline/tilde.h.new; \
	else \
	  mv -f $(d_rld)/usr/include/readline/tilde.h.new \
	    $(d_rld)/usr/include/readline/tilde.h; \
	fi

	: # install $(p_rlfe)
	dh_installdirs -p$(p_rlfe) \
	    usr/bin usr/share/man/man1 \
	    usr/share/doc/$(p_rlfe)
	cp -p $(builddir)/examples/rlfe $(d_rlfe)/usr/bin/.
	cp -p debian/rlfe.1 $(d_rlfe)/usr/share/man/man1/.

ifneq ($(build64),)
	rm -rf $(d64)
	mkdir -p $(d64)/usr
	$(MAKE) -C $(builddir64) install \
	    CC="$(CC64)" \
	    CFLAGS="-g -O2 -D_REENTRANT" \
	    SHOBJ_LDFLAGS='-shared' \
	    SHLIB_XLDFLAGS='$(CC_LINK_FLAGS)-soname,`echo $$@ | sed s/\\..$$$$//`' \
	    SHLIB_LIBS=-lncurses \
	    prefix=$(PWD)/$(d64)/usr \
	    mandir=$(PWD)/$(d64)/usr/share/man \
	    infodir=$(PWD)/$(d64)/usr/share/info

	dh_installdirs -p$(p_rl64) \
	    lib64 \
	    usr/share/doc
	cp -p $(d64)/usr/lib/lib{history,readline}.so.$(libversion) \
		$(d_rl64)/lib64/
	ln -s libhistory.so.$(libversion) \
		$(d_rl64)/lib64/libhistory.so.$(soversion)
	ln -s libreadline.so.$(libversion) \
		$(d_rl64)/lib64/libreadline.so.$(soversion)

	dh_installdirs -p$(p_rld64) \
	    usr/lib64 \
	    usr/share/doc
	ln -s /lib64/libhistory.so.$(soversion) \
		$(d_rld64)/usr/lib64/libhistory.so
	ln -s /lib64/libreadline.so.$(soversion) \
		$(d_rld64)/usr/lib64/libreadline.so
	mv $(d64)/usr/lib/lib{history,readline}.a $(d_rld64)/usr/lib64/.
endif

	touch install-stamp

binary-indep: build install

rl-common-only:
	dh_testdir
	dh_testroot
	dh_installdocs -p$(p_comm) debian/inputrc.arrows
	dh_installchangelogs -p$(p_comm)
	dh_installdocs -p$(p_comm)
	dh_installchangelogs -p$(p_comm)
	dh_compress -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs -p$(p_rl) \
		USAGE debian/inputrc.arrows
	dh_installchangelogs -p$(p_rl) CHANGES
	dh_installexamples -p$(p_rl) \
		examples/Inputrc
	mkdir -p $(d_rld)/usr/share/doc/$(p_rl)/examples
	cp -p $(builddir)/examples/Makefile examples/*.c \
		$(d_rld)/usr/share/doc/$(p_rl)/examples/
	ln -sf $(p_rl) $(d_rld)/usr/share/doc/$(p_rld)
	ln -sf $(p_rl) $(d_rlg)/usr/share/doc/$(p_rlg)

	dh_installdocs -p$(p_rlfe)
	dh_installchangelogs -p$(p_rlfe)

	dh_strip -p$(p_rl) -p$(p_rld) -p$(p_rlg) -p$(p_rlfe)
	dh_compress -p$(p_rl) -p$(p_rld) -p$(p_rlg) -p$(p_rlfe) \
		-X.c
	dh_makeshlibs -p$(p_rl)
	dh_shlibdeps -p$(p_rl) -p$(p_rld) -p$(p_rlg) -p$(p_rlfe) \
		 -L $(p_rl) -l $(d_rl)/lib

ifneq ($(build64),)
	dh_installdocs -p$(p_rl64) \
		USAGE debian/inputrc.arrows
	dh_installchangelogs -p$(p_rl64) CHANGES
	ln -sf $(p_rl64) $(d_rld64)/usr/share/doc/$(p_rld64)
	dh_compress -p$(p_rl64) -p$(p_rld64)
	dh_makeshlibs -p$(p_rl64)
	dh_shlibdeps -p$(p_rl64) -p$(p_rld64) \
		 -L $(p_rl64) -l $(d_rl64)/lib
endif

	dh_installdeb -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

binary:		binary-indep binary-arch

# rules to patch the unpacked files in the source directory
# ---------------------------------------------------------------------------
# various rules to unpack addons and (un)apply patches.
# 	- patch / apply-patches
#	- unpatch / reverse-patches

patchdir	= debian/patches

# which patches should be applied?
debian_patches = \
	readline50-001 \
	readline50-002 \
	readline50-003 \
	readline50-004 \
	readline50-005 \
	rl-inputrc \
	rl-setenv \
	rl-del-backspace-policy \
	rl-header \
	rl-attribute \
	rl-no-rpath \
	rl-display \
	rl-self-insert \
	rlfe-pts \

#	rl-examples

patch: patch-stamp
apply-patches: patch-stamp

patch-stamp: $(foreach p,$(debian_patches),patch-stamp-$(p))
	echo -e "\nPatches applied in this version:" > pxxx
	for i in $(debian_patches); do \
	  echo -e "\n$$i:" >> pxxx; \
	  sed -n 's/^# *DP: */  /p' $(patchdir)/$$i.dpatch >> pxxx; \
	done
	mv -f pxxx $@

reverse-patches: unpatch
unpatch:
	for stamp in none `ls -1t patch-stamp-* 2>/dev/null`; do \
	  case "$$stamp" in none|patched-stamp|patched-\*) continue; esac; \
	  patch=`echo $$stamp | sed -e 's,patch-stamp-,,'`; \
	  echo "trying to revert patch $$patch ..."; \
	  if [ -x $(patchdir)/$$patch.dpatch ]; then true; else \
	    chmod +x $(patchdir)/$$patch.dpatch; fi; \
	  if $(patchdir)/$$patch.dpatch -unpatch -d $(srcdir); then \
	    echo "reverted $$patch patch."; \
	    rm -f $$stamp; \
	  else \
	    echo "error in reverting $$patch patch."; \
	    exit 1; \
	  fi; \
	done
	rm -f patch-stamp

patch-stamp-%: $(patchdir)/%.dpatch
	if [ -x $< ]; then true; else chmod +x $<; fi
	if [ -f $@ ]; then \
	  echo "$* patches already applied."; exit 1; \
	fi
	$< -patch -d $(srcdir)
	echo "$* patches applied." > $@


.PHONY: binary binary-arch binary-indep clean

# Local Variables:
# mode: makefile
# end: