Merge branch 'master' of git.freeside.biz:/home/git/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 expory FREESIDE_SS = $(TMP)/usr/share/docs/freeside
40
41 #XXX own subdir?
42 #export MASON_HANDLER          = /usr/share/freeside/handler.pl
43 export MASON_HANDLER=$(TMP)-webui/usr/local/etc/freeside/handler.pl
44
45 #export FREESIDE_DOCUMENT_ROOT = /usr/share/freeside/www
46 export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui/var/www/freeside
47 export INIT_FILE              = $(TMP).init
48 export INIT_INSTALL           = /bin/true
49 export HTTPD_RESTART          = /bin/true
50 #export APACHE_CONF           = /etc/apache2/conf.d
51 export APACHE_CONF            = $(TMP)-webui/etc/freeside/apache2
52 export FREESIDE_RESTART       = /bin/true
53
54 #XXX root?
55 export INSTALLGROUP           = adm
56
57 export SELFSERVICE_MACHINES   = 
58
59 #prompt ?   XXX these are runtime, not buildtime :/
60 export RT_DOMAIN              =  freeside.biz
61 export RT_TIMEZONE            = US/Eastern
62 export HOSTNAME               = localhost
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           = /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)/opt/rt3
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 DESTDIR=${TMP}-lib 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
121         ( cd FS/ && $(MAKE) -e DESTDIR=$(TMP)-lib install )
122
123         install -d $(FREESIDE_DOCUMENT_ROOT)
124         install -d $(TMP)-webui/usr/local/etc/freeside/
125         install -d $(FREESIDE_CACHE)/masondata #MASONDATA
126         $(MAKE) -e DESTDIR=$(TMP)-webui install-docs
127
128
129         # Ugly hack, why is handler.pl not being "handled" by install-docs
130         install -D htetc/handler.pl DESTDIR=$(FREESIDE_CACHE)
131
132         # Create Apache configurations
133         install -d $(APACHE_CONF)
134         $(MAKE) -e DESTDIR=$(APACHE_CONF) install-apache
135
136         #Hack the build dir out of apache config
137
138         perl -p -i -e "\
139          s'${TMP}(-webui)?''g;\
140         "  $(TMP)-webui/etc/freeside/apache2/*
141
142         # Install configuration files, hack what to do???
143         $(MAKE) -e DESTDIR=$(TMP) create-config
144         $(MAKE) -e DESTDIR=$(TMP) install-init
145
146         #hack the build dir out of Freeside too.  oh yeah, sucky.
147         perl -p -i -e "\
148           s'${TMP}(-webui)?''g;\
149         " ${TMP}-webui/usr/local/etc/freeside/handler.pl 
150
151         #back the build dur out of lib
152         perl -p -i -e "\
153           s'${TMP}-lib?''g;\
154           s'${TMP}(-webui)?''g;\
155         " ${TMP}-webui/usr/local/etc/freeside/handler.pl \
156           ${TMP}-lib/usr/share/perl5/FS/*.pm \
157           ${TMP}-lib/usr/share/perl5/FS/*/*.pm 
158         
159         #hack the build dir out of Freeside binaries
160
161         perl -p -i -e "\
162           s'${TMP}?''g;\
163         " ${TMP}-lib/usr/bin/* \
164
165         #RT Config
166
167         ( cd rt; \
168           cp config.layout.in config.layout; \
169           perl -p -i -e "\
170             s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
171             s'%%%MASONDATA%%%'${FREESIDE_CACHE}/masondata'g;\
172           " config.layout; \
173           ./configure --prefix=${RT_PATH} \
174                 --enable-layout=Freeside \
175                 --with-db-type=Pg \
176                 --with-db-dba=freeside \
177                 --with-db-database=freeside \
178                 --with-db-rt-user=freeside \
179                 --with-db-rt-pass="" \
180                 --with-web-user=freeside \
181                 --with-web-group=freeside \
182                 --with-rt-group=freeside \
183                 --with-web-handler=modperl2 )
184
185         ##(create-rt)
186         #$(MAKE) -e create-rt
187         install -d $(RT_PATH)
188         ( cd rt; make install )
189         
190         ##hack the build dir out of RT.  yeah, sucky.
191
192         perl -p -i -e "\
193         s'${TMP}(-webui)''g;\
194         s'${TMP}''g;\
195         " ${TMP}/opt/rt3/etc/*.pm \
196                 ${TMP}/opt/rt3/lib/*.pm \
197                 ${TMP}/opt/rt3/lib/RT/*.pm \
198                 ${TMP}/opt/rt3/etc/upgrade/* \
199                 ${TMP}/opt/rt3/sbin/* \
200                 ${TMP}/opt/rt3/bin/* \
201
202         # Default RT Settings
203         perl -p -i -e "\
204                 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
205                 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
206                 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
207                 " ${RT_PATH}/etc/RT_SiteConfig.pm
208
209         dh_install
210
211         touch $@
212
213 binary-arch:
214 # We have nothing to do here for an architecture-independent package
215
216 binary-indep: build install
217         dh_testdir
218         dh_testroot
219         dh_installdeb install
220         dh_installdocs #freeside.docs README AGPL
221         dh_installexamples eg/*
222 #       dh_installmenu
223         dh_installdebconf       
224 #       dh_installlogrotate     
225         dh_installinit --no-start 
226         dh_installcron
227 #       dh_installinfo
228         dh_installman
229         dh_perl
230         dh_link
231         dh_compress 
232         dh_fixperms
233         dh_installdeb
234         dh_gencontrol
235         dh_md5sums
236         dh_builddeb
237
238 binary: binary-indep binary-arch
239 .PHONY: build clean binary-indep binary-arch binary install