xref: /freebsd/contrib/byacc/package/debian/rules (revision e17f5b1d)
1#!/usr/bin/make -f
2# $Id: rules,v 1.3 2018/05/25 20:03:37 tom Exp $
3#
4# Uncomment this to turn on verbose mode.
5#export DH_VERBOSE=1
6
7# These are used for cross-compiling and for saving the configure script
8# from having to guess our platform (since we know it already)
9DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
10DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
11
12PACKAGES.arch  = byacc btyacc
13
14CPPFLAGS	:= $(shell dpkg-buildflags --get CPPFLAGS)
15CFLAGS		:= $(shell dpkg-buildflags --get CFLAGS)
16LDFLAGS		:= $(shell dpkg-buildflags --get LDFLAGS)
17
18ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
19        CFLAGS += -O0
20else
21        CFLAGS += -O2
22endif
23ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
24        INSTALL_PROGRAM += -s
25endif
26
27BYACC_DIR = $(CURDIR)/debian/byacc
28BTYACC_DIR = $(CURDIR)/debian/btyacc
29
30BYACC_TMP = t/byacc
31BTYACC_TMP = t/btyacc
32
33verbose = # -v
34
35configure = \
36	CPPFLAGS="$(CPPFLAGS)" \
37	CFLAGS="$(CFLAGS)" \
38	LDFLAGS="$(LDFLAGS)" \
39	../../configure \
40		--host=$(DEB_HOST_GNU_TYPE) \
41		--build=$(DEB_BUILD_GNU_TYPE) \
42		--prefix=/usr \
43		--mandir=\$${prefix}/share/man \
44		--sysconfdir=/etc \
45		--program-transform-name='s,^,b,'
46
47all: build
48
49config: config-arch
50build: build-arch
51install: install-arch
52binary: binary-arch
53
54config-arch:  $(PACKAGES.arch:%=config-%-stamp)
55build-arch:   $(PACKAGES.arch:%=build-%-stamp)
56install-arch: $(PACKAGES.arch:%=install-%-stamp)
57
58config-byacc-stamp:
59	dh_testdir
60
61	rm -rf $(BYACC_TMP)
62	mkdir -p $(BYACC_TMP)
63	cd $(BYACC_TMP); $(configure)
64
65	touch $@
66
67config-btyacc-stamp:
68	dh_testdir
69
70	rm -rf $(BTYACC_TMP)
71	mkdir -p $(BTYACC_TMP)
72	cd $(BTYACC_TMP); $(configure) \
73		--enable-btyacc \
74		--with-max-table-size=18000 \
75		--program-transform-name='s,^,bt,'
76
77	touch $@
78
79build-byacc-stamp: config-byacc-stamp
80	dh_testdir
81
82	cd $(BYACC_TMP); $(MAKE)
83
84	touch $@
85
86build-btyacc-stamp: config-btyacc-stamp
87	dh_testdir
88
89	cd $(BTYACC_TMP); $(MAKE)
90
91	touch $@
92
93install-byacc-stamp: build-byacc-stamp
94	dh_testdir
95	dh_testroot
96	dh_installdirs
97
98	cd $(BYACC_TMP); $(MAKE) install DESTDIR=$(BYACC_DIR)
99
100	touch $@
101
102install-btyacc-stamp: build-btyacc-stamp
103	dh_testdir
104	dh_testroot
105	dh_installdirs
106
107	cd $(BTYACC_TMP); $(MAKE) install DESTDIR=$(BTYACC_DIR)
108
109	touch $@
110
111clean:
112	dh_testdir
113	dh_testroot
114
115	dh_clean $(verbose)
116
117	rm -rf t
118
119# Build architecture-dependent files here.
120binary-arch: build install
121ifneq ($(PACKAGES.arch),)
122	rm -f $(PACKAGES.arch:%=install-%-stamp)
123	dh_testdir
124	dh_testroot
125	dh_lintian           $(verbose) $(PACKAGES.arch:%=-p%)
126	dh_installdocs	     $(verbose) $(PACKAGES.arch:%=-p%)
127	dh_installexamples   $(verbose) $(PACKAGES.arch:%=-p%)
128	dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%) CHANGES
129	dh_strip	     $(verbose) $(PACKAGES.arch:%=-p%)
130	dh_compress	     $(verbose) $(PACKAGES.arch:%=-p%)
131	dh_fixperms	     $(verbose) $(PACKAGES.arch:%=-p%)
132	dh_installdeb	     $(verbose) $(PACKAGES.arch:%=-p%)
133	dh_shlibdeps	     $(verbose) $(PACKAGES.arch:%=-p%)
134	dh_gencontrol	     $(verbose) $(PACKAGES.arch:%=-p%)
135	dh_md5sums	     $(verbose) $(PACKAGES.arch:%=-p%)
136	dh_builddeb	     $(verbose) $(PACKAGES.arch:%=-p%)
137endif
138
139.PHONY: build clean config config-arch binary binary-arch install install-arch
140