summaryrefslogtreecommitdiff
path: root/package/debian/rules
blob: 3db7e86c6135dfe160a28cfb2d7ff0ac53bea842 (plain) (blame)
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
#!/usr/bin/make -f
# $Id: rules,v 1.3 2018/05/25 20:03: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 btyacc

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/btyacc

BYACC_TMP = t/byacc
BTYACC_TMP = t/btyacc

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 \
		--program-transform-name='s,^,b,'

all: build

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

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

config-byacc-stamp:
	dh_testdir

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

	touch $@

config-btyacc-stamp:
	dh_testdir

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

	touch $@

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

	cd $(BYACC_TMP); $(MAKE)

	touch $@

build-btyacc-stamp: config-btyacc-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)

	touch $@

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

	cd $(BTYACC_TMP); $(MAKE) install DESTDIR=$(BTYACC_DIR)

	touch $@

clean:
	dh_testdir
	dh_testroot

	dh_clean $(verbose)

	rm -rf t

# 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_installdocs	     $(verbose) $(PACKAGES.arch:%=-p%)
	dh_installexamples   $(verbose) $(PACKAGES.arch:%=-p%)
	dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%) CHANGES
	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-arch install install-arch