summaryrefslogtreecommitdiff
path: root/package/debian/rules
blob: acd148eab44a899a6da55b5b95f25b499adeddea (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
#!/usr/bin/make -f
# $Id: rules,v 1.7 2022/01/01 13:01:37 tom Exp $
#
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

PACKAGES.arch  = byacc byacc2

CPPFLAGS	:= $(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS		:= $(shell dpkg-buildflags --get CFLAGS)
LDFLAGS		:= $(shell dpkg-buildflags --get LDFLAGS)

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
        CFLAGS += -O0
else
        CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
        INSTALL_PROGRAM += -s
endif

BYACC_DIR = $(CURDIR)/debian/byacc
BTYACC_DIR = $(CURDIR)/debian/byacc2

BYACC_TMP = t/byacc
BTYACC_TMP = t/byacc2

verbose = # -v

configure = \
	CPPFLAGS="$(CPPFLAGS)" \
	CFLAGS="$(CFLAGS)" \
	LDFLAGS="$(LDFLAGS)" \
	../../configure \
		--host=$(DEB_HOST_GNU_TYPE) \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr \
		--mandir=\$${prefix}/share/man \
		--sysconfdir=/etc \
		--enable-stdnoreturn \
		--program-transform-name='s,^yacc,byacc,'

all: build

config: config-arch
build: build-indep build-arch
install: install-arch
binary: binary-indep binary-arch

config-arch:  $(PACKAGES.arch:%=config-%-stamp)
build-arch:   $(PACKAGES.arch:%=build-%-stamp)
install-arch: $(PACKAGES.arch:%=install-%-stamp)

build-indep:

config-byacc-stamp:
	dh_testdir

	rm -rf $(BYACC_TMP)
	mkdir -p $(BYACC_TMP)
	cd $(BYACC_TMP); $(configure)

	touch $@

config-byacc2-stamp:
	dh_testdir

	rm -rf $(BTYACC_TMP)
	mkdir -p $(BTYACC_TMP)
	cd $(BTYACC_TMP); $(configure) \
		--enable-btyacc \
		--with-max-table-size=123456 \
		--program-transform-name='s,^yacc,byacc2,'

	touch $@

build-byacc-stamp: config-byacc-stamp
	dh_testdir

	cd $(BYACC_TMP); $(MAKE)

	touch $@

build-byacc2-stamp: config-byacc2-stamp
	dh_testdir

	cd $(BTYACC_TMP); $(MAKE)

	touch $@

install-byacc-stamp: build-byacc-stamp
	dh_testdir
	dh_testroot
	dh_installdirs

	cd $(BYACC_TMP); $(MAKE) install DESTDIR=$(BYACC_DIR)
	sed -i '/- an LALR/s,^..N,byacc,' $(BYACC_DIR)/usr/share/man/man1/byacc.1

	touch $@

install-byacc2-stamp: build-byacc2-stamp
	dh_testdir
	dh_testroot
	dh_installdirs

	cd $(BTYACC_TMP); $(MAKE) install DESTDIR=$(BTYACC_DIR)
	sed -i '/- an LALR/s,^..N,byacc2,' $(BTYACC_DIR)/usr/share/man/man1/byacc2.1

	touch $@

clean:
	dh_testdir
	dh_testroot

	dh_clean $(verbose)

	rm -rf t

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_lintian           $(verbose) $(PACKAGES.arch:%=-p%)
	dh_installdocs	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_installexamples   $(verbose) $(PACKAGES.arch:%=-p%)
	dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%) CHANGES

# Build architecture-dependent files here.
binary-arch: build install
ifneq ($(PACKAGES.arch),)
	rm -f $(PACKAGES.arch:%=install-%-stamp)
	dh_testdir
	dh_testroot
	dh_lintian           $(verbose) $(PACKAGES.arch:%=-p%)
	dh_strip	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_compress	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_fixperms	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_installdeb	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_shlibdeps	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_gencontrol	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_md5sums	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_builddeb	     $(verbose) $(PACKAGES.arch:%=-p%)
endif

.PHONY: build clean config config-arch binary binary-indep binary-arch install install-arch