Merge branch 'patch-19' of https://github.com/gjones2/Freeside
[freeside.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 # Uncomment this to turn on verbose mode.
5 #export DH_VERBOSE=1
6
7 # If set to a true value then MakeMaker's prompt function will
8 # always return the default without waiting for user input.
9 #export PERL_MM_USE_DEFAULT=1
10
11 PERL   ?= /usr/bin/perl
12 #PACKAGE = $(shell dh_listpackages)
13 PACKAGE = freeside
14 TMP     = $(CURDIR)/debian/$(PACKAGE)
15 #DBC_SCRIPTS = $(TMP)/usr/share/dbconfig-common/scripts/freeside
16
17 ##this is gotten from dbconfig-common
18 #DB_TYPE = db_type_is_configured_during_pkg_install_by_dbconfig-common_not_at_build_time
19
20 #no chance, it doesn't get backslash-interpolted now...
21 ##DEBVERSION                    = `head -1 debian/changelog | cut -d')' -f1 | cut -c11-`
22 #DEBVERSION                    = 1.7.3~rc2-1
23 #export VERSION                = $(DEBVERSION) (Debian)
24
25 #export FREESIDE_CONF          = /etc/freeside
26 #export FREESIDE_LOG           = /var/log/freeside
27 #export FREESIDE_LOCK          = /var/lock/freeside
28 #export FREESIDE_CACHE         = $(TMP)/var/cache/freeside
29 #FREESIDE_CACHE         = $(TMP)/var/cache/freeside
30
31 #XXX huh?
32 #export FREESIDE_EXPORT        = /var/spool/freeside
33
34 export FREESIDE_CONF = $(TMP)/usr/local/etc/freeside
35 export FREESIDE_LOG = $(TMP)/usr/local/etc/freeside
36 export FREESIDE_LOCK = $(TMP)/usr/local/etc/freeside
37 export FREESIDE_CACHE = $(TMP)/usr/local/etc/freeside
38 export FREESIDE_EXPORT = $(TMP)/usr/local/etc/freeside
39
40 #XXX own subdir?
41 #export MASON_HANDLER          = $(TMP)-webui/usr/share/freeside/handler.pl
42 export MASON_HANDLER=$(TMP)-webui/usr/local/etc/freeside/handler.pl
43
44 #export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui/usr/share/freeside/www
45 export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui/var/www/freeside
46 export INIT_FILE              = $(TMP).init
47 export INIT_INSTALL           = /bin/true
48 export HTTPD_RESTART          = /bin/true
49 #export APACHE_CONF            = $(TMP)-webui/etc/apache2/conf.d
50 export APACHE_CONF            = $(TMP)-webui/etc/freeside/apache2
51 export FREESIDE_RESTART       = /bin/true
52
53 #XXX root?
54 export INSTALLGROUP           = adm
55
56 export SELFSERVICE_MACHINES   = 
57
58 #prompt ?   XXX these are runtime, not buildtime :/
59 #export RT_DOMAIN              = `dnsdomainname`
60 #export RT_TIMEZONE            = `cat /etc/timezone`
61
62 #export HOSTNAME               = `hostname -f`
63 #export FREESIDE_URL           = http://$(HOSTNAME)/freeside/
64
65 #specific to deb pkg, for purposes of saving off a permanent copy of default
66 #config for postinst and that sort of thing
67 #export DIST_CONF           = $(TMP)/usr/share/freeside/default_conf
68
69 #XXX yuck.  proper RT layout is entirely necessary
70 #this seems to infect way to much of RT with the build location, requiring
71 # a kludge to hack it out afterwords.  look into using fakeroot (didn't
72 # realize it would need to be explicit argh)
73 # (but leaving it for now, otherwise can't get RT to put files where we need em)
74 #export RT_PATH                = $(TMP)/var/opt/freeside/rt
75
76 # This has to be exported to make some magic below work.
77 export DH_OPTIONS
78
79 configure: configure-stamp
80 configure-stamp:
81         dh_testdir
82         # Add here commands to configure the package.
83         
84         touch configure-stamp
85
86
87 build: build-stamp
88 build-stamp: 
89         dh_testdir
90         # Add commands to compile the package here
91         
92         ( cd FS/ && $(PERL) Makefile.PL INSTALLDIRS=vendor )
93
94         $(MAKE) -e perl-modules
95
96         #TEST#
97
98         touch $@
99
100 clean:
101         dh_testdir
102         dh_testroot
103         dh_clean build-stamp install-stamp
104
105         # Add here commands to clean up after the build process.
106         $(MAKE) -e clean
107         #|| true #XXX freeside clean target fucked
108
109         dh_clean 
110
111 install: install-stamp
112 install-stamp: build-stamp
113         dh_testdir
114         dh_testroot
115         dh_clean -k
116         dh_installdirs
117
118         # Add here commands to install package into
119         # debian/<package>-whatever.
120         ( cd FS/ && $(MAKE) -e DESTDIR=$(TMP)-lib install )
121
122         #false laziness w/install-perl-modules now
123         #install this for postinst later (no create-config)
124         ##install -d $(DIST_CONF)
125         #install conf/[a-z]* $(DEFAULT_CONF)
126         #CVS is not [a-z]
127         ##install `ls -d conf/[a-z]* | grep -v CVS` $(DIST_CONF)
128
129         install -d $(FREESIDE_DOCUMENT_ROOT)
130         install -d $(FREESIDE_CACHE)/masondata #MASONDATA
131         $(MAKE) -e DESTDIR=$(TMP)-webui install-docs
132
133         #hack the build dir out of Freeside too.  oh yeah, sucky.
134         perl -p -i -e "\
135           s'${TMP}(-webui)?''g;\
136         " ${TMP}-webui/usr/share/freeside/handler.pl \
137           ${TMP}/usr/share/perl5/FS/* \
138           ${TMP}/usr/share/perl5/FS/*/* \
139           ${TMP}/usr/bin/*
140
141         #rm -r $(FREESIDE_DOCUMENT_ROOT).*
142
143         install -d $(APACHE_CONF)
144         #install debian/freeside.apache-alias.conf $(APACHE_CONF)/freeside-alias.conf
145         #FREESIDE_DOCUMENT_ROOT=/usr/share/freeside/www MASON_HANDLER=/usr/share/freeside/handler.pl FREESIDE_CONF=/etc/freeside $(MAKE) -e install-apache
146         $(MAKE) -e install-apache
147
148         $(MAKE) -e install-init
149
150         #RT
151         #(configure-rt)
152         $(MAKE) -e configure-rt
153
154         ## XXX need to adjust db-type, db-database, db-rt-user, db-rt-pass
155         ## based on info from dbc
156         #( cd rt; \
157         #  cp config.layout.in config.layout; \
158         #  perl -p -i -e "\
159         #    s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
160         #    s'%%%MASONDATA%%%'${FREESIDE_CACHE}/masondata'g;\
161         #  " config.layout; \
162         #  ./configure --prefix=${RT_PATH} \
163         #              --enable-layout=Freeside \
164         #              --with-db-type=Pg \
165         #              --with-db-dba=freeside \
166         #              --with-db-database=_DBC_DBNAME_ \
167         #              --with-db-rt-user=_DBC_DBUSER_ \
168         #              --with-db-rt-pass=_DBC_DBPASS_ \
169         #              --with-web-user=freeside \
170         #              --with-web-group=freeside \
171         #              --with-rt-group=freeside \
172         #)
173
174         ##(create-rt)
175         #$(MAKE) -e create-rt
176
177         #install -d $(RT_PATH)
178         #( cd rt; make install )
179         ##hack the build dir out of RT.  yeah, sucky.
180         #perl -p -i -e "\
181         #  s'${TMP}''g;\
182         #" ${RT_PATH}/etc/RT_Config.pm \
183         #  ${RT_PATH}/lib/RT.pm \
184         #  ${RT_PATH}/bin/mason_handler.fcgi \
185         #  ${RT_PATH}/bin/mason_handler.scgi \
186         #  ${RT_PATH}/bin/standalone_httpd \
187         #  ${RT_PATH}/bin/webmux.pl \
188         #  ${RT_PATH}/bin/rt-crontool \
189         #  ${RT_PATH}/sbin/rt-dump-database \
190         #  ${RT_PATH}/sbin/rt-setup-database
191         #
192         ##hack @INC dir out of RT (well, handler.pl) too.
193         #perl -p -i -e "\
194         #  s'/opt/rt3/'/var/opt/freeside/rt/'g;\
195         #" ${TMP}-webui/usr/share/freeside/handler.pl
196
197         #mv ${RT_PATH}/etc/RT_Config.pm ${RT_PATH}/etc/RT_Config.pm.dbc
198
199         #perl -p -i -e "\
200         #  s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
201         #  s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
202         #  s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
203         #" ${RT_PATH}/etc/RT_SiteConfig.pm
204
205         #install -D debian/dbconfig-common.install $(DBC_SCRIPTS)/install/pgsql
206         #install -D debian/dbconfig-common.install $(DBC_SCRIPTS)/install/mysql
207         
208         #install -D debian/dbconfig-common.upgrade $(DBC_SCRIPTS)/upgrade/pgsql/$(DEBVERSION)
209         #install -D debian/dbconfig-common.upgrade $(DBC_SCRIPTS)/upgrade/mysql/$(DEBVERSION)
210         
211         dh_install
212
213         touch $@
214
215 binary-arch:
216 # We have nothing to do here for an architecture-independent package
217
218 binary-indep: build install
219         dh_testdir
220         dh_testroot
221         dh_installdocs #freeside.docs README AGPL
222         dh_installexamples eg/*
223 #       dh_installmenu
224         dh_installdebconf       
225 #       dh_installlogrotate     
226         dh_installinit
227         dh_installcron
228 #       dh_installinfo
229         dh_installman
230         dh_perl
231         dh_link
232         dh_compress 
233         dh_fixperms
234         dh_installdeb
235         dh_gencontrol
236         dh_md5sums
237         dh_builddeb
238
239 binary: binary-indep binary-arch
240 .PHONY: build clean binary-indep binary-arch binary install