5dd00317f1a2a78dbbb16382dcdfcd2d78d2e65d
[pkg/netris.git] / debian / rules
1 #!/usr/bin/make -f
2 # rules file for netris
3 # copyright 2002-2010 by Gerfried Fuchs <rhonda@debian.at>
4 # Licenced under BSD style
5
6 PKG = netris
7 TMP = $(CURDIR)/debian/$(PKG)
8
9 COPT = -g
10 INSTALL = install
11 INSTALL_FILE    = $(INSTALL) -p    -oroot -groot -m644
12 INSTALL_PROGRAM = $(INSTALL) -p    -oroot -groot -m755
13 INSTALL_SCRIPT  = $(INSTALL) -p    -oroot -groot -m755
14 INSTALL_DIR     = $(INSTALL) -p -d -oroot -groot -m755
15
16 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
17         COPT += -O0
18 else
19         COPT += -O2
20 endif
21 ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
22         INSTALL_PROGRAM += -s
23         STRIP = true
24 endif
25 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
26         NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
27         MAKEFLAGS += -j$(NUMJOBS)
28 endif
29
30
31
32 include /usr/share/quilt/quilt.make
33
34 clean: unpatch
35         $(checkdir)
36         $(checkroot)
37         -rm -rf $(TMP) debian/substvars debian/files \
38                 build-stamp install-stamp config.h .depend
39         [ ! -f Makefile ] || $(MAKE) clean
40         -rm -rf Makefile
41
42
43 build: build-stamp
44 build-stamp: patch
45         $(checkdir)
46         ./Configure -g
47         $(MAKE) COPT="$(COPT)"
48         touch build-stamp
49
50
51 install: install-stamp
52 install-stamp: build
53         $(checkdir)
54         $(checkroot)
55         -rm -rf $(TMP)
56         $(INSTALL_DIR) $(TMP)
57         cd $(TMP) && $(INSTALL_DIR) usr/games usr/share/man/man6 \
58                 usr/share/doc/$(PKG)/examples
59         $(INSTALL_PROGRAM) netris $(TMP)/usr/games
60         $(INSTALL_PROGRAM) sr     $(TMP)/usr/games/netris-sample-robot
61         test "$(STRIP)" != true || strip \
62                 --remove-section=.comment --remove-section=.note \
63                 $(TMP)/usr/games/*
64         $(INSTALL_FILE) debian/netris*.6 $(TMP)/usr/share/man/man6
65         $(INSTALL_FILE) FAQ robot_desc   $(TMP)/usr/share/doc/$(PKG)
66         $(INSTALL_FILE) sr.c $(TMP)/usr/share/doc/$(PKG)/examples
67         gzip -9 $(TMP)/usr/share/man/man6/netris*.6 \
68                 $(TMP)/usr/share/doc/$(PKG)/FAQ \
69                 $(TMP)/usr/share/doc/$(PKG)/robot_desc \
70                 $(TMP)/usr/share/doc/$(PKG)/examples/sr.c
71         touch install-stamp
72
73
74 # Build architecture-independent files here.
75 binary-indep: build
76 # We have nothing to do by default.
77
78
79 # Build architecture-dependent files here.
80 binary-arch: build install
81         $(checkdir)
82         $(checkroot)
83         $(INSTALL_DIR) $(TMP)/DEBIAN $(TMP)/usr/share/menu
84         $(INSTALL_FILE) debian/menu      $(TMP)/usr/share/menu/$(PKG)
85         $(INSTALL_FILE) debian/copyright debian/README.Debian \
86                 $(TMP)/usr/share/doc/$(PKG)
87         $(INSTALL_FILE) debian/changelog \
88                 $(TMP)/usr/share/doc/$(PKG)/changelog.Debian
89         gzip -9 $(TMP)/usr/share/doc/$(PKG)/changelog.Debian
90         $(INSTALL_SCRIPT) debian/postinst debian/postrm \
91                 $(TMP)/DEBIAN
92         dpkg-shlibdeps -Tdebian/substvars -dDepends \
93                 $(TMP)/usr/games/netris*
94         dpkg-gencontrol -ldebian/changelog -isp -Tdebian/substvars -pnetris \
95                 -P$(TMP)
96         cd $(TMP) && find * -type f ! -regex '^DEBIAN/.*' -print0 | \
97                 xargs -r0 md5sum > DEBIAN/md5sums
98         dpkg --build $(TMP) ..
99
100
101 binary: binary-indep binary-arch
102
103 define checkdir
104         test -f debian/rules
105 endef
106
107 define checkroot
108         test root = "`whoami`"
109 endef
110
111 .PHONY: clean build install binary-indep binary-arch binary