1#!/usr/bin/make -f
2# -*- makefile -*-
3
4# Uncomment this to turn on verbose mode.
5#export DH_VERBOSE=1
6
7export SHELL=/bin/bash
8
9CFLAGS = -g
10
11ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
12	CFLAGS += -O0
13else
14	CFLAGS += -O2
15endif
16ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
17	INSTALL_PROGRAM += -s
18endif
19
20LANGUAGES=nl es
21
22configure: configure-stamp
23configure-stamp: patch-stamp
24	cp -p /usr/share/misc/config.* .
25	yes | /bin/bash ./configure \
26		--with-HTML=yes \
27		--with-UTMP=auto \
28		--with-DIR_BIN="/usr/bin" \
29		--with-DIR_LIBDATA="/etc/hylafax" \
30		--with-DIR_LIB="/usr/lib/hylafax" \
31		--with-DIR_LIBEXEC="/usr/sbin" \
32		--with-DIR_MAN="/usr/share/man" \
33		--with-DIR_SBIN="/usr/sbin" \
34		--with-DIR_LOCKS="/var/lock" \
35		--with-PATH_AFM="/usr/share/fonts/type1/gsfonts" \
36		--with-DIR_LOCALE="/usr/share/locale" \
37		--with-FONTMAP="/usr/share/gs-esp/8.15/lib:/usr/share/gs-esp/7.07/lib:/usr/share/gs/6.53" \
38		--with-DIR_HTML="/usr/share/doc/hylafax" \
39		--with-DIR_CGI="/usr/lib/cgi-bin" \
40		--with-HTMLPATH="/doc/hylafax" \
41		--with-SYSGID="root" \
42		--with-SYSUID="root" \
43		--with-PATH_GETTY="/etc/hylafax/getty-link" \
44		--with-PATH_VGETTY="/etc/hylafax/vgetty-link" \
45		--with-PATH_EGETTY="/etc/hylafax/egetty-link" \
46		--with-PATH_SENDMAIL="/usr/sbin/sendmail" \
47		--with-PATH_GSRIP="/usr/bin/gs" \
48		--with-MANSCHEME="bsd-source-gzip-strip" \
49		--with-INSTALL='${PORT}/../debian/install ${PORT}' \
50		--with-LIBZ="-lz" \
51		--with-ZLIBINC="-I/usr/include" \
52		--with-CONFIG_MAXGID="65534" \
53		--with-CMP="/usr/bin/cmp" \
54		--with-COL="/usr/bin/col" \
55		--with-MKFIFO="/usr/bin/mkfifo" \
56		--with-SORT="/usr/bin/sort" \
57		--with-OPTIMIZER="$(CFLAGS)" \
58		--with-MANDIR="/usr/share/man" \
59		--with-PATH_IMPRIP="/usr/bin/psrip"
60#		--with-FUSER="/bin/fuser" \
61#		--with-AWK="/usr/bin/awk" \
62#		--with-BASE64ENCODE="/usr/bin/mimencode" \
63#		--with-MIMENCODE="/usr/bin/mimencode" \
64#		--with-UUENCODE="/usr/bin/uuencode" \
65#		--with-QPENCODE="/usr/bin/mimencode -q"
66
67	touch configure-stamp
68
69build: build-arch
70
71build-arch: build-arch-stamp
72build-arch-stamp: configure-stamp
73#	$(MAKE) all COPTIONS="$(CFLAGS)"
74	$(MAKE) all
75	touch build-arch-stamp
76
77clean: clean1 unpatch
78clean1:
79	dh_testdir
80	dh_testroot
81	rm -f build-arch-stamp configure-stamp
82	[ ! -f Makefile ] || make distclean
83	[ ! -d man/cman.apps ] \
84	    || rmdir man/cman.apps man/cman.files man/sman.apps man/sman.files
85	 rm -f port/Makefile port/install.sh port/mkdepend
86	rm -f config.{guess,sub}
87	rm -f dummy xgnu.c dummy.c xmakeinc t dummy.o dummy.C confMakefile config.log a.out
88	dh_clean
89
90PWD		:= $(shell pwd)
91p_client	= hylafax-client
92p_server	= hylafax-server
93
94d_client	= debian/$(p_client)
95d_server	= debian/$(p_server)
96
97install: install-client install-server
98
99install-server:
100	dh_testdir
101	dh_testroot
102	dh_clean -k -p$(p_server)
103
104	: # install server package
105	dh_installdirs -p$(p_server) \
106		etc/hylafax \
107		usr/sbin \
108		var/log/hylafax \
109		usr/lib/hylafax/bin \
110		var/spool/hylafax/{archive,client,config,dev,info,log,bin,etc} \
111		var/spool/hylafax/{recvq,status,sendq,doneq,docq,tmp,pollq} \
112		usr/share/man/{man5,man8} \
113		usr/share/locale \
114		usr/share/lintian/overrides
115
116	cp -p debian/hosts.hfaxd hfaxd/hfaxd.conf util/cover.templ \
117		etc/dialrules etc/dialrules.sf-ba etc/dialrules.europe \
118		etc/lutRS18.pcf \
119	    $(d_server)/etc/hylafax/.
120	cp -p debian/hylafax.config $(d_server)/etc/hylafax/config
121	cp -pR etc/templates $(d_server)/etc/hylafax/
122	rm -r $(d_server)/etc/hylafax/templates/html-sample1
123
124	cp -p util/{faxmsg,faxconfig,faxmodem,faxstate,faxwatch} \
125		util/{faxinfo,tiffcheck,typetest,dialtest,faxadduser,faxdeluser} \
126		faxd/{faxq,faxqclean,faxgetty,faxsend} \
127		faxd/{pagesend,tsitest,tagtest,cqtest} \
128		faxd/choptest \
129		hfaxd/hfaxd \
130		etc/ondelay \
131		etc/lockname \
132	    $(d_server)/usr/sbin/.
133	for i in \
134	  util/xferfaxstats.sh util/recvstats.sh util/faxcron.sh \
135	  etc/faxaddmodem.sh etc/faxsetup.sh etc/probemodem.sh; \
136	do \
137	  b=`basename $$i .sh`; \
138	  install -p $$i $(d_server)/usr/sbin/$$b; \
139	done
140	for i in \
141	  util/{ps2fax.gs.sh,pdf2fax.gs.sh,pcl2fax.sh,tiff2fax.sh,tiff2pdf.sh} \
142	  util/{archive.sh,notify.sh,notify-4.1.sh,faxrcvd.sh,pollrcvd.sh,mkcover.sh,wedged.sh} \
143	  util/{common-functions.sh,dictionary.sh,qp-encode.awk,b64-encode.awk}; \
144	do \
145	  b=`basename $$i .sh`; \
146	  install -p $$i $(d_server)/var/spool/hylafax/bin/$$b; \
147	done
148	install -p util/notify.awk $(d_server)/var/spool/hylafax/bin/.
149	chmod a-x $(d_server)/var/spool/hylafax/bin/{dictionary,common-functions}
150
151	cp -p config/[a-z]* $(d_server)/var/spool/hylafax/config/.
152
153	ln -sf faxmsg $(d_server)/usr/sbin/faxanswer
154	ln -sf faxmsg $(d_server)/usr/sbin/faxabort
155	ln -sf faxmsg $(d_server)/usr/sbin/faxquit
156	ln -sf faxmsg $(d_server)/usr/sbin/faxlock
157#	ln -sf /etc/hylafax $(d_server)/var/spool/hylafax/etc
158#	ln -sf ps2fax.gs $(d_server)/var/spool/hylafax/bin/ps2fax
159#	ln -sf pdf2fax.gs $(d_server)/var/spool/hylafax/bin/pdf2fax
160
161	: # install server man pages
162	for i in man/sman.files/*.4f; do \
163	  b=`basename $$i .4f`; \
164	  cp -p $$i $(d_server)/usr/share/man/man5/$$b.5; \
165	done
166	for i in man/sman.apps/*.1m; do \
167	  b=`basename $$i .1m`; \
168	  cp -p $$i $(d_server)/usr/share/man/man8/$$b.8; \
169	done
170	for i in debian/man/*.8; do \
171	  b=`basename $$i .8`; \
172	  cp -p $$i $(d_server)/usr/share/man/man8/$$b.8; \
173	done
174
175	# i18n mo files
176	for l in $(LANGUAGES); do \
177		mkdir $(d_server)/usr/share/locale/$$l; \
178		mkdir $(d_server)/usr/share/locale/$$l/LC_MESSAGES; \
179		cp po/hylafax-server/$$l.mo $(d_server)/usr/share/locale/$$l/LC_MESSAGES/hylafax-server.mo; \
180	done
181
182	# override lintian warnings
183	cp -p debian/lintian.override.hylafax-server \
184		$(d_server)/usr/share/lintian/overrides/$(p_server)
185
186	dh_installexamples -p$(p_server) debian/examples/*
187
188	install --mode=a+rx -p debian/copy_configuration_from_spool $(d_server)/usr/lib/hylafax/bin/
189	dh_install -p$(p_server) --list-missing
190
191install-client:
192	dh_testdir
193	dh_testroot
194	dh_clean -k -p$(p_client)
195
196	: # install client package
197	dh_installdirs -p$(p_client) \
198		etc/hylafax \
199		usr/bin \
200		usr/lib \
201		usr/share/man/{man1,man5} \
202		usr/share/hylafax \
203		usr/share/doc/hylafax-client/faxmail \
204		usr/share/locale \
205		usr/share/lintian/overrides
206
207	cp -p debian/hyla.conf faxcover/faxcover.ps faxmail/faxmail.ps \
208		libhylafax/typerules \
209	    $(d_client)/etc/hylafax/.
210	touch $(d_client)/etc/hylafax/faxcover.ps
211	cp -p libhylafax/pagesizes $(d_client)/usr/share/hylafax/.
212	install -p util/textfmt faxalter/faxalter faxcover/faxcover \
213		faxmail/faxmail faxrm/faxrm faxstat/faxstat \
214		sendfax/sendfax sendpage/sendpage \
215	$(d_client)/usr/bin/.
216
217	#i18n .mo files
218	for l in $(LANGUAGES); do \
219		mkdir $(d_client)/usr/share/locale/$$l; \
220		mkdir $(d_client)/usr/share/locale/$$l/LC_MESSAGES; \
221		cp po/libhylafax/$$l.mo $(d_client)/usr/share/locale/$$l/LC_MESSAGES/libhylafax.mo; \
222		cp po/hylafax-client/$$l.mo $(d_client)/usr/share/locale/$$l/LC_MESSAGES/hylafax-client.mo; \
223	done
224
225	install -p faxmail/mailfax.sh-postfix faxmail/mailfax.sh-qmail \
226		faxmail/mailfax.sh-sendmail faxmail/mailfax.sh-smail \
227		faxmail/README \
228	$(d_client)/usr/share/doc/hylafax-client/faxmail/
229
230	for i in faxcover/edit-faxcover.sh; \
231        do \
232          b=`basename $$i .sh`; \
233          install -p $$i $(d_client)/usr/bin/$$b; \
234        done
235
236	: # install client man pages
237	for i in man/cman.files/*.4f; do \
238	  b=`basename $$i .4f`; \
239	  cp -p $$i $(d_client)/usr/share/man/man5/$$b.5; \
240	done
241	for i in man/cman.apps/*.1; do \
242	  b=`basename $$i .1`; \
243	  [ $$b != sgi2fax ] && cp -p $$i $(d_client)/usr/share/man/man1/$$b.1; \
244	done
245
246	# override lintian warnings
247	cp -p debian/lintian.override.hylafax-client \
248		$(d_client)/usr/share/lintian/overrides/$(p_client)
249
250	# needed by sendfax ...
251	mkdir -p $(d_client)/usr/sbin
252	ln -sf ../bin/textfmt $(d_client)/usr/sbin/textfmt
253	dh_install -p$(p_client) --list-missing
254
255# Build architecture dependant packages using the common target.
256binary-arch: build-arch install-client install-server
257	dh_testdir
258	dh_testroot
259	dh_installchangelogs -a doc/RELEASENOTES-6.0.txt
260	dh_installdocs -a -A \
261		debian/README.mgetty debian/README.Debian \
262		TODO CONTRIBUTORS
263	dh_installexamples
264	dh_installdebconf -p$(p_server)
265	dh_installinit -p$(p_server) --name=hylafax --no-start
266	dh_installcron -p$(p_server) --name=hylafax
267	dh_strip -a
268	dh_compress -a
269	dh_fixperms -a
270	chgrp uucp $(d_server)/etc/hylafax
271	chown uucp:uucp \
272	    $(d_server)/var/spool/hylafax/{client,config,dev,info,log,recvq,status,archive,docq,doneq,pollq,sendq,tmp,.}
273	chmod 755 \
274	    $(d_server)/var/spool/hylafax/{archive,docq,doneq,pollq,sendq}
275	chmod 775 $(d_server)/var/spool/hylafax
276	chmod 4777 $(d_server)/var/spool/hylafax/tmp
277	chmod 755  $(d_server)/var/spool/hylafax/dev
278	chown uucp $(d_server)/etc/hylafax/hosts.hfaxd
279	chmod 600  $(d_server)/etc/hylafax/hosts.hfaxd
280
281	dh_makeshlibs -a
282	dh_installdeb -a
283	dh_shlibdeps -phylafax-client \
284		debian/hylafax-client/usr/bin/faxalter \
285		debian/hylafax-client/usr/bin/faxcover \
286		debian/hylafax-client/usr/bin/faxmail \
287		debian/hylafax-client/usr/bin/faxrm \
288		debian/hylafax-client/usr/bin/faxstat \
289		debian/hylafax-client/usr/bin/sendfax \
290		debian/hylafax-client/usr/bin/sendpage \
291		debian/hylafax-client/usr/bin/textfmt
292	dh_shlibdeps -L libfaxutil -phylafax-server \
293		debian/hylafax-server/usr/sbin/choptest \
294		debian/hylafax-server/usr/sbin/cqtest \
295		debian/hylafax-server/usr/sbin/dialtest \
296		debian/hylafax-server/usr/sbin/faxadduser \
297		debian/hylafax-server/usr/sbin/faxconfig \
298		debian/hylafax-server/usr/sbin/faxdeluser \
299		debian/hylafax-server/usr/sbin/faxgetty \
300		debian/hylafax-server/usr/sbin/faxinfo \
301		debian/hylafax-server/usr/sbin/faxmodem \
302		debian/hylafax-server/usr/sbin/faxmsg \
303		debian/hylafax-server/usr/sbin/faxq \
304		debian/hylafax-server/usr/sbin/faxqclean \
305		debian/hylafax-server/usr/sbin/faxsend \
306		debian/hylafax-server/usr/sbin/faxstate \
307		debian/hylafax-server/usr/sbin/faxwatch \
308		debian/hylafax-server/usr/sbin/hfaxd \
309		debian/hylafax-server/usr/sbin/ondelay \
310		debian/hylafax-server/usr/sbin/lockname \
311		debian/hylafax-server/usr/sbin/pagesend \
312		debian/hylafax-server/usr/sbin/tagtest \
313		debian/hylafax-server/usr/sbin/tiffcheck \
314		debian/hylafax-server/usr/sbin/tsitest \
315		debian/hylafax-server/usr/sbin/typetest
316	dh_gencontrol -a
317	dh_md5sums -a
318	dh_builddeb -a
319
320include /usr/share/dpatch/dpatch.make
321
322binary: binary-arch
323.PHONY: build clean clean1 binary-arch binary install install-client install-server configure patch unpatch
324