1#
2# Copyright 1998 - 2011 Double Precision, Inc.  See COPYING for
3# distribution information.
4
5@SET_MAKE@
6
7
8AM_CPPFLAGS=@CPPAUTH@
9
10CLEANFILES=htmllibdir.h ldapsearch webgpg ldapaddressbook.dist \
11	cron.cmd sqwebmail.msg TIMEZONELIST
12DISTCLEANFILES=webmail.authpam
13
14SUBDIRS=images html
15
16scriptdir=@scriptdir@
17script_SCRIPTS=sendit.sh cleancache.pl ldapsearch webgpg
18sysconf_DATA=ldapaddressbook.dist sqwebmaild.dist
19pkglibexecdir=@pkglibexecdir@
20pkglibexec_PROGRAMS=sqwebpasswd
21
22DOCS=SECURITY BUGS TODO SECURITY.html BUGS.html TODO.html
23noinst_DATA=$(DOCS) TIMEZONELIST
24
25#
26#  Because cgibindir is not based on prefix, we must conditionally install
27#  bin_PROGRAMS in install-exec-local, otherwise make distcheck will fail.
28#
29
30noinst_PROGRAMS=sqwebmail sqwebmaild showmsg2html testhtml
31
32COMMONDEPENDENCIES=$(LIBOBJS) ../pcp/libpcp.la ../maildir/libmaildir.la \
33	../rfc2045/librfc2045.la ../rfc822/librfc822.la \
34	../rfc822/libencode.la \
35	../liblock/liblock.la \
36	../http11/libhttp11.la ../cgi/libcgi.la \
37	../ldapaddressbook/libaddressbook.la \
38	../gpglib/libgpg.la \
39	../random128/librandom128.la ../md5/libmd5.la \
40	../numlib/libnumlib.la \
41	@dblibrary@
42COMMONLDADD=$(COMMONDEPENDENCIES) `cat ../pcp/pcp.libs` -lcourier-unicode
43
44noinst_LTLIBRARIES=libwebmail.la
45
46libwebmail_la_SOURCES=filter.c filter.h msg2html.c msg2html.h html.c html.h \
47			buf.c buf.h
48libwebmail_la_DEPENDENCIES=$(COMMONDEPENDENCIES)
49libwebmail_la_LIBADD=$(COMMONLDADD)
50libwebmail_la_LDFLAGS=-static
51
52showmsg2html_SOURCES=showmsg2html.c
53showmsg2html_LDADD=libwebmail.la
54showmsg2html_LDFLAGS=-static
55
56ISPELLSOURCES=sqispell.c ispell.c ispell.h
57
58BUILT_SOURCES=htmllibdir.h
59if HAVE_SGML
60
61GITFILES=sqwebmaild.dist.in
62
63BUILT_SOURCES += $(GITFILES)
64
65$(GITFILES): %: %.git
66	perl -p -e 's/\$$Id:[^\$$]*/\$$Id: '"`git log --pretty=format:\"%H\" -n 1 -- $<`-`date +%Y%m%d%H%M%S`/" <$< >$@.tmp
67	mv -f $@.tmp $@
68endif
69
70EXTRA_DIST=$(DOCS) sqwebmail.pamconf sqwebmail-system-auth.pamconf\
71	 sqwebmail-system-auth2.pamconf\
72           strdup.c strcasecmp.c strncasecmp.c sv-make_timezonelist.pl\
73           $(ISPELLSOURCES) \
74	testhtml.tst testhtml.txt
75
76testhtml_SOURCES=testhtml.c
77testhtml_LDADD=libwebmail.la
78
79#CFLAGS += -Dmalloc=my_malloc -Drealloc=my_realloc -Dfree=my_free -Dstrdup=my_strdup -Dcalloc=my_calloc
80
81if ISPELL
82SQISPELLSOURCES=$(ISPELLSOURCES)
83endif
84
85
86sqwebmaild_SOURCES=acl.c acl.h \
87		addressbook.c addressbook.h args.c attachments.c \
88		auth.c auth.h autoresponse.c autoresponse.h \
89		changepw.c \
90		folder.c folder.h gpg.c gpg.h \
91		ldaplist.c logindomainlist.c logindomainlist.h \
92		maildir.c maildir.h mailfilter.c \
93		mailfilter.h mailinglist.c mailinglist.h newmsg.c newmsg.h \
94		newmsg_create.c	newmsg_newdraft.c pcp.c pcp.h pref.c pref.h \
95		sqconfig.c sqconfig.h sqwebmail.c \
96		strftime.c strftime.h \
97		sqwebmail.h token.c token.h $(SQISPELLSOURCES)
98
99sqwebmaild_LDADD=libwebmail.la @NETLIBS@ @LDAUTH@ -lcourierauth -lpcre
100sqwebmaild_DEPENDENCIES=libwebmail.la
101
102sqwebmail_SOURCES=sqwebmaild.c
103sqwebmail_DEPENDENCIES= ../cgi/libcgi.la
104sqwebmail_LDADD=@NETLIBS@ ../cgi/libcgi.la
105sqwebmail_LDFLAGS=-static
106
107sqwebpasswd_SOURCES=sqwebpasswd.c
108sqwebpasswd_LDADD=@NETLIBS@ @LDAUTH@ -lcourierauth
109
110HTML2TXT=`which lynx 2>/dev/null && echo "lynx -dump -nolist" && exit; echo "links -dump"`
111
112SECURITY: SECURITY.html
113	rm -f SECURITY
114	$(HTML2TXT) $(srcdir)/SECURITY.html >SECURITY
115
116BUGS: BUGS.html
117	rm -f BUGS
118	$(HTML2TXT) $(srcdir)/BUGS.html >BUGS
119
120TODO: TODO.html
121	rm -f TODO
122	$(HTML2TXT) $(srcdir)/TODO.html >TODO
123
124TIMEZONELIST: sv-make_timezonelist.pl
125	rm -f TIMEZONELIST
126	-@PERL@ $(srcdir)/sv-make_timezonelist.pl
127
128install-perms:
129	@$(MAKE) install-perms-recursive
130	@$(MAKE) install-perms-local
131
132install-perms-recursive:
133	@>permissions.dat
134	@SUBDIRS="$(SUBDIRS)" ; for f in $$SUBDIRS ; do ( cd $$f && $(MAKE) $(AM_MAKEFLAGS) install-perms ) ; cat /dev/null >>$$f/permissions.dat ; cat $$f/permissions.dat >>permissions.dat ; done
135
136install-perms-local: install-perms-cache
137	@echo "$(scriptdir)/webgpg 755 bin bin" >>permissions.dat
138	@echo "$(scriptdir)/sendit.sh 755 bin bin" >>permissions.dat
139	@echo "$(scriptdir)/ldapsearch 755 bin bin" >>permissions.dat
140	@echo "$(sysconfdir)/ldapaddressbook.dist 644 root bin config" >>permissions.dat
141
142htmllibdir.h: config.status
143	echo '#define HTMLLIBDIR "@htmldir@"' >htmllibdir.h
144	echo '#define SENDITSH "$(scriptdir)/sendit.sh"' >>htmllibdir.h
145	echo '#define CALENDARMODE "$(sysconfdir)/calendarmode"' >>htmllibdir.h
146	echo '#define LOGINDOMAINLIST "$(sysconfdir)/logindomainlist"' >>htmllibdir.h
147	echo '#define MAXMSGSIZE @MAXMSGSIZE@' >>htmllibdir.h
148	echo '#define IMGPATH "@imageurl@"' >>htmllibdir.h
149	echo '#define SOCKDIR "$(localstatedir)"' >>htmllibdir.h
150	echo '#define SHAREDINDEXFILE "$(sysconfdir)/shared/index"' >>htmllibdir.h
151	echo '#define SQWEBPASSWD "$(pkglibexecdir)/sqwebpasswd"' >>htmllibdir.h
152	if test -d $(srcdir)/../../courier \
153		; then \
154		echo '#define HOSTNAMEFILE "$(sysconfdir)/defaultdomain"' >>htmllibdir.h \
155		; echo '#define MAKEMIME "$(bindir)/makemime"' >>htmllibdir.h \
156		; else \
157		echo '#define HOSTNAMEFILE "$(sysconfdir)/hostname"' >>htmllibdir.h \
158		; echo '#define MAKEMIME "$(pkglibexecdir)/makemime"' >>htmllibdir.h \
159		; fi
160	echo '#define LDAPADDRESSBOOK "$(sysconfdir)/ldapaddressbook"' >>htmllibdir.h
161	echo '#define LDAPSEARCH "$(scriptdir)/ldapsearch"' >>htmllibdir.h
162	echo '#define AUTHCHARSET "$(sysconfdir)/authcharset"' >>htmllibdir.h
163
164ldapsearch: ../ldapaddressbook/ldapsearch
165	cp ../ldapaddressbook/ldapsearch .
166
167webgpg: ../gpglib/webgpg
168	cp ../gpglib/webgpg .
169
170ldapaddressbook.dist: ../ldapaddressbook/ldapaddressbook.dist
171	cp $(srcdir)/../ldapaddressbook/ldapaddressbook.dist .
172
173install-data-local: cache-reminder
174
175install-data-hook:
176	chmod 755 $(DESTDIR)@htmldir@
177	chmod 755 $(DESTDIR)$(scriptdir)
178
179install-exec-hook:
180	-chown @mailuser@ $(DESTDIR)$(pkglibexecdir)/sqwebpasswd
181	-chgrp @mailgroup@ $(DESTDIR)$(pkglibexecdir)/sqwebpasswd
182	-chmod 755 $(DESTDIR)$(pkglibexecdir)/sqwebpasswd
183	-chmod g+s $(DESTDIR)$(pkglibexecdir)/sqwebpasswd
184
185configure-check:
186	@echo "URL to the image directory is @imageurl@"
187
188install-perms-cache:
189	@echo "$(scriptdir)/cleancache.pl 755 bin bin" >>permissions.dat
190	@echo "@cachedir@ 700 @cacheowner@ bin" >>permissions.dat
191
192cache-reminder:
193	-$(mkinstalldirs) $(DESTDIR)@cachedir@
194	-$(mkinstalldirs) $(DESTDIR)$(piddir)
195	test -w /etc || exit 0; chown @cacheowner@ $(DESTDIR)@cachedir@
196	@rm -f cron.cmd
197	@echo '#! @SHELL@' >cron.cmd
198	@echo 'su -p -c "$(scriptdir)/cleancache.pl" @cacheowner@' >>cron.cmd
199	@chmod 555 cron.cmd
200	@cp /dev/null sqwebmail.msg
201	@echo '-----------------------------------------------------------' >>sqwebmail.msg
202	@echo 'You must now add the following command to your system startup script:' >>sqwebmail.msg
203	@echo '' >>sqwebmail.msg
204	@if test -d $(srcdir)/../../courier \
205		; then \
206	echo '$(sbindir)/webmaild start' >>sqwebmail.msg ; else \
207	echo '$(libexecdir)/sqwebmaild.rc start' >>sqwebmail.msg ; fi
208	@echo '' >>sqwebmail.msg
209	@echo 'You must now create the following cron job that runs at' >>sqwebmail.msg
210	@echo 'regular intervals:' >>sqwebmail.msg
211	@echo '' >>sqwebmail.msg
212	@echo 'su -c "$(scriptdir)/cleancache.pl" @cacheowner@' >>sqwebmail.msg
213	@echo '' >>sqwebmail.msg
214	@echo '-----------------------------------------------------------' >>sqwebmail.msg
215	@echo '(note - your su command may use slightly different arguments)' >>sqwebmail.msg
216	@echo '' >>sqwebmail.msg
217	@echo '' >>sqwebmail.msg
218
219
220check-am:
221	./testhtml <$(srcdir)/testhtml.tst | diff -U 3 $(srcdir)/testhtml.txt -
222