Run "basename" on our script name when it is a symlink as well. [from 0-9-x]
[ngircd-alex.git] / contrib / Debian / rules
1 #!/usr/bin/make -f
2 #
3 # ngIRCd -- The Next Generation IRC Daemon
4 # Copyright (c)2001-2003 by Alexander Barton (alex@barton.de)
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 # Please read the file COPYING, README and AUTHORS for more information.
11 #
12 # debian/rules for ngIRCd
13 #
14 # $Id: rules,v 1.3 2005/02/07 23:09:31 alex Exp $
15 #
16 # Based on the sample debian/rules that uses debhelper,
17 # GNU copyright 1997 to 1999 by Joey Hess.
18 #
19
20 # Uncomment this to turn on verbose mode.
21 #export DH_VERBOSE=1
22
23 # These are used for cross-compiling and for saving the configure script
24 # from having to guess our platform (since we know it already)
25 DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
26 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
27
28 CFLAGS = -Wall -g
29
30 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
31         CFLAGS += -O0
32 else
33         CFLAGS += -O2
34 endif
35 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
36         INSTALL_PROGRAM += -s
37 endif
38
39 configure-ngircd: configure
40         dh_testdir
41         
42         # configure "standard" variant:
43         ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
44           --prefix=/usr \
45           --sysconfdir=/etc/ngircd \
46           --mandir=\$${prefix}/share/man \
47           --with-syslog --with-zlib
48
49 configure-ngircd-full: configure
50         dh_testdir
51         
52         # configure "full" variant:
53         ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
54           --prefix=/usr \
55           --sysconfdir=/etc/ngircd \
56           --mandir=\$${prefix}/share/man \
57           --with-syslog --with-zlib --with-tcp-wrappers --with-ident
58
59 build:
60         dh_clean -k
61
62 build-ngircd: build-stamp-ngircd
63 build-stamp-ngircd: configure-ngircd
64         dh_testdir
65         rm -f build-stamp-*
66         
67         # Add here commands to compile the "standard" package:
68         $(MAKE)
69         
70         touch build-stamp-ngircd
71
72 build-ngircd-full: build-stamp-ngircd-full
73 build-stamp-ngircd-full: configure-ngircd-full
74         dh_testdir
75         rm -f build-stamp-*
76         
77         # Add here commands to compile the "full" package:
78         $(MAKE)
79         
80         touch build-stamp-ngircd-full
81
82 clean:
83         dh_testdir
84         dh_testroot
85         rm -f build-stamp*
86         rm -f $(CURDIR)/debian/ngircd-full.default
87         rm -f $(CURDIR)/debian/ngircd-full.init
88         rm -f $(CURDIR)/debian/ngircd-full.postinst
89         
90         # Add here commands to clean up after the build process:
91         -$(MAKE) clean
92         
93 ifneq "$(wildcard /usr/share/misc/config.sub)" ""
94         cp -f /usr/share/misc/config.sub config.sub
95 endif
96 ifneq "$(wildcard /usr/share/misc/config.guess)" ""
97         cp -f /usr/share/misc/config.guess config.guess
98 endif
99         dh_clean
100
101 install: install-ngircd install-ngircd-full
102
103 install-ngircd: build-ngircd
104         dh_testdir
105         dh_testroot
106         dh_installdirs
107         
108         # Add here commands to install the "standard" package into debian/ngircd:
109         $(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd
110         rm $(CURDIR)/debian/ngircd/usr/share/doc/ngircd/INSTALL*
111         rm $(CURDIR)/debian/ngircd/usr/share/doc/ngircd/COPYING*
112         mkdir -p $(CURDIR)/debian/ngircd/var/run/ircd
113         cat $(CURDIR)/debian/ngircd/usr/share/doc/ngircd/sample-ngircd.conf | \
114          sed -e "s/;ServerUID = 65534/ServerUID = irc/g" | \
115          sed -e "s/;ServerGID = 65534/ServerGID = irc/g" | \
116          sed -e "s/;MotdFile = \/usr\/local\/etc\/ngircd.motd/MotdFile = \/etc\/ngircd\/ngircd.motd/g" | \
117          sed -e "s/;PidFile = \/var\/run\/ngircd\/ngircd.pid/PidFile = \/var\/run\/ircd\/ngircd.pid/g" \
118          >$(CURDIR)/debian/ngircd/etc/ngircd/ngircd.conf
119         touch $(CURDIR)/debian/ngircd/etc/ngircd/ngircd.motd
120
121 install-ngircd-full: build-ngircd-full
122         dh_testdir
123         dh_testroot
124         dh_installdirs
125         
126         # Add here commands to install the "full" package into debian/ngircd-full:
127         $(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd-full
128         rm $(CURDIR)/debian/ngircd-full/usr/share/doc/ngircd/INSTALL*
129         rm $(CURDIR)/debian/ngircd-full/usr/share/doc/ngircd/COPYING*
130         mv $(CURDIR)/debian/ngircd-full/usr/share/doc/ngircd \
131          $(CURDIR)/debian/ngircd-full/usr/share/doc/ngircd-full
132         mkdir -p $(CURDIR)/debian/ngircd-full/var/run/ircd
133         cat $(CURDIR)/debian/ngircd-full/usr/share/doc/ngircd-full/sample-ngircd.conf | \
134          sed -e "s/;ServerUID = 65534/ServerUID = irc/g" | \
135          sed -e "s/;ServerGID = 65534/ServerGID = irc/g" | \
136          sed -e "s/;MotdFile = \/usr\/local\/etc\/ngircd.motd/MotdFile = \/etc\/ngircd\/ngircd.motd/g" | \
137          sed -e "s/;PidFile = \/var\/run\/ngircd\/ngircd.pid/PidFile = \/var\/run\/ircd\/ngircd.pid/g" \
138          >$(CURDIR)/debian/ngircd-full/etc/ngircd/ngircd.conf
139         touch $(CURDIR)/debian/ngircd-full/etc/ngircd/ngircd.motd
140
141 # Build architecture-independent files here.
142 binary-indep:
143         # We have nothing to do by default.
144
145 # Build architecture-dependent files here.
146 binary-arch: build install
147         ln -s $(CURDIR)/debian/ngircd.default \
148          $(CURDIR)/debian/ngircd-full.default
149         ln -s $(CURDIR)/debian/ngircd.init \
150          $(CURDIR)/debian/ngircd-full.init
151         ln -s $(CURDIR)/debian/ngircd.postinst \
152          $(CURDIR)/debian/ngircd-full.postinst
153         
154         dh_testdir
155         dh_testroot
156         dh_installchangelogs -a -A ChangeLog
157         dh_installdocs -a
158         dh_installinit -a
159         dh_strip -a
160         dh_compress -a
161         dh_fixperms -a
162         dh_installdeb -a
163         dh_shlibdeps -a
164         dh_gencontrol -a
165         dh_md5sums -a
166         dh_builddeb -a
167
168 binary: binary-indep binary-arch
169
170 .PHONY: build clean binary-indep binary-arch binary install 
171
172 # -eof-