1##########################################################################
2#
3# Written by and Copyright (C) 2002-2018 the Privoxy team.
4# https://www.privoxy.org/
5#
6# This script originally written by and Copyright (C) 2002
7# Jonathan Foster
8#
9# This program is free software; you can redistribute it
10# and/or modify it under the terms of the GNU General
11# Public License as published by the Free Software
12# Foundation; either version 2 of the License, or (at
13# your option) any later version.
14#
15# This program is distributed in the hope that it will
16# be useful, but WITHOUT ANY WARRANTY; without even the
17# implied warranty of MERCHANTABILITY or FITNESS FOR A
18# PARTICULAR PURPOSE.  See the GNU General Public
19# License for more details.
20#
21# The GNU General Public License should be included with
22# this file.  If not, you can view it at
23# http://www.gnu.org/copyleft/gpl.html
24# or write to the Free Software Foundation, Inc., 59
25# Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26#
27##########################################################################
28
29
30##########################################################################
31# External programs
32##########################################################################
33SED        = sed
34PERL       = perl
35AWK        = awk
36WGET       = wget
37STRIP      = strip
38AUTOCONF   = autoconf
39AUTOHEADER = autoheader
40
41# Program to copy a directory from a web site to the local disk.
42WEBMIRROR = $(WGET) -nv -nH -nd -N -r -np
43
44# Program to do LF->CRLF
45#
46# The sed version should be the most portable, but it doesn't work for me,
47# the other two do.  FIXME.
48#   - Jon
49#
50DOSFILTER = $(SED) -e $$'s,$$,\r,'
51#DOSFILTER = $(AWK) -v ORS='\r\n' '{print $0;}'
52#DOSFILTER = $(PERL) -p -e 's/\n/\r\n/'
53
54# Path to NSIS
55# MAKENSIS = ./nsis/nsis-2.30.exe
56MAKENSIS = /source/nsis-3.03/makensis.exe
57
58
59##########################################################################
60# More configuration
61##########################################################################
62
63# Directory containing the source code
64SOURCE   = ..
65
66# Directory to build an image of the installed file system in.
67DEST     = ./build
68
69# The name of the EXE installer (must match the name specified in
70# the .NSI script)
71TARGET=privoxy_setup.exe
72
73# The NSIS script that generates the installer.
74NSIFILE=privoxy_winthreads.nsi
75
76
77##########################################################################
78# Rules
79##########################################################################
80
81winrelease: $(TARGET)
82
83winbuild: $(DEST)/privoxy.exe templates inifiles doc webdoc
84
85clean:
86	rm -rf $(DEST) $(TARGET)
87
88clobber: clean
89	rm -f $(TARGET) $(SOURCE)/privoxy.exe
90
91.PHONY: winrelease winbuild clean
92
93
94$(TARGET): $(NSIFILE) winbuild
95	$(MAKENSIS) $<
96
97$(DEST):
98	mkdir $@
99
100$(DEST)/templates:
101	mkdir $@
102
103$(DEST)/doc:
104	mkdir $@
105
106$(DEST)/%.txt: $(SOURCE)/% $(DEST)
107	$(DOSFILTER) < $< > $@
108
109
110inifiles: $(DEST)/config.txt $(DEST)/match-all.action $(DEST)/default.action $(DEST)/user.action \
111          $(DEST)/default.filter $(DEST)/trust.txt $(DEST)/user.filter
112
113
114$(DEST)/config.txt: $(SOURCE)/config $(DEST)
115	$(SED) -e 's!trustfile trust!trustfile trust.txt!' \
116	       -e 's!logfile logfile!logfile privoxy.log!' \
117	       -e 's!#user-manual http://www.privoxy.org/user-manual/!user-manual ./doc/user-manual/!' \
118	       -e 's!#Win32-only: !!' \
119	       < $< | \
120	       $(DOSFILTER) > $@
121
122$(DEST)/match-all.action: $(SOURCE)/match-all.action $(DEST)
123	$(DOSFILTER) < $< > $@
124
125$(DEST)/default.action: $(SOURCE)/default.action $(DEST)
126	$(DOSFILTER) < $< > $@
127
128$(DEST)/user.action: $(SOURCE)/user.action $(DEST)
129	$(DOSFILTER) < $< > $@
130
131$(DEST)/default.filter: $(SOURCE)/default.filter $(DEST)
132	$(DOSFILTER) < $< > $@
133
134$(DEST)/user.filter: $(SOURCE)/user.filter $(DEST)
135	$(DOSFILTER) < $< > $@
136
137$(DEST)/privoxy.exe: $(SOURCE)/privoxy.exe $(DEST)
138	$(STRIP) -o $@ $<
139
140$(SOURCE)/configure: $(SOURCE)/configure.in
141	cd $(SOURCE) && $(AUTOCONF)
142
143$(SOURCE)/config.h.in: $(SOURCE)/configure $(SOURCE)/acconfig.h
144	cd $(SOURCE) && $(AUTOHEADER)
145
146$(SOURCE)/config.h: $(SOURCE)/configure $(SOURCE)/config.h.in
147	./MYconfigure
148
149$(SOURCE)/privoxy.exe: $(SOURCE)/configure $(SOURCE)/config.h
150	cd $(SOURCE) && $(MAKE) clean
151	cd $(SOURCE) && $(MAKE)
152
153
154templates: $(patsubst $(SOURCE)/%,$(DEST)/%,$(wildcard $(SOURCE)/templates/*))
155
156$(DEST)/templates/%: $(SOURCE)/templates/% $(DEST)/templates
157	if test -f $< ; then $(DOSFILTER) < $< > $@ ; fi
158
159
160doc: $(DEST)/AUTHORS.txt $(DEST)/README.txt $(DEST)/LICENSE.txt
161
162webdoc: $(DEST)/doc/developer-manual $(DEST)/doc/faq $(DEST)/doc/user-manual
163	cp $(SOURCE)/doc/webserver/p_doc.css $(DEST)/doc
164	cp $(SOURCE)/doc/webserver/p_doc.css $(DEST)/doc/user-manual/
165
166
167$(DEST)/doc/%.txt : $(SOURCE)/doc/text/%.txt $(DEST)/doc
168	$(DOSFILTER) < $< > $@
169
170$(DEST)/doc/developer-manual: $(DEST)/doc $(SOURCE)/doc/webserver/developer-manual/index.html
171	test -d $(DEST)/doc/developer-manual || mkdir $(DEST)/doc/developer-manual
172	cp    $(SOURCE)/doc/webserver/developer-manual/*.html $(DEST)/doc/developer-manual/
173
174$(DEST)/doc/user-manual: $(DEST)/doc $(SOURCE)/doc/webserver/user-manual/index.html
175	test -d $(DEST)/doc/user-manual      || mkdir $(DEST)/doc/user-manual
176	cp    $(SOURCE)/doc/webserver/user-manual/*.html $(DEST)/doc/user-manual/
177	cp    $(SOURCE)/doc/webserver/user-manual/*.jpg  $(DEST)/doc/user-manual/
178
179$(DEST)/doc/faq: $(DEST)/doc $(SOURCE)/doc/webserver/faq/index.html
180	test -d $(DEST)/doc/faq              || mkdir $(DEST)/doc/faq
181	cp    $(SOURCE)/doc/webserver/faq/*.html $(DEST)/doc/faq/
182
183##########################################################################
184# That's all, folks!
185##########################################################################
186
187