Imported Upstream version 20220109
[platform/upstream/byacc.git] / package / debian / rules
1 #!/usr/bin/make -f
2 # $Id: rules,v 1.8 2022/01/08 19:53:07 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)
9 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
10 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
11
12 PACKAGES.arch  = byacc byacc2
13
14 QA_FIX          = DEB_BUILD_MAINT_OPTIONS="hardening=+all qa=+bug reproducible=+all"
15
16 CPPFLAGS        := $(shell $(QA_FIX) dpkg-buildflags --get CPPFLAGS)
17 CFLAGS          := $(shell $(QA_FIX) dpkg-buildflags --get CFLAGS)
18 LDFLAGS         := $(shell $(QA_FIX) dpkg-buildflags --get LDFLAGS)
19
20 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
21         CFLAGS += -O0
22 else
23         CFLAGS += -O2
24 endif
25 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
26         INSTALL_PROGRAM += -s
27 endif
28
29 BYACC_DIR = $(CURDIR)/debian/byacc
30 BTYACC_DIR = $(CURDIR)/debian/byacc2
31
32 BYACC_TMP = t/byacc
33 BTYACC_TMP = t/byacc2
34
35 verbose = # -v
36
37 configure = \
38         CPPFLAGS="$(CPPFLAGS)" \
39         CFLAGS="$(CFLAGS)" \
40         LDFLAGS="$(LDFLAGS)" \
41         ../../configure \
42                 --host=$(DEB_HOST_GNU_TYPE) \
43                 --build=$(DEB_BUILD_GNU_TYPE) \
44                 --prefix=/usr \
45                 --mandir=\$${prefix}/share/man \
46                 --sysconfdir=/etc \
47                 --enable-stdnoreturn \
48                 --program-transform-name='s,^yacc,byacc,'
49
50 all: build
51
52 config: config-arch
53 build: build-indep build-arch
54 install: install-arch
55 binary: binary-indep binary-arch
56
57 config-arch:  $(PACKAGES.arch:%=config-%-stamp)
58 build-arch:   $(PACKAGES.arch:%=build-%-stamp)
59 install-arch: $(PACKAGES.arch:%=install-%-stamp)
60
61 build-indep:
62
63 config-byacc-stamp:
64         dh_testdir
65
66         rm -rf $(BYACC_TMP)
67         mkdir -p $(BYACC_TMP)
68         cd $(BYACC_TMP); $(configure)
69
70         touch $@
71
72 config-byacc2-stamp:
73         dh_testdir
74
75         rm -rf $(BTYACC_TMP)
76         mkdir -p $(BTYACC_TMP)
77         cd $(BTYACC_TMP); $(configure) \
78                 --enable-btyacc \
79                 --with-max-table-size=123456 \
80                 --program-transform-name='s,^yacc,byacc2,'
81
82         touch $@
83
84 build-byacc-stamp: config-byacc-stamp
85         dh_testdir
86
87         cd $(BYACC_TMP); $(MAKE)
88
89         touch $@
90
91 build-byacc2-stamp: config-byacc2-stamp
92         dh_testdir
93
94         cd $(BTYACC_TMP); $(MAKE)
95
96         touch $@
97
98 install-byacc-stamp: build-byacc-stamp
99         dh_testdir
100         dh_testroot
101         dh_installdirs
102
103         cd $(BYACC_TMP); $(MAKE) install DESTDIR=$(BYACC_DIR)
104         sed -i '/- an LALR/s,^..N,byacc,' $(BYACC_DIR)/usr/share/man/man1/byacc.1
105
106         touch $@
107
108 install-byacc2-stamp: build-byacc2-stamp
109         dh_testdir
110         dh_testroot
111         dh_installdirs
112
113         cd $(BTYACC_TMP); $(MAKE) install DESTDIR=$(BTYACC_DIR)
114         sed -i '/- an LALR/s,^..N,byacc2,' $(BTYACC_DIR)/usr/share/man/man1/byacc2.1
115
116         touch $@
117
118 clean:
119         dh_testdir
120         dh_testroot
121
122         dh_clean $(verbose)
123
124         rm -rf t
125
126 # Build architecture-independent files here.
127 binary-indep: build install
128         dh_testdir
129         dh_testroot
130         dh_lintian           $(verbose) $(PACKAGES.arch:%=-p%)
131         dh_installdocs       $(verbose) $(PACKAGES.arch:%=-p%)
132         dh_installexamples   $(verbose) $(PACKAGES.arch:%=-p%)
133         dh_installchangelogs $(verbose) $(PACKAGES.arch:%=-p%) CHANGES
134
135 # Build architecture-dependent files here.
136 binary-arch: build install
137 ifneq ($(PACKAGES.arch),)
138         rm -f $(PACKAGES.arch:%=install-%-stamp)
139         dh_testdir
140         dh_testroot
141         dh_lintian           $(verbose) $(PACKAGES.arch:%=-p%)
142         dh_strip             $(verbose) $(PACKAGES.arch:%=-p%)
143         dh_compress          $(verbose) $(PACKAGES.arch:%=-p%)
144         dh_fixperms          $(verbose) $(PACKAGES.arch:%=-p%)
145         dh_installdeb        $(verbose) $(PACKAGES.arch:%=-p%)
146         dh_shlibdeps         $(verbose) $(PACKAGES.arch:%=-p%)
147         dh_gencontrol        $(verbose) $(PACKAGES.arch:%=-p%)
148         dh_md5sums           $(verbose) $(PACKAGES.arch:%=-p%)
149         dh_builddeb          $(verbose) $(PACKAGES.arch:%=-p%)
150 endif
151
152 .PHONY: build clean config config-arch binary binary-indep binary-arch install install-arch