38fdcc7f7dc493fde14de3f99cde61c08f485564
[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/share/freeside/handler.pl \
150           ${TMP}/usr/share/perl5/FS/* \
151           ${TMP}/usr/share/perl5/FS/*/* \
152           ${TMP}/usr/bin/*
153
154         #back the build dur out of lib
155         perl -p -i -e "\
156           s'${TMP}-lib?''g;\
157           s'${TMP}(-webui)?''g;\
158         " ${TMP}-webui/usr/local/etc/freeside/handler.pl \
159           ${TMP}-lib/usr/share/perl5/FS/*.pm \
160           ${TMP}-lib/usr/share/perl5/FS/*/*.pm 
161         
162         #hack the build dir out of Freeside binaries
163
164         perl -p -i -e "\
165           s'${TMP}?''g;\
166         " ${TMP}-lib/usr/bin/* \
167
168         #RT Config
169
170         ( cd rt; \
171           cp config.layout.in config.layout; \
172           perl -p -i -e "\
173             s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
174             s'%%%MASONDATA%%%'${FREESIDE_CACHE}/masondata'g;\
175           " config.layout; \
176           ./configure --prefix=${RT_PATH} \
177                 --enable-layout=Freeside \
178                 --with-db-type=Pg \
179                 --with-db-dba=freeside \
180                 --with-db-database=freeside \
181                 --with-db-rt-user=freeside \
182                 --with-db-rt-pass="" \
183                 --with-web-user=freeside \
184                 --with-web-group=freeside \
185                 --with-rt-group=freeside \
186                 --with-web-handler=modperl2 )
187
188         ##(create-rt)
189         #$(MAKE) -e create-rt
190         install -d $(RT_PATH)
191         ( cd rt; make install )
192         
193         ##hack the build dir out of RT.  yeah, sucky.
194
195         perl -p -i -e "\
196         s'${TMP}(-webui)''g;\
197         s'${TMP}''g;\
198         " ${TMP}/opt/rt3/etc/*.pm \
199                 ${TMP}/opt/rt3/lib/*.pm \
200                 ${TMP}/opt/rt3/lib/RT/*.pm \
201                 ${TMP}/opt/rt3/etc/upgrade/* \
202                 ${TMP}/opt/rt3/sbin/* \
203                 ${TMP}/opt/rt3/bin/* \
204
205         # Default RT Settings
206         perl -p -i -e "\
207                 s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
208                 s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
209                 s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
210                 " ${RT_PATH}/etc/RT_SiteConfig.pm
211
212         dh_install
213
214         touch $@
215
216 binary-arch:
217 # We have nothing to do here for an architecture-independent package
218
219 binary-indep: build install
220         dh_testdir
221         dh_testroot
222         dh_installdeb install
223         dh_installdocs #freeside.docs README AGPL
224         dh_installexamples eg/*
225 #       dh_installmenu
226         dh_installdebconf       
227 #       dh_installlogrotate     
228         dh_installinit --no-start 
229         dh_installcron
230 #       dh_installinfo
231         dh_installman
232         dh_perl
233         dh_link
234         dh_compress 
235         dh_fixperms
236         dh_installdeb
237         dh_gencontrol
238         dh_md5sums
239         dh_builddeb
240
241 binary: binary-indep binary-arch
242 .PHONY: build clean binary-indep binary-arch binary install