summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 0ff2789289d9a4c24b16bda81c068eab54ee7d60 (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
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
#! /usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1

unexport LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MESSAGES

# architecture dependent variables
DEB_BUILD_GNU_TYPE	:= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_ARCH		:= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_ARCH_OS	:= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
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)

VERSION		:= 3.3
#PKGVERSION	:= $(shell dpkg-parsechangelog \
#			| sed -n '/Version:/s/\(.* \)\(.*\)-2\(.*\)/\2\3/p')
#PKGVERSION	:= 3.0
#dpkg_ctrl_args := -v$(PKGVERSION) -VBinary-Version=$(PKGVERSION)


with_gfdl	= no

CC	= gcc
CFLAGS	= -g -O2
SHELL	= bash
YACC	= bison -y

IX	= install -o 0 -g 0
ID	= install -o 0 -g 0 -m 644

# built with installed libreadline?
with_installed_rl = no

debflags =

PWD	:= $(shell pwd)
p	= vyatta-bash

d	= debian/$(p)

conf_args = \
	--with-curses \
	--disable-net-redirections \
	--enable-largefile \
	--prefix=/usr \
	--infodir=/usr/share/info \
	--mandir=/usr/share/man
ifeq ($(with_installed_rl),yes)
    conf_args += --with-installed-readline
endif

conf_args += --host=$(DEB_HOST_GNU_TYPE)

build: before-build bash-build

before-build:
	: # see #327477, needed to have HAVE_DEV_STDIN defined
	(test -d /dev/fd && test -r /dev/stdin < /dev/null) \
	  || (test -d /proc/self/fd && test -r /dev/stdin < /dev/null)
ifneq (,$(findstring $(DEB_HOST_ARCH_OS), linux freebsd))
	$(CC) $(CFLAGS) -o clear_console debian/clear_console.c -lncurses
endif

# ---------------------------------------------------------------------------
# build standard bash

bash-build:
	$(MAKE) -f debian/rules do-build-bash \
	    bash_src=bash \
	    bash_patches="$(debian_patches)" \
	    build=bash \
	    configure_args="$(conf_args)"
bash-configure:
	$(MAKE) -f debian/rules do-configure-bash \
	    bash_src=bash \
	    bash_patches="$(debian_patches)" \
	    build=bash \
	    configure_args="$(conf_args)"

# ---------------------------------------------------------------------------

check: stamps/stamp-check
stamps/stamp-check: bash-build
	@echo BEGIN test
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
	-sh debian/locale-gen
	LOCPATH=$(PWD)/locales \
		$(MAKE) -C build-bash test 2>&1 | tee build-bash/test-protocol
else
	@echo Suppress 'make' test, because this is cross build
endif
	@echo END test
	touch stamps/stamp-check

# ---------------------------------------------------------------------------

clean:
	dh_testdir
	dh_testroot
	rm -rf stamps build-* bash bashdb
	rm -f debian/README.Debian
	rm -rf locales
	rm -f clear_console
	dh_clean

# ---------------------------------------------------------------------------

install: bash-install

bash-install: bash-build stamps/stamp-install-bash
stamps/stamp-install-bash: stamps/stamp-build-bash
	dh_testdir
	dh_testroot
	dh_clean -k -p$(p)
	dh_installdirs -p$(p) \
		bin

	: # install it
	$(MAKE) -C build-bash install \
		CC='$(CC)' \
		CFLAGS='$(CFLAGS)' \
		YACC="$(YACC)" \
		DESTDIR=$(PWD)/$(d)
	mv $(d)/usr/bin/vbash $(d)/bin/.
	rmdir $(d)/usr/bin

	cat debian/README > debian/README.Debian

	touch stamps/stamp-install-bash

binary-bash: bash-install
	rm -f debian/files
	dh_testdir
	dh_testroot
	dh_installchangelogs -p$(p) bash/CWRU/changelog
	dh_installdocs -p$(p) \
		bash/{CHANGES,NEWS,COMPAT,doc/INTRO,POSIX} \
		debian/{README.Debian,README.abs-guide,README.commands} \
		debian/inputrc.arrows
	dh_strip -p$(p)
	dh_compress -p$(p)
	dh_fixperms -p$(p)
	dh_shlibdeps -p$(p) -- -dPre-Depends $(d)/bin/vbash
	dh_installdeb -p$(p)
	if [ -f "../.VYATTA_DEV_BUILD" ]; then \
		dh_gencontrol -p$(p) -- -v999.dev; \
	else \
		dh_gencontrol -p$(p); \
	fi
	dh_md5sums -p$(p)
	dh_builddeb -p$(p)

binary-arch: binary-bash
binary:	binary-arch

# ---------------------------------------------------------------------------
# common rules for all bash build variations

do-build-$(build): stamps/stamp-build-$(build)
stamps/stamp-build-$(build): stamps/stamp-configure-$(build)
	dh_testdir
	$(MAKE) -C build-$(build) \
		CC='$(CC)' \
		CFLAGS='$(CFLAGS)' \
		YACC="$(YACC)" \
		deb_builddir=build-$(build)/ \
		$(debflags)
	touch stamps/stamp-build-$(build)

do-configure-$(build): stamps/stamp-configure-$(build)
stamps/stamp-configure-$(build): stamps/stamp-unpack-$(bash_src)
	dh_testdir
	rm -rf build-$(build)
	mkdir build-$(build)
	cd build-$(build) && \
	    CC="$(CC)" CFLAGS="$(CFLAGS)" YACC="$(YACC)" \
		../$(bash_src)/configure $(configure_args)
	if ! grep -q '#define HAVE_DEV_STDIN 1' build-$(build)/config.h; then \
	  echo "HAVE_DEV_STDIN not defined, abortig build"; \
	  exit 1; \
	fi
	touch stamps/stamp-configure-$(build)

unpack-$(bash_src): stamps/stamp-unpack-$(bash_src)
stamps/stamp-unpack-$(bash_src):
	mkdir -p stamps
	rm -rf bash-$(VERSION) $(bash_src)
	rm -f stamps/stamp-patch-$(bash_src){,-*}
	tar c --exclude='bash-src.tar' --exclude='debian' --exclude='.git' \
	      --exclude='stamps' --exclude='bash' --exclude='build-bash' \
	      --exclude='build-min' --exclude='build-static' \
	      -f bash-src.tar .
	mkdir -p $(bash_src)
	tar x -C $(bash_src) -f bash-src.tar
	rm -f bash-src.tar
	cp -p /usr/share/misc/config.* $(bash_src)/.
	cp -p /usr/share/misc/config.* $(bash_src)/support/.
	touch stamps/stamp-unpack-$(bash_src)

.PHONY: unpack patch binary binary-arch clean build bash-build \
    check bash-configure binary-bash install bash-install

# Local Variables:
# mode: makefile
# end: