1# vim: noexpandtab tabstop=8 shiftwidth=8 syntax=make
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements.  See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership.  The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance
9# with the License.  You may obtain a copy of the License at
10#
11#   http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing,
14# software distributed under the License is distributed on an
15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16# KIND, either express or implied.  See the License for the
17# specific language governing permissions and limitations
18# under the License.
19#
20# WARNING: This may or may not work on your system. This Makefile is
21# an example, rather than a ready-made universal solution.
22
23#   ****************************************************************
24#   **       IMPORTANT NOTE FOR SVN COMMITTERS:  READ THIS.       **
25#   **                                                            **
26#   ****************************************************************
27#   | This Makefile is used by the bb-openbsd buildbot             |
28#   | (http://ci.apache.org/builders/bb-openbsd). Please check     |
29#   | the bot's health after making changes to this file.          |
30#   |______________________________________________________________|
31
32PERL ?= yes
33ENABLE_PERL_BINDINGS = $(PERL)
34THREADING ?= yes
35ifeq ($(THREADING),yes)
36JAVA ?= yes
37else
38JAVA ?= no
39endif
40ENABLE_JAVA_BINDINGS = $(JAVA)
41USE_APR_ICONV ?= no # set to yes to use APR iconv instead of GNU iconv
42PARALLEL ?= 1
43CLEANUP ?= 1
44EXCLUSIVE_WC_LOCKS ?= 1
45USE_HTTPV1 ?= no
46USE_AUTHZ_SHORT_CIRCUIT ?= no
47RAMDISK ?= /ramdisk
48MAKE_JOBS ?= 4
49SVN_CHECK_FS_BACKENDS ?= fsfs bdb
50
51PWD		= $(shell pwd)
52UNAME		= $(shell uname)
53RUBY		= $(shell which ruby 2>/dev/null)
54ifeq ($(RUBY),)
55RUBY		= $(shell which ruby24 2>/dev/null)
56ifeq ($(RUBY),)
57RUBY		= $(shell which ruby23 2>/dev/null)
58ifeq ($(RUBY),)
59RUBY		= $(shell which ruby22 2>/dev/null)
60ifeq ($(RUBY),)
61RUBY		= $(shell which ruby21 2>/dev/null)
62ifeq ($(RUBY),)
63RUBY		= $(shell which ruby20 2>/dev/null)
64ifeq ($(RUBY),)
65RUBY		= $(shell which ruby19 2>/dev/null)
66ifeq ($(RUBY),)
67RUBY		= $(shell which ruby18)
68endif # 1.8
69endif # 1.9
70endif # 2.0
71endif # 2.1
72endif # 2.2
73endif # 2.3
74endif # 2.4
75
76ifeq ($(UNAME),OpenBSD)
77# Pick the correct base compiler (ie. clang rather than ancient gcc 4.2.1)
78CC = cc
79CXX = c++
80endif
81
82TAG		?= none
83ifeq ($(TAG),none)
84BRANCH		?= trunk
85else
86BRANCH		= $(TAG)
87endif
88WC		?= $(BRANCH)
89BRANCH_MAJOR	= $(shell echo $(BRANCH) | \
90			sed -e 's/\([0-9]\)\.\([0-9]\)\.[x0-9].*$$/\1.\2/')
91SVN_REL_WC	= svn-$(WC)
92SVN_WC		= $(PWD)/$(SVN_REL_WC)
93PREFIX		= $(PWD)/prefix
94SVN_PREFIX	= $(PREFIX)/svn-$(WC)
95DISTDIR		= $(PWD)/distfiles
96SRCDIR		= $(PWD)/src
97OBJDIR		= $(PWD)/objdir
98
99BDB_MAJOR_VER	= 4.7
100BDB_VER		= $(BDB_MAJOR_VER).25
101APR_VER		= 1.5.2
102APR_ICONV_VER	= 1.2.1
103GNU_ICONV_VER	= 1.15
104APR_UTIL_VER	= 1.5.4
105PCRE_VER	= 8.41
106HTTPD_VER	= 2.4.37
107NEON_VER	= 0.30.2
108SERF_VER	= 1.3.9
109SERF_OLD_VER	= 0.3.1
110CYRUS_SASL_VER	= 2.1.25
111SQLITE_VER	= 3160200
112LIBMAGIC_VER	= 5.30
113RUBY_VER	= 2.4.4
114BZ2_VER	= 1.0.6
115PYTHON_VER	= 3.7.5
116PY3C_VER	= 1.1
117JUNIT_VER	= 4.10
118GETTEXT_VER	= 0.19.8.1
119LZ4_VER		= 1.7.5
120
121BDB_DIST	= db-$(BDB_VER).tar.gz
122APR_ICONV_DIST	= apr-iconv-$(APR_ICONV_VER).tar.gz
123GNU_ICONV_DIST	= libiconv-$(GNU_ICONV_VER).tar.gz
124NEON_DIST	= neon-$(NEON_VER).tar.gz
125SQLITE_DIST	= sqlite-autoconf-$(SQLITE_VER).tar.gz
126CYRUS_SASL_DIST	= cyrus-sasl-$(CYRUS_SASL_VER).tar.gz
127PCRE_DIST	= pcre-$(PCRE_VER).tar.gz
128HTTPD_DIST	= httpd-$(HTTPD_VER).tar.gz
129LIBMAGIC_DIST	= file-$(LIBMAGIC_VER).tar.gz
130RUBY_DIST	= ruby-$(RUBY_VER).tar.gz
131BZ2_DIST	= bzip2-$(BZ2_VER).tar.gz
132PYTHON_DIST	= Python-$(PYTHON_VER).tgz
133PY3C_DIST	= py3c-$(PY3C_VER).tar.gz
134JUNIT_DIST	= junit-${JUNIT_VER}.jar
135GETTEXT_DIST	= gettext-$(GETTEXT_VER).tar.gz
136LZ4_DIST	= lz4-$(LZ4_VER).tar.gz
137
138SHA256_${BDB_DIST} = f14fd96dd38915a1d63dcb94a63fbb8092334ceba6b5060760427096f631263e
139SHA256_${APR_ICONV_DIST} = 19381959d50c4a5f3b9c84d594a5f9ffb3809786919b3058281f4c87e1f4b245
140SHA256_${GNU_ICONV_DIST} = ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178
141SHA256_${PCRE_DIST} = 244838e1f1d14f7e2fa7681b857b3a8566b74215f28133f14a8f5e59241b682c
142SHA256_${HTTPD_DIST} = aa97a834a32d51974be8d8a013b561e28d327387cb1da2c3c2762acd0146aabd
143SHA256_${NEON_DIST} = db0bd8cdec329b48f53a6f00199c92d5ba40b0f015b153718d1b15d3d967fbca
144SHA256_${CYRUS_SASL_DIST} = 418c16e6240a4f9b637cbe3d62937b9675627bad27c622191d47de8686fe24fe
145SHA256_${SQLITE_DIST} = 65cc0c3e9366f50c0679c5ccd31432cea894bc4a3e8947dabab88c8693263615
146SHA256_${LIBMAGIC_DIST} = 694c2432e5240187524c9e7cf1ec6acc77b47a0e19554d34c14773e43dbbf214
147SHA256_${RUBY_DIST} = 254f1c1a79e4cc814d1e7320bc5bdd995dc57e08727d30a767664619a9c8ae5a
148SHA256_${BZ2_DIST} = a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd
149SHA256_${PYTHON_DIST} = 8ecc681ea0600bbfb366f2b173f727b205bb825d93d2f0b286bc4e58d37693da
150SHA256_${PY3C_DIST} = c7ffc22bc92dded0ca859db53ef3a0b466f89a9f8aad29359c9fe4ff18ebdd20
151SHA256_${JUNIT_DIST} = 36a747ca1e0b86f6ea88055b8723bb87030d627766da6288bf077afdeeb0f75a
152SHA256_${GETTEXT_DIST} = ff942af0e438ced4a8b0ea4b0b6e0d6d657157c5e2364de57baa279c1c125c43
153SHA256_${LZ4_DIST} = 0190cacd63022ccb86f44fa5041dc6c3804407ad61550ca21c382827319e7e7e
154
155define do_check_sha256
156if [ -x /bin/sha256 ]; then \
157	(cd $(DISTDIR) && \
158		echo "SHA256 (${1}) = ${SHA256_${1}}" | /bin/sha256 -C /dev/stdin "${1}"); \
159elif [ -x /usr/bin/sha256sum ]; then \
160	(cd $(DISTDIR) && \
161		echo "${SHA256_${1}} ${1}" | /usr/bin/sha256sum --quiet --check); \
162else \
163	echo "Error: No tool found to verify checksum"; \
164	false; \
165fi
166endef
167
168DISTFILES	= $(DISTDIR)/$(NEON_DIST) \
169		$(DISTDIR)/$(SERF_DIST) \
170		$(DISTDIR)/$(SQLITE_DIST) \
171		$(DISTDIR)/$(PCRE_DIST) \
172		$(DISTDIR)/$(HTTPD_DIST) \
173		$(DISTDIR)/$(APR_ICONV_DIST) \
174		$(DISTDIR)/$(GNU_ICONV_DIST) \
175		$(DISTDIR)/$(CYRUS_SASL_DIST) \
176		$(DISTDIR)/$(LIBMAGIC_DIST) \
177		$(DISTDIR)/$(RUBY_DIST) \
178		$(DISTDIR)/$(BZ2_DIST) \
179		$(DISTDIR)/$(PYTHON_DIST) \
180		$(DISTDIR)/$(PY3C_DIST) \
181		$(DISTDIR)/$(JUNIT_DIST) \
182		$(DISTDIR)/$(GETTEXT_DIST)
183
184FETCH_CMD	= wget -c
185
186SUBVERSION_REPOS_URL = https://svn.apache.org/repos/asf/subversion
187BDB_URL		= http://download.oracle.com/berkeley-db/$(BDB_DIST)
188APR_URL		= https://svn.apache.org/repos/asf/apr/apr
189APR_ICONV_URL	= https://archive.apache.org/dist/apr/$(APR_ICONV_DIST)
190GNU_ICONV_URL	= https://ftp.gnu.org/pub/gnu/libiconv/$(GNU_ICONV_DIST)
191APR_UTIL_URL	= https://svn.apache.org/repos/asf/apr/apr-util
192PCRE_URL	= https://ftp.pcre.org/pub/pcre/$(PCRE_DIST)
193HTTPD_URL	= https://archive.apache.org/dist/httpd/$(HTTPD_DIST)
194#NEON_URL	= http://webdav.org/neon/$(NEON_DIST)
195NEON_URL	= http://ftp.openbsd.org/pub/OpenBSD/distfiles/$(NEON_DIST)
196SERF_URL	= https://svn.apache.org/repos/asf/serf/tags/$(SERF_VER)
197SERF_OLD_URL	= https://svn.apache.org/repos/asf/serf/tags/$(SERF_OLD_VER)
198SQLITE_URL	= https://www.sqlite.org/2017/$(SQLITE_DIST)
199CYRUS_SASL_URL	= https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-${CYRUS_SASL_VER}/$(CYRUS_SASL_DIST)
200LIBMAGIC_URL	= ftp://ftp.astron.com/pub/file/$(LIBMAGIC_DIST)
201RUBY_URL	= https://cache.ruby-lang.org/pub/ruby/2.4/$(RUBY_DIST)
202BZ2_URL		= https://stsp.name/distfiles/$(BZ2_DIST)
203PYTHON_URL	= https://python.org/ftp/python/$(PYTHON_VER)/$(PYTHON_DIST)
204PY3C_URL	= https://stsp.name/distfiles/py3c-${PY3C_VER}.tar.gz
205JUNIT_URL	= https://stsp.name/distfiles/$(JUNIT_DIST)
206GETTEXT_URL	= https://ftp.gnu.org/pub/gnu/gettext/$(GETTEXT_DIST)
207LZ4_URL		= https://github.com/lz4/lz4/archive/v$(LZ4_VER).tar.gz
208
209
210BDB_SRCDIR	= $(SRCDIR)/db-$(BDB_VER)
211APR_SRCDIR	= $(SRCDIR)/apr-$(APR_VER)
212APR_ICONV_SRCDIR	= $(SRCDIR)/apr-iconv-$(APR_ICONV_VER)
213GNU_ICONV_SRCDIR	= $(SRCDIR)/libiconv-$(GNU_ICONV_VER)
214APR_UTIL_SRCDIR	= $(SRCDIR)/apr-util-$(APR_UTIL_VER)
215PCRE_SRCDIR	= $(SRCDIR)/pcre-$(PCRE_VER)
216HTTPD_SRCDIR	= $(SRCDIR)/httpd-$(HTTPD_VER)
217NEON_SRCDIR	= $(SRCDIR)/neon-$(NEON_VER)
218SERF_SRCDIR	= $(SRCDIR)/serf-$(SERF_VER)
219SERF_OLD_SRCDIR	= $(SRCDIR)/serf-$(SERF_OLD_VER)
220SQLITE_SRCDIR	= $(SRCDIR)/sqlite-autoconf-$(SQLITE_VER)
221CYRUS_SASL_SRCDIR	= $(SRCDIR)/cyrus-sasl-$(CYRUS_SASL_VER)
222LIBMAGIC_SRCDIR	= $(SRCDIR)/file-$(LIBMAGIC_VER)
223RUBY_SRCDIR	= $(SRCDIR)/ruby-$(RUBY_VER)
224BZ2_SRCDIR	= $(SRCDIR)/bzip2-$(BZ2_VER)
225PYTHON_SRCDIR	= $(SRCDIR)/Python-$(PYTHON_VER)
226PY3C_SRCDIR	= $(SRCDIR)/py3c-$(PY3C_VER)
227GETTEXT_SRCDIR	= $(SRCDIR)/gettext-$(GETTEXT_VER)
228LZ4_SRCDIR	= ${SRCDIR}/lz4-$(LZ4_VER)
229SVN_SRCDIR	= $(SVN_WC)
230
231BDB_OBJDIR	= $(OBJDIR)/db-$(BDB_VER)
232APR_OBJDIR	= $(OBJDIR)/apr-$(APR_VER)
233APR_ICONV_OBJDIR	= $(OBJDIR)/apr-iconv-$(APR_ICONV_VER)
234GNU_ICONV_OBJDIR	= $(OBJDIR)/libiconv-$(GNU_ICONV_VER)
235APR_UTIL_OBJDIR	= $(OBJDIR)/apr-util-$(APR_UTIL_VER)
236PCRE_OBJDIR	= $(OBJDIR)/pcre-$(PCRE_VER)
237HTTPD_OBJDIR	= $(OBJDIR)/httpd-$(HTTPD_VER)
238NEON_OBJDIR	= $(OBJDIR)/neon-$(NEON_VER)
239SERF_OBJDIR	= $(OBJDIR)/serf-$(SERF_VER)
240SERF_OLD_OBJDIR	= $(OBJDIR)/serf-$(SERF_OLD_VER)
241SQLITE_OBJDIR	= $(OBJDIR)/sqlite-$(SQLITE_VER)
242CYRUS_SASL_OBJDIR	= $(OBJDIR)/cyrus-sasl-$(CYRUS_SASL_VER)
243LIBMAGIC_OBJDIR	= $(OBJDIR)/file-$(LIBMAGIC_VER)
244RUBY_OBJDIR	= $(OBJDIR)/ruby-$(RUBY_VER)
245BZ2_OBJDIR	= $(OBJDIR)/bzip2-$(BZ2_VER)
246PYTHON_OBJDIR	= $(OBJDIR)/python-$(PYTHON_VER)
247PY3C_OBJDIR	= $(OBJDIR)/python-$(PY3C_VER)
248GETTEXT_OBJDIR	= $(OBJDIR)/gettext-$(GETTEXT_VER)
249LZ4_OBJDIR	= ${OBJDIR}/lz4-$(LZ4_VER)
250SVN_OBJDIR	= $(OBJDIR)/$(SVN_REL_WC)
251
252# Tweak this for out-of-tree builds. Note that running individual
253# tests in the test suite won't work conveniently with out-of-tree
254# builds!
255svn_builddir	?=$(SVN_WC)
256
257ifdef PROFILE
258PROFILE_CFLAGS=-pg
259endif
260
261# We need this to make sure some targets below pick up the right libraries
262LD_LIBRARY_PATH=$(PREFIX)/apr/lib:$(PREFIX)/gettext/lib:$(PREFIX)/iconv/lib:$(PREFIX)/bdb/lib:$(PREFIX)/neon/lib:$(PREFIX)/serf/lib:$(PREFIX)/sqlite/lib:$(PREFIX)/cyrus-sasl/lib:$(PREFIX)/iconv/lib:$(PREFIX)/libmagic/lib:$(PREFIX)/ruby/lib:$(PREFIX)/python/lib:$(PREFIX)/svn-$(WC)/lib
263
264# We need this to make sure some targets below pick up the right pkg-config files
265PKG_CONFIG_PATH=$(PREFIX)/apr/lib/pkgconfig:$(PREFIX)/neon/lib/pkgconfig:$(PREFIX)/serf/lib/pkgconfig:$(PREFIX)/sqlite/lib/pkgconfig:$(PREFIX)/ruby/lib/pkgconfig:$(PREFIX)/python/lib/pkgconfig:$(PREFIX)/lz4/lib/pkgconfig
266
267
268#######################################################################
269# Main targets.
270#######################################################################
271
272.PHONY: all reset clean nuke fetch
273
274all: dirs-create bdb-install apr-install iconv-install apr-util-install \
275	pcre-install httpd-install neon-install serf-install serf-old-install \
276	sqlite-install cyrus-sasl-install libmagic-install \
277	ruby-install bz2-install python-install py3c-retrieve gettext-install \
278	lz4-install svn-install svn-bindings-install
279
280# Use these to start a build from the beginning.
281reset: dirs-reset bdb-reset apr-reset iconv-reset apr-util-reset \
282	pcre-reset httpd-reset neon-reset serf-reset serf-old-reset \
283	sqlite-reset cyrus-sasl-reset libmagic-reset ruby-reset python-reset \
284	bz2-reset gettext-reset lz4-reset svn-reset
285
286# Use to save disk space.
287clean: bdb-clean apr-clean iconv-clean apr-util-clean pcre-clean httpd-clean \
288	neon-clean serf-clean serf-old-clean sqlite-clean cyrus-sasl-clean \
289	libmagic-clean ruby-clean bz2-clean python-clean gettext-clean \
290	lz4-clean svn-clean
291
292# Nukes everything (including installed binaries!)
293# Use this to start ALL OVER AGAIN! Use with caution!
294nuke:
295	@echo
296	@echo "I will now remove the following directories PERMANENTLY:"
297	@echo
298	@echo "  $(SRCDIR)"
299	@echo "  $(OBJDIR)"
300	@echo "  $(PREFIX)"
301	@echo
302	@echo -n 'Do you want me to continue? ([no]/yes): '
303	@read ANSWER ; \
304		case $$ANSWER in \
305			yes)    echo "You said $$ANSWER. I will continue."; \
306				echo rm -rf $(SRCDIR) $(OBJDIR) $(PREFIX); \
307				rm -rf $(SRCDIR) $(OBJDIR) $(PREFIX); \
308				$(MAKE) reset; \
309				;; \
310			"")     echo "You said no."; \
311				;; \
312			*)      echo "You said $$ANSWER."; \
313				;; \
314		esac
315
316fetch: $(DISTFILES)
317
318#######################################################################
319# directories
320#######################################################################
321
322dirs-create: $(PWD)/.dirs-created
323dirs-reset:
324	rm -f $(PWD)/.dirs-created
325
326$(PWD)/.dirs-created:
327	$(foreach d, $(PREFIX) $(DISTDIR) $(SRCDIR) $(OBJDIR), \
328		[ -d $(d) ] || mkdir -p $(d);)
329		touch $@
330
331#######################################################################
332# bdb
333#######################################################################
334
335bdb-retrieve:	$(BDB_OBJDIR)/.retrieved
336bdb-configure:	$(BDB_OBJDIR)/.configured
337bdb-compile:	$(BDB_OBJDIR)/.compiled
338bdb-install:	$(BDB_OBJDIR)/.installed
339bdb-reset:
340	$(foreach f, .retrieved .configured .compiled .installed, \
341		rm -f $(BDB_OBJDIR)/$(f);)
342
343bdb-clean:
344	-(cd $(BDB_SRCDIR)/build_unix/ && env MAKEFLAGS= make clean)
345
346# fetch distfile for bdb
347$(DISTDIR)/$(BDB_DIST):
348	cd $(DISTDIR) && $(FETCH_CMD) $(BDB_URL)
349
350# retrieve bdb
351$(BDB_OBJDIR)/.retrieved: $(DISTDIR)/$(BDB_DIST)
352	$(call do_check_sha256,$(BDB_DIST))
353	[ -d $(BDB_OBJDIR) ] || mkdir -p $(BDB_OBJDIR)
354	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(BDB_DIST)
355	touch $@
356
357# configure bdb
358$(BDB_OBJDIR)/.configured: $(BDB_OBJDIR)/.retrieved
359	cd $(BDB_SRCDIR)/build_unix \
360		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`" \
361		CC=$(CC) CXX=$(CXX) \
362		../dist/configure \
363		--prefix=$(PREFIX)/bdb \
364		--enable-debug
365	touch $@
366
367# compile bdb
368$(BDB_OBJDIR)/.compiled: $(BDB_OBJDIR)/.configured
369	(cd $(BDB_SRCDIR)/build_unix && env MAKEFLAGS= make -j${MAKE_JOBS})
370	touch $@
371
372# install bdb
373$(BDB_OBJDIR)/.installed: $(BDB_OBJDIR)/.compiled
374	(cd $(BDB_SRCDIR)/build_unix && env MAKEFLAGS= make install)
375	touch $@
376
377#######################################################################
378# apr
379#######################################################################
380
381apr-retrieve:	$(APR_OBJDIR)/.retrieved
382apr-configure:	$(APR_OBJDIR)/.configured
383apr-compile:	$(APR_OBJDIR)/.compiled
384apr-install:	$(APR_OBJDIR)/.installed
385apr-reset:
386	$(foreach f, .retrieved .configured .compiled .installed, \
387		rm -f $(APR_OBJDIR)/$(f);)
388
389apr-clean:
390	-(cd $(APR_OBJDIR) && env MAKEFLAGS= make clean)
391
392# retrieve apr if not present yet
393$(APR_OBJDIR)/.retrieved:
394	[ -d $(APR_OBJDIR) ] || mkdir -p $(APR_OBJDIR)
395	if [ ! -d $(APR_SRCDIR) ]; then \
396		svn export $(APR_URL)/tags/$(APR_VER)/ $(APR_SRCDIR); \
397	fi
398	touch $@
399
400ifeq ($(THREADING),yes)
401THREADS_FLAG=--enable-threads
402else
403THREADS_FLAG=--disable-threads
404endif
405
406ifdef POOL_DEBUG
407POOL_DEBUG_FLAG=--enable-pool-debug=all
408else
409# Map apr_palloc()/apr_pool_{clear,destroy}() to malloc()/free().
410# This also puts poison bytes into freed memory to help detect use after free.
411POOL_DEBUG_FLAG=--enable-pool-debug=yes
412endif
413
414# configure apr
415$(APR_OBJDIR)/.configured: $(APR_OBJDIR)/.retrieved $(BDB_OBJDIR)/.installed
416	cd $(APR_SRCDIR) && ./buildconf
417	cd $(APR_OBJDIR) \
418		&& env CFLAGS="-O0 -g $(PROFILE_CFLAGS)" GREP="`which grep`" \
419		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
420		CC=$(CC) CXX=$(CXX) \
421		$(APR_SRCDIR)/configure \
422		--prefix=$(PREFIX)/apr \
423		--enable-maintainer-mode \
424		$(THREADS_FLAG) \
425		$(POOL_DEBUG_FLAG)
426	touch $@
427
428# compile apr
429$(APR_OBJDIR)/.compiled: $(APR_OBJDIR)/.configured
430	(cd $(APR_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
431	touch $@
432
433# install apr
434$(APR_OBJDIR)/.installed: $(APR_OBJDIR)/.compiled
435	(cd $(APR_OBJDIR) && env MAKEFLAGS= make install)
436	touch $@
437
438#######################################################################
439# apr-iconv
440#######################################################################
441
442apr-iconv-retrieve:	$(APR_ICONV_OBJDIR)/.retrieved
443apr-iconv-configure:	$(APR_ICONV_OBJDIR)/.configured
444apr-iconv-compile:	$(APR_ICONV_OBJDIR)/.compiled
445apr-iconv-install:	$(APR_ICONV_OBJDIR)/.installed
446apr-iconv-reset:
447	$(foreach f, .retrieved .configured .compiled .installed, \
448		rm -f $(APR_ICONV_OBJDIR)/$(f);)
449
450apr-iconv-clean:
451	-(cd $(APR_ICONV_OBJDIR) && env MAKEFLAGS= make clean)
452
453# fetch distfile for apr-iconv
454$(DISTDIR)/$(APR_ICONV_DIST):
455	cd $(DISTDIR) && $(FETCH_CMD) $(APR_ICONV_URL)
456
457# retrieve apr-iconv
458$(APR_ICONV_OBJDIR)/.retrieved: $(DISTDIR)/$(APR_ICONV_DIST)
459	$(call do_check_sha256,$(APR_ICONV_DIST))
460	[ -d $(APR_ICONV_OBJDIR) ] || mkdir -p $(APR_ICONV_OBJDIR)
461	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(APR_ICONV_DIST)
462	touch $@
463
464# configure apr-iconv
465$(APR_ICONV_OBJDIR)/.configured: $(APR_ICONV_OBJDIR)/.retrieved \
466	$(APR_OBJDIR)/.installed
467	cd $(APR_ICONV_OBJDIR) \
468		&& env CFLAGS="-g $(PROFILE_CFLAGS) -DAPR_POOL_DEBUG" \
469		CC=$(CC) CXX=$(CXX) \
470		GREP="`which grep`" \
471		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
472		$(APR_ICONV_SRCDIR)/configure \
473		--prefix=$(PREFIX)/apr \
474		--with-apr=$(PREFIX)/apr
475	touch $@
476
477# compile apr-iconv
478$(APR_ICONV_OBJDIR)/.compiled: $(APR_ICONV_OBJDIR)/.configured
479	(cd $(APR_ICONV_OBJDIR) \
480		&& env MAKEFLAGS= make CPPFLAGS="-D_OSD_POSIX" CFLAGS="-g -O0 $(PROFILE_CFLAGS)" -j${MAKE_JOBS})
481	touch $@
482
483# install apr-iconv
484$(APR_ICONV_OBJDIR)/.installed: $(APR_ICONV_OBJDIR)/.compiled
485	(cd $(APR_ICONV_OBJDIR) && env MAKEFLAGS= make install)
486	touch $@
487
488#######################################################################
489# gnu-iconv
490#######################################################################
491
492gnu-iconv-retrieve:	$(GNU_ICONV_OBJDIR)/.retrieved
493gnu-iconv-configure:	$(GNU_ICONV_OBJDIR)/.configured
494gnu-iconv-compile:	$(GNU_ICONV_OBJDIR)/.compiled
495gnu-iconv-install:	$(GNU_ICONV_OBJDIR)/.installed
496gnu-iconv-reset:
497	$(foreach f, .retrieved .configured .compiled .installed, \
498		rm -f $(GNU_ICONV_OBJDIR)/$(f);)
499
500gnu-iconv-clean:
501	-(cd $(GNU_ICONV_OBJDIR) && env MAKEFLAGS= make clean)
502	rm -f $(GNU_ICONV_OBJDIR)/lib_encodings.def.diff
503	rm -f $(GNU_ICONV_OBJDIR)/lib_aliases.gperf.diff
504
505# fetch distfile for gnu-iconv
506$(DISTDIR)/$(GNU_ICONV_DIST):
507	cd $(DISTDIR) && $(FETCH_CMD) $(GNU_ICONV_URL)
508
509$(GNU_ICONV_OBJDIR)/lib_encodings.def.diff:
510	mkdir -p $(dir $@)
511	echo > $@.tmp '--- lib/encodings.def.orig	Wed Oct 24 23:41:41 2007'
512	echo >>$@.tmp '+++ lib/encodings.def	Wed Oct 24 23:43:47 2007'
513	echo >>$@.tmp '@@ -37,6 +37,7 @@'
514	echo >>$@.tmp ' '
515	echo >>$@.tmp ' '
516	echo >>$@.tmp ' DEFENCODING(( "US-ASCII",               /* IANA */'
517	echo >>$@.tmp '+              "646",'
518	echo >>$@.tmp '               "ASCII",                  /* IANA, JDK 1.1 */'
519	echo >>$@.tmp '               "ISO646-US",              /* IANA */'
520	echo >>$@.tmp '               "ISO_646.IRV:1991",       /* IANA */'
521	mv -f $@.tmp $@
522
523$(GNU_ICONV_OBJDIR)/lib_aliases.gperf.diff:
524	mkdir -p $(dir $@)
525	echo > $@.tmp '--- lib/aliases.gperf.orig	Wed Oct 24 23:41:32 2007'
526	echo >>$@.tmp '+++ lib/aliases.gperf	Wed Oct 24 23:47:38 2007'
527	echo >>$@.tmp '@@ -10,6 +10,7 @@ struct alias { int name; unsigned int encoding_index; '
528	echo >>$@.tmp ' %pic'
529	echo >>$@.tmp ' %%'
530	echo >>$@.tmp ' US-ASCII, ei_ascii'
531	echo >>$@.tmp '+646, ei_ascii'
532	echo >>$@.tmp ' ASCII, ei_ascii'
533	echo >>$@.tmp ' ISO646-US, ei_ascii'
534	echo >>$@.tmp ' ISO_646.IRV:1991, ei_ascii'
535	mv -f $@.tmp $@
536
537# retrieve gnu-iconv
538# Add 646 as an alias for ASCII to fix prop_test 22 on OpenBSD
539$(GNU_ICONV_OBJDIR)/.retrieved: $(DISTDIR)/$(GNU_ICONV_DIST) \
540		$(GNU_ICONV_OBJDIR)/lib_encodings.def.diff \
541		$(GNU_ICONV_OBJDIR)/lib_aliases.gperf.diff
542	$(call do_check_sha256,$(GNU_ICONV_DIST))
543	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(GNU_ICONV_DIST)
544	cd $(SRCDIR)/libiconv-$(GNU_ICONV_VER) && \
545		patch -p0 < $(GNU_ICONV_OBJDIR)/lib_encodings.def.diff && \
546		patch -p0 < $(GNU_ICONV_OBJDIR)/lib_aliases.gperf.diff
547	touch $@
548
549# configure gnu-iconv
550$(GNU_ICONV_OBJDIR)/.configured: $(GNU_ICONV_OBJDIR)/.retrieved
551	cd $(SRCDIR)/libiconv-${GNU_ICONV_VER} && \
552		${MAKE} -f Makefile.devel lib/aliases.h
553	cd $(GNU_ICONV_OBJDIR) \
554		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`"\
555		CC=$(CC) CXX=$(CXX) \
556		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
557		$(GNU_ICONV_SRCDIR)/configure \
558		--prefix=$(PREFIX)/iconv \
559		--enable-extra-encodings
560	touch $@
561
562# compile gnu-iconv
563$(GNU_ICONV_OBJDIR)/.compiled: $(GNU_ICONV_OBJDIR)/.configured
564	(cd $(GNU_ICONV_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
565	touch $@
566
567# install gnu-iconv
568$(GNU_ICONV_OBJDIR)/.installed: $(GNU_ICONV_OBJDIR)/.compiled
569	(cd $(GNU_ICONV_OBJDIR) && env MAKEFLAGS= make install)
570	touch $@
571
572#######################################################################
573# iconv
574#######################################################################
575
576.PHONY: iconv-install iconv-reset iconv-clean
577
578ifeq ($(USE_APR_ICONV),yes)
579iconv-install: apr-iconv-install
580iconv-reset: apr-iconv-reset
581iconv-clean: apr-iconv-clean
582else
583iconv-install: gnu-iconv-install
584iconv-reset: gnu-iconv-reset
585iconv-clean: gnu-iconv-clean
586endif
587
588#######################################################################
589# apr-util
590#######################################################################
591
592apr-util-retrieve:	$(APR_UTIL_OBJDIR)/.retrieved
593apr-util-configure:	$(APR_UTIL_OBJDIR)/.configured
594apr-util-compile:	$(APR_UTIL_OBJDIR)/.compiled
595apr-util-install:	$(APR_UTIL_OBJDIR)/.installed
596apr-util-reset:
597	$(foreach f, .retrieved .configured .compiled .installed, \
598		rm -f $(APR_UTIL_OBJDIR)/$(f);)
599
600apr-util-clean:
601	-(cd $(APR_UTIL_OBJDIR) && env MAKEFLAGS= make clean)
602
603
604# retrieve apr-util if not present yet
605$(APR_UTIL_OBJDIR)/.retrieved:
606	[ -d $(APR_UTIL_OBJDIR) ] || mkdir -p $(APR_UTIL_OBJDIR)
607	if [ ! -d $(APR_UTIL_SRCDIR) ]; then \
608		svn export $(APR_UTIL_URL)/tags/$(APR_UTIL_VER)/ \
609			$(APR_UTIL_SRCDIR); \
610	fi
611	touch $@
612
613ifeq ($(USE_APR_ICONV),yes)
614ICONV_FLAG=--with-iconv=$(PREFIX)/apr
615ICONV_OBJDIR=$(APR_ICONV_OBJDIR)
616else
617ICONV_FLAG=--with-iconv=$(PREFIX)/iconv
618ICONV_OBJDIR=$(GNU_ICONV_OBJDIR)
619endif
620
621# configure apr-util
622$(APR_UTIL_OBJDIR)/.configured: $(APR_UTIL_OBJDIR)/.retrieved \
623	$(APR_OBJDIR)/.installed $(ICONV_OBJDIR)/.installed
624	cd $(APR_UTIL_SRCDIR) && ./buildconf --with-apr=$(APR_SRCDIR)
625	cd $(APR_UTIL_OBJDIR) \
626		&& env LD_LIBRARY_PATH=$(PREFIX)/bdb/lib \
627			PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
628			CFLAGS="-O0 -g $(PROFILE_CFLAGS) -DAPR_POOL_DEBUG" \
629			CC=$(CC) CXX=$(CXX) \
630			GREP="`which grep`" \
631			$(APR_UTIL_SRCDIR)/configure \
632		--prefix=$(PREFIX)/apr \
633		--enable-maintainer-mode \
634		--with-apr=$(PREFIX)/apr \
635		--with-berkeley-db=$(PREFIX)/bdb \
636		$(ICONV_FLAG)
637	touch $@
638
639# compile apr-util
640$(APR_UTIL_OBJDIR)/.compiled: $(APR_UTIL_OBJDIR)/.configured
641	(cd $(APR_UTIL_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
642	touch $@
643
644# install apr-util
645$(APR_UTIL_OBJDIR)/.installed: $(APR_UTIL_OBJDIR)/.compiled
646	(cd $(APR_UTIL_OBJDIR) && env MAKEFLAGS= make install)
647	touch $@
648
649#######################################################################
650# pcre
651#######################################################################
652
653pcre-retrieve:	$(PCRE_OBJDIR)/.retrieved
654pcre-configure:	$(PCRE_OBJDIR)/.configured
655pcre-compile:	$(PCRE_OBJDIR)/.compiled
656pcre-install:	$(PCRE_OBJDIR)/.installed
657pcre-reset:
658	$(foreach f, .retrieved .configured .compiled .installed, \
659		rm -f $(PCRE_OBJDIR)/$(f);)
660
661pcre-clean:
662	-(cd $(PCRE_OBJDIR) && env MAKEFLAGS= make clean)
663
664# fetch distfile for pcre
665$(DISTDIR)/$(PCRE_DIST):
666	cd $(DISTDIR) && $(FETCH_CMD) $(PCRE_URL)
667
668# retrieve pcre
669$(PCRE_OBJDIR)/.retrieved: $(DISTDIR)/$(PCRE_DIST)
670	$(call do_check_sha256,$(PCRE_DIST))
671	[ -d $(PCRE_OBJDIR) ] || mkdir -p $(PCRE_OBJDIR)
672	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(PCRE_DIST)
673	touch $@
674
675# configure pcre
676$(PCRE_OBJDIR)/.configured: $(PCRE_OBJDIR)/.retrieved
677	cd $(PCRE_OBJDIR) \
678		&& env CFLAGS="-g $(PROFILE_CFLAGS)" \
679		CC=$(CC) CXX=$(CXX) \
680		GREP="`which grep`" \
681		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
682		$(PCRE_SRCDIR)/configure \
683		--prefix=$(PREFIX)/pcre
684	touch $@
685
686# compile pcre
687$(PCRE_OBJDIR)/.compiled: $(PCRE_OBJDIR)/.configured
688	(cd $(PCRE_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
689	touch $@
690
691# install pcre
692$(PCRE_OBJDIR)/.installed: $(PCRE_OBJDIR)/.compiled
693	(cd $(PCRE_OBJDIR) && env MAKEFLAGS= make install)
694	touch $@
695
696#######################################################################
697# httpd
698#######################################################################
699
700HTTPD_CONF=	$(PREFIX)/httpd/conf/httpd-$(SVN_REL_WC).conf
701httpd-retrieve:	$(HTTPD_OBJDIR)/.retrieved
702httpd-configure:	$(HTTPD_OBJDIR)/.configured
703httpd-compile:	$(HTTPD_OBJDIR)/.compiled
704httpd-install:	$(HTTPD_OBJDIR)/.installed $(HTTPD_CONF)
705httpd-reset:
706	$(foreach f, .retrieved .configured .compiled .installed, \
707		rm -f $(HTTPD_OBJDIR)/$(f);)
708
709httpd-clean:
710	-(cd $(HTTPD_OBJDIR) && env MAKEFLAGS= make clean)
711	rm -f $(HTTPD_OBJDIR)/mod-proxy-no-threads-2.4.diff
712	rm -f $(HTTPD_OBJDIR)/ssl-init-proxy-certs.diff
713
714# fetch distfile for httpd
715$(DISTDIR)/$(HTTPD_DIST):
716	cd $(DISTDIR) && $(FETCH_CMD) $(HTTPD_URL)
717
718$(HTTPD_OBJDIR)/ssl-init-proxy-certs.diff:
719	mkdir -p $(dir $@)
720	echo > $@.tmp '--- modules/ssl/ssl_engine_init.c.orig	Sun Dec 16 13:34:14 2018'
721	echo >> $@.tmp '+++ modules/ssl/ssl_engine_init.c	Sun Dec 16 13:34:59 2018'
722	echo >> $@.tmp '@@ -1492,7 +1492,7 @@'
723	echo >> $@.tmp '     X509_STORE_CTX *sctx;'
724	echo >> $@.tmp '     X509_STORE *store = SSL_CTX_get_cert_store(mctx->ssl_ctx);'
725	echo >> $@.tmp ' '
726	echo >> $@.tmp '-#if OPENSSL_VERSION_NUMBER >= 0x1010100fL'
727	echo >> $@.tmp '+#if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(LIBRESSL_VERSION_NUMBER)'
728	echo >> $@.tmp '     /* For OpenSSL >=1.1.1, turn on client cert support which is'
729	echo >> $@.tmp '      * otherwise turned off by default (by design).'
730	echo >> $@.tmp '      * https://github.com/openssl/openssl/issues/6933 */'
731	mv -f $@.tmp $@
732
733$(HTTPD_OBJDIR)/mod-proxy-no-threads-2.4.diff:
734	cd $(HTTPD_OBJDIR) && $(FETCH_CMD) https://stsp.name/mod-proxy-no-threads-2.4.diff
735
736# retrieve httpd
737$(HTTPD_OBJDIR)/.retrieved: $(DISTDIR)/$(HTTPD_DIST) \
738	$(HTTPD_OBJDIR)/ssl-init-proxy-certs.diff \
739	$(HTTPD_OBJDIR)/mod-proxy-no-threads-2.4.diff
740	$(call do_check_sha256,$(HTTPD_DIST))
741	[ -d $(HTTPD_OBJDIR) ] || mkdir -p $(HTTPD_OBJDIR)
742	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(HTTPD_DIST)
743	(cd $(HTTPD_SRCDIR) && patch -p0 < $(HTTPD_OBJDIR)/ssl-init-proxy-certs.diff)
744	(cd $(HTTPD_SRCDIR) && patch -p0 < $(HTTPD_OBJDIR)/mod-proxy-no-threads-2.4.diff)
745	(cd $(HTTPD_SRCDIR) && svn diff -cr1849590 https://svn.apache.org/repos/asf/httpd/httpd/trunk | patch -p0)
746	(cd $(HTTPD_SRCDIR) && svn diff -cr1663375 https://svn.apache.org/repos/asf/httpd/httpd/trunk | patch -p0)
747	touch $@
748
749# configure httpd
750$(HTTPD_OBJDIR)/.configured: $(HTTPD_OBJDIR)/.retrieved \
751	$(APR_UTIL_OBJDIR)/.installed $(PCRE_OBJDIR)/.installed
752	cd $(HTTPD_SRCDIR) && ./buildconf \
753		--with-apr="$(PREFIX)/apr/bin/apr-1-config" \
754		--with-apr-util="$(PREFIX)/apr/bin/apu-1-config"
755	cd $(HTTPD_OBJDIR) \
756		&& env CFLAGS="-g $(PROFILE_CFLAGS) -DAPR_POOL_DEBUG" \
757		CC=$(CC) CXX=$(CXX) \
758		GREP="`which grep`" \
759		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
760		$(HTTPD_SRCDIR)/configure \
761		--prefix=$(PREFIX)/httpd \
762		--with-mpm=prefork \
763		--enable-ssl \
764		--enable-dav \
765		--enable-proxy \
766		--disable-md \
767		--disable-http2 \
768		--disable-brotli \
769		--with-apr="$(PREFIX)/apr/bin/apr-1-config" \
770		--with-apr-util="$(PREFIX)/apr/bin/apu-1-config" \
771		--with-pcre="$(PREFIX)/pcre"
772	touch $@
773
774# compile httpd
775$(HTTPD_OBJDIR)/.compiled: $(HTTPD_OBJDIR)/.configured
776	(cd $(HTTPD_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
777	touch $@
778
779# install httpd
780$(HTTPD_OBJDIR)/.installed: $(HTTPD_OBJDIR)/.compiled
781	(cd $(HTTPD_OBJDIR) && env MAKEFLAGS= make install)
782	touch $@
783
784# create a httpd.conf for mod_dav_svn
785$(HTTPD_CONF):
786	mkdir -p $(dir $@)
787	echo > $@.tmp '# httpd config for use with mod_dav_svn'
788	echo >>$@.tmp 'ServerRoot "$(PREFIX)/httpd"'
789	echo >>$@.tmp 'Listen localhost:8080'
790	echo >>$@.tmp 'LoadModule unixd_module modules/mod_unixd.so'
791	echo >>$@.tmp 'LoadModule alias_module modules/mod_alias.so'
792	echo >>$@.tmp 'LoadModule access_compat_module modules/mod_access_compat.so'
793	echo >>$@.tmp 'LoadModule authn_core_module modules/mod_authn_core.so'
794	echo >>$@.tmp 'LoadModule authn_file_module modules/mod_authn_file.so'
795	echo >>$@.tmp 'LoadModule authz_core_module modules/mod_authz_core.so'
796	echo >>$@.tmp 'LoadModule authz_user_module modules/mod_authz_user.so'
797	echo >>$@.tmp 'LoadModule authz_groupfile_module modules/mod_authz_groupfile.so'
798	echo >>$@.tmp 'LoadModule auth_basic_module modules/mod_auth_basic.so'
799	echo >>$@.tmp 'LoadModule dav_module modules/mod_dav.so'
800	echo >>$@.tmp 'LoadModule dav_svn_module modules/svn-$(WC)/mod_dav_svn.so'
801	echo >>$@.tmp 'LoadModule authz_svn_module modules/svn-$(WC)/mod_authz_svn.so'
802	echo >>$@.tmp 'DocumentRoot "$(PREFIX)/httpd/htdocs"'
803	echo >>$@.tmp '<Directory />'
804	echo >>$@.tmp '    Options FollowSymLinks'
805	echo >>$@.tmp '    AllowOverride None'
806	echo >>$@.tmp '    Require all denied'
807	echo >>$@.tmp '</Directory>'
808	echo >>$@.tmp '<Location /repos>'
809	echo >>$@.tmp '    DAV svn'
810	echo >>$@.tmp '    SVNPath /tmp/svn-sandbox/repos'
811	echo >>$@.tmp '    Require ip localhost'
812	echo >>$@.tmp '</Location>'
813	mv -f $@.tmp $@
814
815#######################################################################
816# neon
817#######################################################################
818
819neon-retrieve:	$(NEON_OBJDIR)/.retrieved
820neon-configure:	$(NEON_OBJDIR)/.configured
821neon-compile:	$(NEON_OBJDIR)/.compiled
822neon-install:	$(NEON_OBJDIR)/.installed
823neon-reset:
824	$(foreach f, .retrieved .configured .compiled .installed, \
825		rm -f $(NEON_OBJDIR)/$(f);)
826
827neon-clean:
828	-(cd $(NEON_OBJDIR) && env MAKEFLAGS= make clean)
829
830# fetch distfile for neon
831$(DISTDIR)/$(NEON_DIST):
832	cd $(DISTDIR) && $(FETCH_CMD) $(NEON_URL)
833
834# retrieve neon
835$(NEON_OBJDIR)/.retrieved: $(DISTDIR)/$(NEON_DIST)
836	$(call do_check_sha256,$(NEON_DIST))
837	[ -d $(NEON_OBJDIR) ] || mkdir -p $(NEON_OBJDIR)
838	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(NEON_DIST)
839	touch $@
840
841# OpenBSD does not have krb5-config in PATH, but the neon port has
842# a suitable replacement.
843ifeq ($(UNAME),OpenBSD)
844KRB5_CONFIG_PATH=/usr/ports/net/neon/files
845endif
846
847# configure neon
848$(NEON_OBJDIR)/.configured: $(NEON_OBJDIR)/.retrieved
849	cd $(NEON_SRCDIR) && ./autogen.sh
850	if [ -n "$(KRB5_CONFIG_PATH)" ] && [ -d "$(KRB5_CONFIG_PATH)" ]; then \
851		cp $(KRB5_CONFIG_PATH)/krb5-config $(NEON_OBJDIR); \
852		chmod +x $(NEON_OBJDIR)/krb5-config; \
853	fi
854	cd $(NEON_OBJDIR) \
855		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`" \
856		CC=$(CC) CXX=$(CXX) \
857		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
858		$(NEON_SRCDIR)/configure \
859		PATH=$(NEON_OBJDIR):$$PATH \
860		--prefix=$(PREFIX)/neon \
861		--with-ssl \
862		--enable-shared \
863		--without-libproxy
864	touch $@
865
866# compile neon
867$(NEON_OBJDIR)/.compiled: $(NEON_OBJDIR)/.configured
868	(cd $(NEON_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
869	touch $@
870
871# install neon
872$(NEON_OBJDIR)/.installed: $(NEON_OBJDIR)/.compiled
873	(cd $(NEON_OBJDIR) && env MAKEFLAGS= make install)
874	touch $@
875
876
877#######################################################################
878# serf
879#######################################################################
880
881serf-retrieve:	$(SERF_OBJDIR)/.retrieved
882serf-configure:	$(SERF_OBJDIR)/.configured
883serf-compile:	$(SERF_OBJDIR)/.compiled
884serf-install:	$(SERF_OBJDIR)/.installed
885serf-reset:
886	$(foreach f, .retrieved .configured .compiled .installed, \
887		rm -f $(SERF_OBJDIR)/$(f);)
888
889serf-clean:
890	-(cd $(SERF_SRCDIR) && scons -c)
891
892
893# fetch distfile for serf
894#$(DISTDIR)/$(SERF_DIST):
895#	cd $(DISTDIR) && $(FETCH_CMD) $(SERF_URL)
896#
897# retrieve serf
898#$(SERF_OBJDIR)/.retrieved: $(DISTDIR)/$(SERF_DIST)
899#	[ -d $(SERF_OBJDIR) ] || mkdir -p $(SERF_OBJDIR)
900#	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(SERF_DIST)
901#	touch $@
902
903# retrieve serf if not present yet
904$(SERF_OBJDIR)/.retrieved:
905	[ -d $(SERF_OBJDIR) ] || mkdir -p $(SERF_OBJDIR)
906	if [ ! -d $(SERF_SRCDIR) ]; then \
907		svn co $(SERF_URL) $(SERF_SRCDIR); \
908		svn merge ^/serf/branches/1.3.x-sslbuild@1781542 $(SERF_SRCDIR); \
909	fi
910	touch $@
911
912# compile serf (serf won't compile outside its source tree)
913$(SERF_OBJDIR)/.compiled: $(SERF_OBJDIR)/.retrieved \
914	$(APR_UTIL_OBJDIR)/.installed
915	cd $(SERF_SRCDIR) && \
916		scons -j${MAKE_JOBS} DEBUG=1 \
917			CFLAGS="-O0 -g $(PROFILE_CFLAGS) -DAPR_POOL_DEBUG" \
918			CC=$(CC) CXX=$(CXX) \
919			APR=$(PREFIX)/apr \
920			APU=$(PREFIX)/apr \
921			PREFIX=$(PREFIX)/serf \
922			PKG_CONFIG_PATH=$(PKG_CONFIG_PATH)
923	touch $@
924
925# install serf
926$(SERF_OBJDIR)/.installed: $(SERF_OBJDIR)/.compiled
927	rm -rf $(PREFIX)/serf # XXX scons cannot reinstall :(
928	cd $(SERF_SRCDIR) && \
929		scons install
930	# work around unportable scons shared lib support
931	-ln -s libserf-1.so.$(shell echo $(SERF_VER) | sed -e 's/[0-9]$$/0/') \
932		$(PREFIX)/serf/lib/libserf-1.so
933	touch $@
934
935#######################################################################
936# serf-old (compatible with Subversion 1.5)
937#######################################################################
938
939serf-old-retrieve:	$(SERF_OLD_OBJDIR)/.retrieved
940serf-old-configure:	$(SERF_OLD_OBJDIR)/.configured
941serf-old-compile:	$(SERF_OLD_OBJDIR)/.compiled
942serf-old-install:	$(SERF_OLD_OBJDIR)/.installed
943serf-old-reset:
944	$(foreach f, .retrieved .configured .compiled .installed, \
945		rm -f $(SERF_OLD_OBJDIR)/$(f);)
946
947serf-old-clean:
948	-(cd $(SERF_OLD_SRCDIR) && ./serfmake clean)
949
950# retrieve serf if not present yet
951$(SERF_OLD_OBJDIR)/.retrieved:
952	[ -d $(SERF_OLD_OBJDIR) ] || mkdir -p $(SERF_OLD_OBJDIR)
953	if [ ! -d $(SERF_OLD_SRCDIR) ]; then \
954		svn export $(SERF_OLD_URL) $(SERF_OLD_SRCDIR); \
955	fi
956	touch $@
957
958# compile serf (serf won't compile outside its source tree)
959$(SERF_OLD_OBJDIR)/.compiled: $(SERF_OLD_OBJDIR)/.retrieved \
960	$(APR_UTIL_OBJDIR)/.installed
961	cd $(SERF_OLD_SRCDIR) && \
962		env CFLAGS="-O0 -g $(PROFILE_CFLAGS) -DAPR_POOL_DEBUG" \
963			CC=$(CC) CXX=$(CXX) \
964			./serfmake --with-apr=$(PREFIX)/apr \
965			--prefix=$(PREFIX)/serf-old \
966			build
967	touch $@
968
969# install serf
970$(SERF_OLD_OBJDIR)/.installed: $(SERF_OLD_OBJDIR)/.compiled
971	cd $(SERF_OLD_SRCDIR) && \
972		./serfmake --with-apr=$(PREFIX)/apr \
973			--with-apr-util=$(PREFIX)/apr \
974			--prefix=$(PREFIX)/serf-old \
975			install
976	touch $@
977
978
979#######################################################################
980# sqlite
981#######################################################################
982
983sqlite-retrieve:	$(SQLITE_OBJDIR)/.retrieved
984sqlite-configure:	$(SQLITE_OBJDIR)/.configured
985sqlite-compile:	$(SQLITE_OBJDIR)/.compiled
986sqlite-install:	$(SQLITE_OBJDIR)/.installed
987sqlite-reset:
988	$(foreach f, .retrieved .configured .compiled .installed, \
989		rm -f $(SQLITE_OBJDIR)/$(f);)
990
991sqlite-clean:
992	-cd $(SQLITE_OBJDIR) && env MAKEFLAGS= make clean
993
994# fetch distfile for sqlite
995$(DISTDIR)/$(SQLITE_DIST):
996	cd $(DISTDIR) && $(FETCH_CMD) $(SQLITE_URL)
997
998# retrieve sqlite
999$(SQLITE_OBJDIR)/.retrieved: $(DISTDIR)/$(SQLITE_DIST)
1000	$(call do_check_sha256,$(SQLITE_DIST))
1001	[ -d $(SQLITE_OBJDIR) ] || mkdir -p $(SQLITE_OBJDIR)
1002	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(SQLITE_DIST)
1003	touch $@
1004
1005ifeq ($(THREADING),yes)
1006THREADSAFE_FLAG=--enable-threadsafe
1007else
1008THREADSAFE_FLAG=--disable-threadsafe
1009endif
1010
1011# configure sqlite
1012$(SQLITE_OBJDIR)/.configured: $(SQLITE_OBJDIR)/.retrieved
1013	cd $(SQLITE_OBJDIR) \
1014		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`" \
1015		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
1016		CC=$(CC) CXX=$(CXX) \
1017		$(SQLITE_SRCDIR)/configure \
1018		--prefix=$(PREFIX)/sqlite \
1019		$(THREADSAFE_FLAG)
1020	touch $@
1021
1022# compile sqlite
1023$(SQLITE_OBJDIR)/.compiled: $(SQLITE_OBJDIR)/.configured
1024	(cd $(SQLITE_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
1025	touch $@
1026
1027# install sqlite
1028$(SQLITE_OBJDIR)/.installed: $(SQLITE_OBJDIR)/.compiled
1029	(cd $(SQLITE_OBJDIR) && env MAKEFLAGS= make install)
1030	touch $@
1031
1032#######################################################################
1033# cyrus-sasl
1034#######################################################################
1035
1036cyrus-sasl-retrieve:	$(CYRUS_SASL_OBJDIR)/.retrieved
1037cyrus-sasl-configure:	$(CYRUS_SASL_OBJDIR)/.configured
1038cyrus-sasl-compile:	$(CYRUS_SASL_OBJDIR)/.compiled
1039cyrus-sasl-install:	$(CYRUS_SASL_OBJDIR)/.installed
1040cyrus-sasl-reset:
1041	$(foreach f, .retrieved .configured .compiled .installed, \
1042		rm -f $(CYRUS_SASL_OBJDIR)/$(f);)
1043
1044cyrus-sasl-clean:
1045	-(cd $(CYRUS_SASL_OBJDIR) && env MAKEFLAGS= make distclean)
1046
1047# fetch distfile for cyrus-sasl
1048$(DISTDIR)/$(CYRUS_SASL_DIST):
1049	cd $(DISTDIR) && $(FETCH_CMD) $(CYRUS_SASL_URL)
1050
1051# retrieve cyrus-sasl
1052$(CYRUS_SASL_OBJDIR)/.retrieved: $(DISTDIR)/$(CYRUS_SASL_DIST)
1053	$(call do_check_sha256,$(CYRUS_SASL_DIST))
1054	[ -d $(CYRUS_SASL_OBJDIR) ] || mkdir -p $(CYRUS_SASL_OBJDIR)
1055	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(CYRUS_SASL_DIST)
1056	# fixes build on Debian:
1057	sed 's/#elif WITH_DES/#elif defined(WITH_DES)/' \
1058		< $(CYRUS_SASL_SRCDIR)/plugins/digestmd5.c \
1059		> $(CYRUS_SASL_SRCDIR)/plugins/digestmd5.c.patched
1060	mv $(CYRUS_SASL_SRCDIR)/plugins/digestmd5.c.patched \
1061		$(CYRUS_SASL_SRCDIR)/plugins/digestmd5.c
1062ifeq ($(UNAME),OpenBSD)
1063	# Fixes GSSAPI support on OpenBSD, which hasn't got libroken:
1064	for f in `grep -l -R -- -lroken $(CYRUS_SASL_SRCDIR)`; do \
1065		sed -e 's/-lroken//g' < $$f > $$f.tmp && \
1066		mv $$f.tmp $$f; \
1067	done
1068	chmod +x $(CYRUS_SASL_SRCDIR)/configure
1069endif
1070	# Fixes excessive auth log spam from sasl if broken .la files exist
1071	sed 's/SASL_LOG_WARN/SASL_LOG_DEBUG/' \
1072		< $(CYRUS_SASL_SRCDIR)/lib/dlopen.c \
1073		> $(CYRUS_SASL_SRCDIR)/lib/dlopen.c.patched
1074	mv $(CYRUS_SASL_SRCDIR)/lib/dlopen.c.patched \
1075		$(CYRUS_SASL_SRCDIR)/lib/dlopen.c
1076	# Fix a weird autotools error about missing cmulocal dir
1077	(cd $(CYRUS_SASL_SRCDIR)/saslauthd/ && ln -sf ../cmulocal)
1078	touch $@
1079
1080# configure cyrus-sasl
1081$(CYRUS_SASL_OBJDIR)/.configured: $(CYRUS_SASL_OBJDIR)/.retrieved \
1082	$(BDB_OBJDIR)/.installed $(SQLITE_OBJDIR)/.installed
1083	cd $(CYRUS_SASL_OBJDIR) \
1084		&& env CFLAGS="-g $(PROFILE_CFLAGS)" \
1085		CPPFLAGS="-I/usr/include/kerberosV" \
1086		CC=$(CC) CXX=$(CXX) \
1087		GREP="`which grep`" \
1088		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
1089		$(CYRUS_SASL_SRCDIR)/configure \
1090		--with-dbpath=$(PREFIX)/cyrus-sasl/etc/sasldb2 \
1091		--with-plugindir=$(PREFIX)/cyrus-sasl/lib/sasl2 \
1092		--with-configdir=$(PREFIX)/cyrus-sasl/lib/sasl2 \
1093		--with-bdb-libdir=$(PREFIX)/bdb/lib \
1094		--with-bdb-incdir=$(PREFIX)/bdb/include \
1095		--with-dblib=berkeley \
1096		--with-sqlite=$(PREFIX)/sqlite \
1097		--prefix=$(PREFIX)/cyrus-sasl
1098	touch $@
1099
1100# compile cyrus-sasl (ignore MAKE_JOBS; multiple jobs cause random build failures)
1101$(CYRUS_SASL_OBJDIR)/.compiled: $(CYRUS_SASL_OBJDIR)/.configured
1102	(cd $(CYRUS_SASL_OBJDIR) && env MAKEFLAGS= make)
1103	touch $@
1104
1105# install cyrus-sasl
1106$(CYRUS_SASL_OBJDIR)/.installed: $(CYRUS_SASL_OBJDIR)/.compiled
1107	(cd $(CYRUS_SASL_OBJDIR) && env MAKEFLAGS= make install)
1108	touch $@
1109
1110#######################################################################
1111# libmagic
1112#######################################################################
1113
1114libmagic-retrieve:	$(LIBMAGIC_OBJDIR)/.retrieved
1115libmagic-configure:	$(LIBMAGIC_OBJDIR)/.configured
1116libmagic-compile:	$(LIBMAGIC_OBJDIR)/.compiled
1117libmagic-install:	$(LIBMAGIC_OBJDIR)/.installed
1118libmagic-reset:
1119	$(foreach f, .retrieved .configured .compiled .installed, \
1120		rm -f $(LIBMAGIC_OBJDIR)/$(f);)
1121
1122libmagic-clean:
1123	-(cd $(LIBMAGIC_OBJDIR) && env MAKEFLAGS= make distclean)
1124
1125# fetch distfile for libmagic
1126$(DISTDIR)/$(LIBMAGIC_DIST):
1127	cd $(DISTDIR) && $(FETCH_CMD) $(LIBMAGIC_URL)
1128
1129# retrieve libmagic
1130$(LIBMAGIC_OBJDIR)/.retrieved: $(DISTDIR)/$(LIBMAGIC_DIST)
1131	$(call do_check_sha256,$(LIBMAGIC_DIST))
1132	[ -d $(LIBMAGIC_OBJDIR) ] || mkdir -p $(LIBMAGIC_OBJDIR)
1133	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(LIBMAGIC_DIST)
1134	touch $@
1135
1136# configure libmagic
1137$(LIBMAGIC_OBJDIR)/.configured: $(LIBMAGIC_OBJDIR)/.retrieved
1138	cd $(LIBMAGIC_OBJDIR) \
1139		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`"\
1140		CC=$(CC) CXX=$(CXX) \
1141		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
1142		$(LIBMAGIC_SRCDIR)/configure \
1143		--enable-fsect-man5 \
1144		--prefix=$(PREFIX)/libmagic
1145	touch $@
1146
1147# compile libmagic
1148$(LIBMAGIC_OBJDIR)/.compiled: $(LIBMAGIC_OBJDIR)/.configured
1149	(cd $(LIBMAGIC_OBJDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
1150	touch $@
1151
1152# install libmagic
1153$(LIBMAGIC_OBJDIR)/.installed: $(LIBMAGIC_OBJDIR)/.compiled
1154	(cd $(LIBMAGIC_OBJDIR) && env MAKEFLAGS= make install)
1155	touch $@
1156
1157#######################################################################
1158# ruby
1159#######################################################################
1160
1161ruby-retrieve:	$(RUBY_OBJDIR)/.retrieved
1162ruby-configure:	$(RUBY_OBJDIR)/.configured
1163ruby-compile:	$(RUBY_OBJDIR)/.compiled
1164ruby-install:	$(RUBY_OBJDIR)/.installed
1165ruby-reset:
1166	$(foreach f, .retrieved .configured .compiled .installed, \
1167		rm -f $(RUBY_OBJDIR)/$(f);)
1168
1169ruby-clean:
1170	-(cd $(RUBY_OBJDIR) && env MAKEFLAGS= make distclean)
1171
1172# fetch distfile for ruby
1173$(DISTDIR)/$(RUBY_DIST):
1174	cd $(DISTDIR) && $(FETCH_CMD) $(RUBY_URL)
1175
1176$(RUBY_OBJDIR)/openssl_missing.patch:
1177	mkdir -p $(dir $@)
1178	echo > $@.tmp 'Index: ext/openssl/openssl_missing.h'
1179	echo >> $@.tmp '--- ext/openssl/openssl_missing.h.orig'
1180	echo >> $@.tmp '+++ ext/openssl/openssl_missing.h'
1181	echo >> $@.tmp '@@ -119,6 +119,9 @@ void ossl_HMAC_CTX_free(HMAC_CTX *);'
1182	echo >> $@.tmp ' #if !defined(HAVE_X509_STORE_SET_EX_DATA)'
1183	echo >> $@.tmp ' #  define X509_STORE_set_ex_data(x, idx, data) \'
1184	echo >> $@.tmp ' 	CRYPTO_set_ex_data(&(x)->ex_data, (idx), (data))'
1185	echo >> $@.tmp '+#endif'
1186	echo >> $@.tmp '+'
1187	echo >> $@.tmp '+#if !defined(HAVE_X509_STORE_GET_EX_NEW_INDEX)'
1188	echo >> $@.tmp ' #  define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \'
1189	echo >> $@.tmp ' 	CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, (l), (p), \'
1190	echo >> $@.tmp ' 				(newf), (dupf), (freef))'
1191	echo >> $@.tmp '@@ -192,6 +195,7 @@ void ossl_X509_REQ_get0_signature(const X509_REQ *, co'
1192	echo >> $@.tmp ' #endif'
1193	echo >> $@.tmp ' '
1194	echo >> $@.tmp ' #if !defined(HAVE_OPAQUE_OPENSSL)'
1195	echo >> $@.tmp '+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL'
1196	echo >> $@.tmp ' #define IMPL_PKEY_GETTER(_type, _name) \'
1197	echo >> $@.tmp ' static inline _type *EVP_PKEY_get0_##_type(EVP_PKEY *pkey) { \'
1198	echo >> $@.tmp ' 	return pkey->pkey._name; }'
1199	echo >> $@.tmp '@@ -243,6 +247,7 @@ IMPL_PKEY_GETTER(EC_KEY, ec)'
1200	echo >> $@.tmp ' #undef IMPL_PKEY_GETTER'
1201	echo >> $@.tmp ' #undef IMPL_KEY_ACCESSOR2'
1202	echo >> $@.tmp ' #undef IMPL_KEY_ACCESSOR3'
1203	echo >> $@.tmp '+#endif'
1204	echo >> $@.tmp ' #endif /* HAVE_OPAQUE_OPENSSL */'
1205	echo >> $@.tmp ' '
1206	echo >> $@.tmp ' #if defined(HAVE_AUTHENTICATED_ENCRYPTION) && !defined(EVP_CTRL_AEAD_GET_TAG)'
1207	mv -f $@.tmp $@
1208
1209$(RUBY_OBJDIR)/sparc64_buserror.patch:
1210	mkdir -p $(dir $@)
1211	echo > $@.tmp '--- compile.c.orig	Thu Mar 12 12:58:26 2020'
1212	echo >> $@.tmp '+++ compile.c	Thu Mar 12 16:36:55 2020'
1213	echo >> $@.tmp '@@ -751,6 +751,16 @@'
1214	echo >> $@.tmp '   #define STRICT_ALIGNMENT'
1215	echo >> $@.tmp ' #endif'
1216	echo >> $@.tmp ' '
1217	echo >> $@.tmp '+/*'
1218	echo >> $@.tmp '+ * Some OpenBSD platforms (including sparc64) require strict alignment.'
1219	echo >> $@.tmp '+ */'
1220	echo >> $@.tmp '+#if defined(__OpenBSD__)'
1221	echo >> $@.tmp '+  #include <sys/endian.h>'
1222	echo >> $@.tmp '+  #ifdef __STRICT_ALIGNMENT'
1223	echo >> $@.tmp '+    #define STRICT_ALIGNMENT'
1224	echo >> $@.tmp '+  #endif'
1225	echo >> $@.tmp '+#endif'
1226	echo >> $@.tmp '+'
1227	echo >> $@.tmp ' #ifdef STRICT_ALIGNMENT'
1228	echo >> $@.tmp '   #if defined(HAVE_TRUE_LONG_LONG) && SIZEOF_LONG_LONG > SIZEOF_VALUE'
1229	echo >> $@.tmp '     #define ALIGNMENT_SIZE SIZEOF_LONG_LONG'
1230	echo >> $@.tmp '@@ -2094,7 +2104,8 @@'
1231	echo >> $@.tmp ' 	    unref_destination(iobj, 0);'
1232	echo >> $@.tmp ' 	    REMOVE_ELEM(&iobj->link);'
1233	echo >> $@.tmp ' 	}'
1234	echo >> $@.tmp '-	else if (iobj != diobj && IS_INSN_ID(diobj, jump) &&'
1235	echo >> $@.tmp '+	else if (iobj != diobj && IS_INSN(&diobj->link) &&'
1236	echo >> $@.tmp '+		 IS_INSN_ID(diobj, jump) &&'
1237	echo >> $@.tmp ' 		 OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) {'
1238	echo >> $@.tmp ' 	    replace_destination(iobj, diobj);'
1239	echo >> $@.tmp ' 	    remove_unreachable_chunk(iseq, iobj->link.next);'
1240	echo >> $@.tmp '@@ -2136,6 +2147,7 @@'
1241	echo >> $@.tmp ' 	 * L2:'
1242	echo >> $@.tmp ' 	 */'
1243	echo >> $@.tmp ' 	else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&'
1244	echo >> $@.tmp '+		 IS_INSN(&piobj->link) &&'
1245	echo >> $@.tmp ' 		 (IS_INSN_ID(piobj, branchif) ||'
1246	echo >> $@.tmp ' 		  IS_INSN_ID(piobj, branchunless))) {'
1247	echo >> $@.tmp ' 	    if (niobj == (INSN *)get_destination_insn(piobj)) {'
1248	echo >> $@.tmp '@@ -2176,7 +2188,7 @@'
1249	echo >> $@.tmp ' 	}'
1250	echo >> $@.tmp ' '
1251	echo >> $@.tmp ' 	for (;;) {'
1252	echo >> $@.tmp '-	    if (IS_INSN_ID(nobj, jump)) {'
1253	echo >> $@.tmp '+	    if (IS_INSN(&nobj->link) && IS_INSN_ID(nobj, jump)) {'
1254	echo >> $@.tmp ' 		replace_destination(iobj, nobj);'
1255	echo >> $@.tmp ' 	    }'
1256	echo >> $@.tmp ' 	    else if (prev_dup && IS_INSN_ID(nobj, dup) &&'
1257	mv -f $@.tmp $@
1258
1259ifeq ($(UNAME),OpenBSD)
1260RUBY_SSL_EX_NEW_DATA_PATCH = sed -i -e '/^have_func("X509_STORE_set_ex_data")$$/ { p; s/^.*$$/\have_func("X509_STORE_get_ex_new_index")/; }'
1261else
1262RUBY_SSL_EX_NEW_DATA_PATCH = true
1263endif
1264
1265# retrieve ruby
1266#
1267$(RUBY_OBJDIR)/.retrieved: $(DISTDIR)/$(RUBY_DIST) $(RUBY_OBJDIR)/openssl_missing.patch $(RUBY_OBJDIR)/sparc64_buserror.patch
1268	$(call do_check_sha256,$(RUBY_DIST))
1269	[ -d $(RUBY_OBJDIR) ] || mkdir -p $(RUBY_OBJDIR)
1270	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(RUBY_DIST)
1271	-which ghead && sed -i -e "s/head -c/ghead -c/" $(RUBY_SRCDIR)/configure
1272	$(RUBY_SSL_EX_NEW_DATA_PATCH) $(RUBY_SRCDIR)/ext/openssl/extconf.rb
1273	cd $(RUBY_SRCDIR) && patch -p0 < $(RUBY_OBJDIR)/openssl_missing.patch
1274	cd $(RUBY_SRCDIR) && patch -p0 < $(RUBY_OBJDIR)/sparc64_buserror.patch
1275	touch $@
1276
1277ifeq ($(THREADING),yes)
1278THREADSAFE_FLAG=--enable-pthread
1279else
1280THREADSAFE_FLAG=--disable-pthread
1281endif
1282
1283# configure ruby
1284$(RUBY_OBJDIR)/.configured: $(RUBY_OBJDIR)/.retrieved
1285	cd $(RUBY_OBJDIR) \
1286		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`"\
1287		CC=$(CC) CXX=$(CXX) \
1288		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
1289		$(RUBY_SRCDIR)/configure \
1290		--prefix=$(PREFIX)/ruby \
1291		--enable-shared \
1292		--with-baseruby="$(RUBY)" \
1293		$(THREADSAFE_FLAG) \
1294		--disable-install-doc \
1295		--without-valgrind \
1296		--without-gmp
1297	touch $@
1298
1299# compile ruby (ignore MAKE_JOBS; multiple jobs cause random build failures)
1300$(RUBY_OBJDIR)/.compiled: $(RUBY_OBJDIR)/.configured
1301	(cd $(RUBY_OBJDIR) && env MAKEFLAGS= make)
1302	touch $@
1303
1304# install ruby
1305$(RUBY_OBJDIR)/.installed: $(RUBY_OBJDIR)/.compiled
1306	(cd $(RUBY_OBJDIR) && env MAKEFLAGS= make install)
1307	touch $@
1308
1309#######################################################################
1310# bz2
1311#######################################################################
1312
1313bz2-retrieve:	$(BZ2_OBJDIR)/.retrieved
1314bz2-compile:	$(BZ2_OBJDIR)/.compiled
1315bz2-install:	$(BZ2_OBJDIR)/.installed
1316bz2-reset:
1317	$(foreach f, .retrieved .configured .compiled .installed, \
1318		rm -f $(BZ2_OBJDIR)/$(f);)
1319
1320bz2-clean:
1321	-(cd $(BZ2_SRCDIR) && env MAKEFLAGS= make distclean)
1322
1323# fetch distfile for bz2
1324$(DISTDIR)/$(BZ2_DIST):
1325	cd $(DISTDIR) && $(FETCH_CMD) $(BZ2_URL)
1326
1327# retrieve bz2
1328$(BZ2_OBJDIR)/.retrieved: $(DISTDIR)/$(BZ2_DIST)
1329	$(call do_check_sha256,$(BZ2_DIST))
1330	[ -d $(BZ2_OBJDIR) ] || mkdir -p $(BZ2_OBJDIR)
1331	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(BZ2_DIST)
1332	touch $@
1333
1334# compile bz2
1335$(BZ2_OBJDIR)/.compiled: $(BZ2_OBJDIR)/.retrieved
1336	(cd $(BZ2_SRCDIR) && env MAKEFLAGS= make CC=$(CC) CXX=$(CXX) \
1337		CFLAGS="-g $(PROFILE_CFLAGS) -fPIC" -j${MAKE_JOBS})
1338	touch $@
1339
1340# install bz2
1341$(BZ2_OBJDIR)/.installed: $(BZ2_OBJDIR)/.compiled
1342	(cd $(BZ2_SRCDIR) && env MAKEFLAGS= make install PREFIX=$(PREFIX)/bz2)
1343	touch $@
1344
1345
1346#######################################################################
1347# python
1348#######################################################################
1349
1350python-retrieve:	$(PYTHON_OBJDIR)/.retrieved
1351python-configure:	$(PYTHON_OBJDIR)/.configured
1352python-compile:	$(PYTHON_OBJDIR)/.compiled
1353python-install:	$(PYTHON_OBJDIR)/.installed
1354python-reset:
1355	$(foreach f, .retrieved .configured .compiled .installed, \
1356		rm -f $(PYTHON_OBJDIR)/$(f);)
1357
1358python-clean:
1359	-(cd $(PYTHON_OBJDIR) && env MAKEFLAGS= make distclean)
1360
1361# fetch distfile for python
1362$(DISTDIR)/$(PYTHON_DIST):
1363	cd $(DISTDIR) && $(FETCH_CMD) $(PYTHON_URL)
1364
1365# retrieve python
1366#
1367$(PYTHON_OBJDIR)/.retrieved: $(DISTDIR)/$(PYTHON_DIST)
1368	$(call do_check_sha256,$(PYTHON_DIST))
1369	[ -d $(PYTHON_OBJDIR) ] || mkdir -p $(PYTHON_OBJDIR)
1370	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(PYTHON_DIST)
1371	# Make setup.py use our own dependencies instead of system ones
1372	sed -e "s#sqlite_inc_paths = \[ '/usr/include',#sqlite_inc_paths = [ '$(PREFIX)/sqlite/include',#" \
1373		-e "s#'/usr/include/db4'#'$(PREFIX)/bdb/include'#" \
1374		-e "s|\(add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')\)|pass #\1|" \
1375		-e "s|\(add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')\)|pass #\1|" \
1376		-e "s#find_library_file(lib_dirs, 'bz2'#find_library_file(['$(PREFIX)/bz2/lib'] + lib_dirs, 'bz2'#" \
1377		< $(PYTHON_SRCDIR)/setup.py \
1378		> $(PYTHON_SRCDIR)/setup.py.patched
1379	mv $(PYTHON_SRCDIR)/setup.py.patched $(PYTHON_SRCDIR)/setup.py
1380	chmod +x $(PYTHON_SRCDIR)/setup.py
1381	touch $@
1382
1383# configure python
1384ifdef PROFILE
1385PYTHON_PROFILING=--enable-profiling
1386endif
1387$(PYTHON_OBJDIR)/.configured: $(PYTHON_OBJDIR)/.retrieved \
1388	$(BZ2_OBJDIR)/.installed
1389	cd $(PYTHON_OBJDIR) \
1390		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`" \
1391		CC=$(CC) CXX=$(CXX) \
1392		CPPFLAGS="-I$(PREFIX)/bz2/include" \
1393		LDFLAGS="-Wl,-rpath=$(PREFIX)/python/lib -L$(PREFIX)/bz2/lib" \
1394		LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$$LD_LIBRARY_PATH" \
1395		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
1396		$(PYTHON_SRCDIR)/configure \
1397		--prefix=$(PREFIX)/python \
1398		--enable-shared \
1399		--with-system-expat \
1400		--with-dbmliborder=bdb \
1401		--without-pymalloc \
1402		$(PYTHON_PROFILING)
1403	touch $@
1404
1405# compile python
1406$(PYTHON_OBJDIR)/.compiled: $(PYTHON_OBJDIR)/.configured
1407	(cd $(PYTHON_OBJDIR) && \
1408		env MAKEFLAGS= \
1409		LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$$LD_LIBRARY_PATH" \
1410		make -j${MAKE_JOBS})
1411	touch $@
1412
1413# install python
1414$(PYTHON_OBJDIR)/.installed: $(PYTHON_OBJDIR)/.compiled
1415	(cd $(PYTHON_OBJDIR) && \
1416		env MAKEFLAGS= \
1417		LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$$LD_LIBRARY_PATH" \
1418		make install)
1419	touch $@
1420
1421#######################################################################
1422# py3c
1423#######################################################################
1424
1425py3c-retrieve:	$(PY3C_OBJDIR)/.retrieved
1426py3c-reset:
1427	$(foreach f, .retrieved .configured .compiled .installed, \
1428		rm -f $(PY3C_OBJDIR)/$(f);)
1429
1430# fetch distfile for py3c
1431$(DISTDIR)/$(PY3C_DIST):
1432	cd $(DISTDIR) && $(FETCH_CMD) $(PY3C_URL)
1433
1434# retrieve py3c
1435$(PY3C_OBJDIR)/.retrieved: $(DISTDIR)/$(PY3C_DIST)
1436	$(call do_check_sha256,$(PY3C_DIST))
1437	[ -d $(PY3C_OBJDIR) ] || mkdir -p $(PY3C_OBJDIR)
1438	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(PY3C_DIST)
1439	touch $@
1440
1441#######################################################################
1442# junit
1443#######################################################################
1444
1445# fetch distfile for junit
1446$(DISTDIR)/$(JUNIT_DIST):
1447	cd $(DISTDIR) && $(FETCH_CMD) $(JUNIT_URL)
1448	$(call do_check_sha256,$(JUNIT_DIST))
1449
1450
1451#######################################################################
1452# gettext
1453#######################################################################
1454
1455gettext-retrieve:	$(GETTEXT_OBJDIR)/.retrieved
1456gettext-configure:	$(GETTEXT_OBJDIR)/.configured
1457gettext-compile:	$(GETTEXT_OBJDIR)/.compiled
1458gettext-install:	$(GETTEXT_OBJDIR)/.installed
1459gettext-reset:
1460	$(foreach f, .retrieved .configured .compiled .installed, \
1461		rm -f $(GETTEXT_OBJDIR)/$(f);)
1462
1463gettext-clean:
1464	-(cd $(GETTEXT_SRCDIR) && env MAKEFLAGS= make clean)
1465
1466# fetch distfile for gettext
1467$(DISTDIR)/$(GETTEXT_DIST):
1468	cd $(DISTDIR) && $(FETCH_CMD) $(GETTEXT_URL)
1469
1470# retrieve gettext
1471$(GETTEXT_OBJDIR)/.retrieved: $(DISTDIR)/$(GETTEXT_DIST)
1472	$(call do_check_sha256,$(GETTEXT_DIST))
1473	[ -d $(GETTEXT_OBJDIR) ] || mkdir -p $(GETTEXT_OBJDIR)
1474	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(GETTEXT_DIST)
1475	touch $@
1476
1477# (gettext won't compile outside its source tree)
1478# configure gettext
1479$(GETTEXT_OBJDIR)/.configured: $(GETTEXT_OBJDIR)/.retrieved
1480	cd $(GETTEXT_SRCDIR) \
1481		&& env CFLAGS="-g $(PROFILE_CFLAGS)" GREP="`which grep`"\
1482		CC=$(CC) CXX=$(CXX) \
1483		LDFLAGS="-L$(PREFIX)/iconv/lib" \
1484		PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
1485		$(GETTEXT_SRCDIR)/configure \
1486		--prefix=$(PREFIX)/gettext \
1487		--with-libiconv-prefix=$(PREFIX)/iconv \
1488		--disable-c++ \
1489		--disable-java \
1490		--disable-csharp \
1491		$(THREADS_FLAG)
1492	-which gsed && \
1493		sed -e 's/sed /gsed /g' < $(GETTEXT_SRCDIR)/build-aux/moopp \
1494		> $(GETTEXT_SRCDIR)/build-aux/moopp.fixed && \
1495		mv $(GETTEXT_SRCDIR)/build-aux/moopp.fixed \
1496		$(GETTEXT_SRCDIR)/build-aux/moopp && \
1497		chmod +x $(GETTEXT_SRCDIR)/build-aux/moopp
1498	touch $@
1499
1500# compile gettext
1501$(GETTEXT_OBJDIR)/.compiled: $(GETTEXT_OBJDIR)/.configured
1502	(cd $(GETTEXT_SRCDIR) && env MAKEFLAGS= make -j${MAKE_JOBS})
1503	touch $@
1504
1505# install gettext
1506$(GETTEXT_OBJDIR)/.installed: $(GETTEXT_OBJDIR)/.compiled
1507	(cd $(GETTEXT_SRCDIR) && env MAKEFLAGS= make install)
1508	touch $@
1509
1510#######################################################################
1511# lz4
1512#######################################################################
1513
1514lz4-retrieve:	$(LZ4_OBJDIR)/.retrieved
1515lz4-configure:	$(LZ4_OBJDIR)/.configured
1516lz4-compile:	$(LZ4_OBJDIR)/.compiled
1517lz4-install:	$(LZ4_OBJDIR)/.installed
1518lz4-reset:
1519	$(foreach f, .retrieved .configured .compiled .installed, \
1520		rm -f $(LZ4_OBJDIR)/$(f);)
1521
1522lz4-clean:
1523	-(cd $(LZ4_SRCDIR) && env MAKEFLAGS= $(MAKE) clean)
1524
1525# fetch distfile for lz4
1526$(DISTDIR)/$(LZ4_DIST):
1527	cd $(DISTDIR) && $(FETCH_CMD) -O $(LZ4_DIST) $(LZ4_URL)
1528
1529# retrieve lz4
1530$(LZ4_OBJDIR)/.retrieved: $(DISTDIR)/$(LZ4_DIST)
1531	$(call do_check_sha256,$(LZ4_DIST))
1532	[ -d $(LZ4_OBJDIR) ] || mkdir -p $(LZ4_OBJDIR)
1533	tar -C $(SRCDIR) -zxf $(DISTDIR)/$(LZ4_DIST)
1534	touch $@
1535
1536# configure lz4
1537$(LZ4_OBJDIR)/.configured: $(LZ4_OBJDIR)/.retrieved
1538	touch $@
1539
1540# compile lz4
1541$(LZ4_OBJDIR)/.compiled: $(LZ4_OBJDIR)/.configured
1542	(cd $(LZ4_SRCDIR)/lib && \
1543		env MAKEFLAGS= $(MAKE) CC=$(CC) CXX=$(CXX) \
1544			-j${MAKE_JOBS} PREFIX=$(PREFIX)/lz4)
1545	touch $@
1546
1547# install lz4
1548$(LZ4_OBJDIR)/.installed: $(LZ4_OBJDIR)/.compiled
1549	mkdir -p $(PREFIX)/lz4/lib
1550	(cd $(LZ4_SRCDIR)/lib && \
1551		env MAKEFLAGS= $(MAKE) PREFIX=$(PREFIX)/lz4 install)
1552	touch $@
1553
1554#######################################################################
1555# svn
1556#######################################################################
1557
1558.PHONY: svn-configure svn-compile svn-install svn-bindings-compile \
1559	svn-bindings-install svn-bindings-reset svn-clean
1560
1561svn-install-all: svn-install svn-bindings-install
1562
1563svn-retrieve:	$(SVN_OBJDIR)/.retrieved
1564svn-configure:	$(SVN_OBJDIR)/.configured
1565svn-compile:	$(SVN_OBJDIR)/.compiled
1566svn-bindings-compile:	$(SVN_OBJDIR)/.bindings-compiled
1567svn-install:	$(SVN_OBJDIR)/.installed
1568svn-bindings-install:	$(SVN_OBJDIR)/.bindings-installed
1569svn-bindings-reset:
1570	$(foreach f, .bindings-compiled .bindings-installed, \
1571		rm -f $(SVN_OBJDIR)/$(f);)
1572svn-reset: svn-bindings-reset
1573	$(foreach f, .retrieved .configured .compiled .installed \
1574	        .bindings-compiled .bindings-installed, \
1575		rm -f $(SVN_OBJDIR)/$(f);)
1576
1577svn-clean:
1578	-(cd $(svn_builddir) && env MAKEFLAGS= make distclean)
1579
1580# retrieve svn if not present yet
1581$(SVN_OBJDIR)/.retrieved:
1582	[ -d $(SVN_OBJDIR) ] || mkdir -p $(SVN_OBJDIR)
1583	if [ "$(TAG)" != "none" ]; then \
1584		branchdir="tags/$(TAG)"; \
1585		co="export"; \
1586	elif [ $(BRANCH) != trunk ]; then \
1587		branchdir="branches/$(BRANCH)"; \
1588		co="co"; \
1589	else \
1590		branchdir="$(BRANCH)"; \
1591		co="co"; \
1592	fi; \
1593	if [ ! -d $(SVN_WC) ] && [ ! -h $(SVN_WC) ]; then \
1594		svn $${co} $(SUBVERSION_REPOS_URL)/$${branchdir} \
1595			$(SVN_WC); \
1596	fi
1597	touch $@
1598
1599ifeq ($(BRANCH_MAJOR),1.7)
1600BDB_FLAG=db.h:$(PREFIX)/bdb/include:$(PREFIX)/bdb/lib:db-$(BDB_MAJOR_VER)
1601SERF_FLAG=--with-serf="$(PREFIX)/serf"
1602SERF_LDFLAG=-Wl,-rpath,$(PREFIX)/serf/lib -Wl,-rpath,$(PREFIX)/bdb/lib
1603MOD_DAV_SVN=modules/svn-$(WC)/mod_dav_svn.so
1604MOD_AUTHZ_SVN=modules/svn-$(WC)/mod_authz_svn.so
1605MOD_DONTDOTHAT=modules/svn-$(WC)/mod_dontdothat.so
1606LIBMAGIC_FLAG=--with-libmagic=$(PREFIX)/libmagic
1607NEON_FLAG=--with-neon="$(PREFIX)/neon"
1608JAVAHL_CHECK_TARGET=check-javahl
1609else ifeq ($(BRANCH_MAJOR),1.6)
1610BDB_FLAG=db.h:$(PREFIX)/bdb/include:$(PREFIX)/bdb/lib:db-$(BDB_MAJOR_VER)
1611SERF_FLAG=--with-serf="$(PREFIX)/serf"
1612SERF_LDFLAG=-Wl,-rpath,$(PREFIX)/serf/lib -Wl,-rpath,$(PREFIX)/bdb/lib
1613MOD_DAV_SVN=modules/svn-$(WC)/mod_dav_svn.so
1614MOD_AUTHZ_SVN=modules/svn-$(WC)/mod_authz_svn.so
1615MOD_DONTDOTHAT=modules/svn-$(WC)/mod_dontdothat.so
1616W_NO_SYSTEM_HEADERS=-Wno-system-headers
1617NEON_FLAG=--with-neon="$(PREFIX)/neon"
1618JAVAHL_CHECK_TARGET=check-javahl
1619else ifeq ($(BRANCH_MAJOR),1.5)
1620BDB_FLAG=$(PREFIX)/bdb
1621SERF_FLAG=--with-serf="$(PREFIX)/serf-old"
1622MOD_DAV_SVN=modules/mod_dav_svn.so
1623MOD_AUTHZ_SVN=modules/mod_authz_svn.so
1624MOD_DONTDOTHAT=modules/mod_dontdothat.so
1625DISABLE_NEON_VERSION_CHECK=--disable-neon-version-check
1626W_NO_SYSTEM_HEADERS=-Wno-system-headers
1627NEON_FLAG=--with-neon="$(PREFIX)/neon"
1628JAVAHL_CHECK_TARGET=check-javahl
1629else ifeq ($(BRANCH_MAJOR), $(filter $(BRANCH_MAJOR), 1.8 1.9))
1630BDB_FLAG=db.h:$(PREFIX)/bdb/include:$(PREFIX)/bdb/lib:db-$(BDB_MAJOR_VER)
1631SERF_FLAG=--with-serf="$(PREFIX)/serf"
1632# serf >= 1.3.0 is built with scons and no longer sets up rpath linker flags,
1633# so we have to do that ourselves :(
1634SERF_LDFLAG=-Wl,-rpath,$(PREFIX)/serf/lib -Wl,-rpath,$(PREFIX)/bdb/lib
1635MOD_DAV_SVN=modules/svn-$(WC)/mod_dav_svn.so
1636MOD_AUTHZ_SVN=modules/svn-$(WC)/mod_authz_svn.so
1637MOD_DONTDOTHAT=modules/svn-$(WC)/mod_dontdothat.so
1638LIBMAGIC_FLAG=--with-libmagic=$(PREFIX)/libmagic
1639JAVAHL_CHECK_TARGET=check-all-javahl
1640else # 1.10
1641BDB_FLAG=db.h:$(PREFIX)/bdb/include:$(PREFIX)/bdb/lib:db-$(BDB_MAJOR_VER)
1642SERF_FLAG=--with-serf="$(PREFIX)/serf"
1643# serf >= 1.3.0 is built with scons and no longer sets up rpath linker flags,
1644# so we have to do that ourselves :(
1645SERF_LDFLAG=-Wl,-rpath,$(PREFIX)/serf/lib -Wl,-rpath,$(PREFIX)/bdb/lib
1646LZ4_LDFLAG=-Wl,-rpath,$(PREFIX)/lz4/lib
1647MOD_DAV_SVN=modules/svn-$(WC)/mod_dav_svn.so
1648MOD_AUTHZ_SVN=modules/svn-$(WC)/mod_authz_svn.so
1649MOD_DONTDOTHAT=modules/svn-$(WC)/mod_dontdothat.so
1650LIBMAGIC_FLAG=--with-libmagic=$(PREFIX)/libmagic
1651JAVAHL_CHECK_TARGET=check-all-javahl
1652LZ4_FLAG=--with-lz4=$(PREFIX)/lz4
1653UTF8PROC_FLAG=--with-utf8proc=internal
1654endif
1655
1656ifeq ($(ENABLE_JAVA_BINDINGS),yes)
1657	JAVAHL_FLAG=--enable-javahl=yes --with-jdk --with-jikes=no \
1658		--with-junit=$(DISTDIR)/$(JUNIT_DIST)
1659else
1660	JAVAHL_FLAG=--with-jdk=no
1661endif
1662
1663ifdef PROFILE
1664SVN_STATIC_FLAG=--enable-all-static
1665else
1666SVN_STATIC_FLAG=--disable-static
1667SVN_WITH_HTTPD=--with-apxs="$(PREFIX)/httpd/bin/apxs" \
1668	--with-apache-libexecdir="$(PREFIX)/httpd/modules/svn-$(WC)"
1669SVN_WITH_SASL=--with-sasl="$(PREFIX)/cyrus-sasl"
1670endif
1671
1672# On OpenBSD, MExtUtils -e ldopts outputs -L/usr/local/lib, which can
1673# cause us to link Perl bindings against the wrong set of SVN libraries.
1674# As a workaround, we patch the configure script after it has been generated.
1675ifeq ($(UNAME),OpenBSD)
1676SWIG_PL_INCLUDES_HACK= sed -i 's^\($$PERL -MExtUtils::Embed -e ccopts\)^\1 | sed -e s@-I/usr/local/include@@^' $(svn_builddir)/configure
1677SWIG_PL_LINK_HACK= sed -i 's^\($$PERL -MExtUtils::Embed -e ldopts\)^\1 | sed -e s@-L/usr/local/lib@@^' $(svn_builddir)/configure
1678else
1679SWIG_PL_INCLUDES_HACK=true
1680SWIG_PL_LINK_HACK=true
1681endif
1682
1683$(SVN_OBJDIR)/.configured: $(SVN_OBJDIR)/.retrieved $(DISTDIR)/$(JUNIT_DIST) \
1684	$(APR_OBJDIR)/.installed $(APR_UTIL_OBJDIR)/.installed \
1685	$(BDB_OBJDIR)/.installed $(SQLITE_OBJDIR)/.installed \
1686	$(HTTPD_OBJDIR)/.installed $(CYRUS_SASL_OBJDIR)/.installed \
1687	$(LIBMAGIC_OBJDIR)/.installed $(NEON_OBJDIR)/.installed \
1688	$(SERF_OBJDIR)/.installed $(SERF_OLD_OBJDIR)/.installed \
1689	$(RUBY_OBJDIR)/.installed $(PYTHON_OBJDIR)/.installed
1690	cd $(SVN_SRCDIR) && ./autogen.sh
1691	$(SWIG_PL_INCLUDES_HACK)
1692	$(SWIG_PL_LINK_HACK)
1693	cd $(svn_builddir) && \
1694		env LDFLAGS="-L$(PREFIX)/neon/lib -L$(PREFIX)/apr/lib $(SERF_LDFLAG) $(LZ4_LDFLAG) -L$(PREFIX)/gettext/lib -L$(PREFIX)/iconv/lib" \
1695			CC=$(CC) CXX=$(CXX) \
1696			CFLAGS="-I$(PREFIX)/gettext/include -DAPR_POOL_DEBUG" \
1697			CXXFLAGS="-I$(PREFIX)/gettext/include -DAPR_POOL_DEBUG" \
1698			LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$$LD_LIBRARY_PATH" \
1699			PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) \
1700			PYTHON=$(PREFIX)/python/bin/python3 \
1701			GREP="`which grep`" \
1702			PATH=$(PREFIX)/ruby/bin:$(PREFIX)/python/bin:$(PREFIX)/gettext/bin:$$PATH \
1703			$(SVN_SRCDIR)/configure \
1704			--enable-maintainer-mode \
1705			--prefix="$(SVN_PREFIX)" \
1706			--with-apr="$(PREFIX)/apr" \
1707			--with-apr-util="$(PREFIX)/apr" \
1708			$(NEON_FLAG) \
1709			$(SVN_WITH_HTTPD) \
1710			$(SVN_WITH_SASL) \
1711			$(SERF_FLAG) \
1712			--with-sqlite="$(PREFIX)/sqlite" \
1713			--with-zlib="/usr" \
1714			--without-gnome-keyring \
1715			--with-berkeley-db="$(BDB_FLAG)" \
1716			--with-ruby-sitedir="$(SVN_PREFIX)/lib/ruby/site_ruby" \
1717			--with-py3c="$(SRCDIR)/py3c-${PY3C_VER}" \
1718			--disable-mod-activation \
1719			$(JAVAHL_FLAG) \
1720			$(LIBMAGIC_FLAG) \
1721			$(LZ4_FLAG) \
1722			$(UTF8PROC_FLAG) \
1723			$(SVN_STATIC_FLAG) \
1724			$(DISABLE_NEON_VERSION_CHECK)
1725	touch $@
1726
1727# compile svn
1728$(SVN_OBJDIR)/.compiled: $(SVN_OBJDIR)/.configured
1729	cd $(svn_builddir) \
1730		&& env MAKEFLAGS= make -j${MAKE_JOBS} EXTRA_CFLAGS="$(PROFILE_CFLAGS) $(W_NO_SYSTEM_HEADERS)"
1731	touch $@
1732
1733# install svn
1734$(SVN_OBJDIR)/.installed: $(SVN_OBJDIR)/.compiled
1735	cd $(svn_builddir) \
1736		&& env MAKEFLAGS= make install install-tools
1737	touch $@
1738
1739# SWIG 1.x and 2.x are not compatible. If SWIG 2.x is used to generated .swg
1740# files and 1.x is used to build the bindings, the Python bindings fail to
1741# load with errors such as "undefined symbol 'SWIG_Python_str_AsChar'".
1742# So clean any pre-generated .swg files to make sure everything is done
1743# by the same version of SWIG.
1744$(SVN_OBJDIR)/.pre-generated-swig-cleaned:
1745	-cd $(svn_builddir) \
1746		&& env MAKEFLAGS= make clean-swig
1747	touch $@
1748
1749
1750# On OpenBSD, Perl's LDDLFLAGS include -L/usr/local/lib, which can cause
1751# us to link Perl bindings against the wrong set of SVN libraries.
1752# We manually fix up the generated Makefile.PL to work around this issue.
1753ifeq ($(UNAME),OpenBSD)
1754MAKEFILE_PL_LDDLFLAGS_HACK= sed -i 's@^WriteMakefile@$$config{LDDLFLAGS} =~ s+-L/usr/local/lib++; WriteMakefile@' \
1755			$(SVN_SRCDIR)/subversion/bindings/swig/perl/native/Makefile.PL
1756else
1757MAKEFILE_PL_LDDLFLAGS_HACK=true
1758endif
1759
1760$(SVN_OBJDIR)/.bindings-compiled: $(SVN_OBJDIR)/.installed $(SVN_OBJDIR)/.pre-generated-swig-cleaned
1761	cd $(svn_builddir) \
1762		&& env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
1763			env MAKEFLAGS= make -j${MAKE_JOBS} swig-py
1764	cd $(svn_builddir) && \
1765		env PATH=$(PREFIX)/ruby/bin:$$PATH \
1766		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) env MAKEFLAGS= make -j${MAKE_JOBS} swig-rb
1767	if [ $(ENABLE_PERL_BINDINGS) = yes ]; then \
1768		cd $(svn_builddir) && make $(SVN_SRCDIR)/subversion/bindings/swig/perl/native/Makefile.PL; \
1769		$(MAKEFILE_PL_LDDLFLAGS_HACK); \
1770		cd $(svn_builddir) \
1771			&& env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
1772				env MAKEFLAGS= make -j${MAKE_JOBS} swig-pl; \
1773	fi
1774	if [ $(ENABLE_JAVA_BINDINGS) = yes ]; then \
1775		cd $(svn_builddir) \
1776			&& env MAKEFLAGS= make javahl; \
1777	fi
1778	touch $@
1779
1780$(SVN_OBJDIR)/.bindings-installed: $(SVN_OBJDIR)/.bindings-compiled
1781	cd $(svn_builddir) \
1782	  && env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
1783		env MAKEFLAGS= make install-swig-py
1784	cd $(svn_builddir) && \
1785		env PATH=$(PREFIX)/ruby/bin:$$PATH \
1786		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) MAKEFLAGS= make install-swig-rb
1787	if [ $(ENABLE_PERL_BINDINGS) = yes ]; then \
1788		cd $(svn_builddir) \
1789			&& env MAKEFLAGS= LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
1790				make install-swig-pl-lib; \
1791		cd subversion/bindings/swig/perl/native \
1792			&& perl Makefile.PL PREFIX="$(SVN_PREFIX)" \
1793			&& env MAKEFLAGS= LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
1794				make install; \
1795	fi
1796	if [ $(ENABLE_JAVA_BINDINGS) = yes ]; then \
1797		cd $(svn_builddir) \
1798			&& env MAKEFLAGS= make install-javahl; \
1799	fi
1800	touch $@
1801
1802# run svn regression tests
1803HTTPD_CHECK_CONF=$(PREFIX)/httpd/conf/httpd-svn-check-$(WC).conf
1804HTTPD_PROXY_CONF=$(PREFIX)/httpd/conf/httpd-svn-proxy-$(WC).conf
1805HTTPD_CHECK_USERS=$(PREFIX)/httpd/conf/httpd-svn-check-users
1806HTTPD_CHECK_GROUPS=$(PREFIX)/httpd/conf/httpd-svn-check-groups
1807HTTPD_CHECK_PORT=8081
1808HTTPD_PROXY_PORT=8082
1809MOD_DONTDOTHAT_CONF=$(PREFIX)/httpd/conf/dontdothat
1810
1811$(MOD_DONTDOTHAT_CONF):
1812	mkdir -p $(dir $@)
1813	echo > $@.tmp '[recursive-actions]'
1814	echo >>$@.tmp '/ = deny'
1815	mv -f $@.tmp $@
1816
1817$(HTTPD_CHECK_GROUPS):
1818	mkdir -p $(dir $@)
1819	printf "random: jrandom\nconstant: jconstant\n" > $@
1820
1821$(HTTPD_CHECK_CONF): $(MOD_DONTDOTHAT_CONF) $(HTTPD_CHECK_GROUPS)
1822	mkdir -p $(dir $@)
1823	$(PREFIX)/httpd/bin/htpasswd -bc $(HTTPD_CHECK_USERS).tmp jrandom rayjandom
1824	$(PREFIX)/httpd/bin/htpasswd -b $(HTTPD_CHECK_USERS).tmp jconstant rayjandom
1825	$(PREFIX)/httpd/bin/htpasswd -b $(HTTPD_CHECK_USERS).tmp __dumpster__ __loadster__
1826	$(PREFIX)/httpd/bin/htpasswd -b $(HTTPD_CHECK_USERS).tmp JRANDOM rayjandom
1827	$(PREFIX)/httpd/bin/htpasswd -b $(HTTPD_CHECK_USERS).tmp JCONSTANT rayjandom
1828	mv -f $(HTTPD_CHECK_USERS).tmp $(HTTPD_CHECK_USERS)
1829	echo > $@.tmp '# httpd config for make check'
1830	echo >>$@.tmp 'ServerRoot "$(PREFIX)/httpd"'
1831	echo >>$@.tmp 'Listen localhost:$(HTTPD_CHECK_PORT)'
1832	echo >>$@.tmp 'LoadModule unixd_module modules/mod_unixd.so'
1833	echo >>$@.tmp 'LoadModule alias_module modules/mod_alias.so'
1834	echo >>$@.tmp 'LoadModule access_compat_module modules/mod_access_compat.so'
1835	echo >>$@.tmp 'LoadModule authn_core_module modules/mod_authn_core.so'
1836	echo >>$@.tmp 'LoadModule authn_file_module modules/mod_authn_file.so'
1837	echo >>$@.tmp 'LoadModule authz_core_module modules/mod_authz_core.so'
1838	echo >>$@.tmp 'LoadModule authz_user_module modules/mod_authz_user.so'
1839	echo >>$@.tmp 'LoadModule authz_groupfile_module modules/mod_authz_groupfile.so'
1840	echo >>$@.tmp 'LoadModule auth_basic_module modules/mod_auth_basic.so'
1841	echo >>$@.tmp 'LoadModule dav_module modules/mod_dav.so'
1842	echo >>$@.tmp 'LoadModule dav_svn_module $(MOD_DAV_SVN)'
1843	echo >>$@.tmp 'LoadModule authz_svn_module $(MOD_AUTHZ_SVN)'
1844	echo >>$@.tmp 'LoadModule dontdothat_module $(MOD_DONTDOTHAT)'
1845	echo >>$@.tmp 'DocumentRoot "$(PREFIX)/httpd/htdocs"'
1846	echo >>$@.tmp '# These two Locations are used for "make check"'
1847	echo >>$@.tmp '<Directory />'
1848	echo >>$@.tmp '    Options FollowSymLinks'
1849	echo >>$@.tmp '    AllowOverride None'
1850	echo >>$@.tmp '    Require all granted'
1851	echo >>$@.tmp '</Directory>'
1852	echo >>$@.tmp '<Location /svn-test-work/repositories>'
1853	echo >>$@.tmp '    DAV svn'
1854	echo >>$@.tmp '    SVNParentPath $(SVN_WC)/subversion/tests/cmdline/svn-test-work/repositories'
1855	echo >>$@.tmp '    AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1856	echo >>$@.tmp '    AuthType Basic'
1857	echo >>$@.tmp '    AuthName "Subversion Repository"'
1858	echo >>$@.tmp '    AuthUserFile $(HTTPD_CHECK_USERS)'
1859	echo >>$@.tmp '    Require valid-user'
1860ifeq ($(USE_HTTPV1),yes)
1861	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
1862endif
1863ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1864	echo >>$@.tmp '    SVNPathAuthz short_circuit'
1865endif
1866	echo >>$@.tmp '</Location>'
1867	echo >>$@.tmp '<Location /svn-test-work/local_tmp/repos>'
1868	echo >>$@.tmp '    DAV svn'
1869	echo >>$@.tmp '    SVNPath $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp/repos'
1870	echo >>$@.tmp '    AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1871	echo >>$@.tmp '    AuthType Basic'
1872	echo >>$@.tmp '    AuthName "Subversion Repository"'
1873	echo >>$@.tmp '    AuthUserFile $(HTTPD_CHECK_USERS)'
1874	echo >>$@.tmp '    Require valid-user'
1875ifeq ($(USE_HTTPV1),yes)
1876	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
1877endif
1878ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1879	echo >>$@.tmp '    SVNPathAuthz short_circuit'
1880endif
1881	echo >>$@.tmp '</Location>'
1882	echo >>$@.tmp '<Location /svn-test-work/local_tmp/trojan>'
1883	echo >>$@.tmp '    DAV svn'
1884	echo >>$@.tmp '    SVNPath $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp/trojan'
1885	echo >>$@.tmp '    AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1886	echo >>$@.tmp '    AuthType Basic'
1887	echo >>$@.tmp '    AuthName "Subversion Repository"'
1888	echo >>$@.tmp '    AuthUserFile $(HTTPD_CHECK_USERS)'
1889	echo >>$@.tmp '    Require valid-user'
1890ifeq ($(USE_HTTPV1),yes)
1891	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
1892endif
1893ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1894	echo >>$@.tmp '    SVNPathAuthz short_circuit'
1895endif
1896	echo >>$@.tmp '</Location>'
1897	echo >>$@.tmp '# This Location lets you access repositories dropped in /tmp/'
1898	echo >>$@.tmp '<Location /svn>'
1899	echo >>$@.tmp '    DAV svn'
1900	echo >>$@.tmp '    SVNParentPath /tmp'
1901	echo >>$@.tmp '    Require all granted'
1902	echo >>$@.tmp '    #AuthType Basic'
1903	echo >>$@.tmp '    #AuthName "Subversion Repository"'
1904	echo >>$@.tmp '    #AuthUserFile $(HTTPD_CHECK_USERS)'
1905	echo >>$@.tmp '    #Require valid-user'
1906ifeq ($(USE_HTTPV1),yes)
1907	echo >> $@.tmp '   SVNAdvertiseV2Protocol off'
1908endif
1909ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1910	echo >> $@.tmp '   SVNPathAuthz short_circuit'
1911endif
1912	echo >>$@.tmp '</Location>'
1913	echo >>$@.tmp '# Location for tests using mod_dontdothat'
1914	echo >>$@.tmp '<Location /ddt-test-work/repositories>'
1915	echo >> $@.tmp 'DAV               svn'
1916	echo >> $@.tmp 'SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/repositories'
1917	echo >> $@.tmp 'AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1918	echo >> $@.tmp 'AuthType          Basic'
1919	echo >> $@.tmp 'AuthName          "Subversion Repository"'
1920	echo >> $@.tmp 'AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1921	echo >> $@.tmp 'AuthUserFile $(HTTPD_CHECK_USERS)'
1922	echo >> $@.tmp 'Require           valid-user'
1923ifeq ($(USE_HTTPV1),yes)
1924	echo >> $@.tmp '    SVNAdvertiseV2Protocol off'
1925endif
1926	echo >> $@.tmp 'DontDoThatConfigFile "$(MOD_DONTDOTHAT_CONF)"'
1927	echo >> $@.tmp '</Location>'
1928
1929	echo >>$@.tmp '# Several locations for mod_authz_svn test follow'
1930	echo >>$@.tmp '<Location /authz-test-work/anon>'
1931	echo >>$@.tmp '  DAV               svn'
1932	echo >>$@.tmp '  SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
1933	echo >>$@.tmp '  AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1934ifeq ($(USE_HTTPV1),yes)
1935       echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
1936endif
1937	echo >>$@.tmp '  SVNListParentPath On'
1938	echo >>$@.tmp '  <IfModule mod_authz_core.c>'
1939	echo >>$@.tmp '    Require all granted'
1940	echo >>$@.tmp '  </IfModule>'
1941	echo >>$@.tmp '  <IfModule !mod_authz_core.c>'
1942	echo >>$@.tmp '    Requite all granted'
1943	echo >>$@.tmp '  </IfModule>'
1944ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1945	echo >>$@.tmp '    SVNPathAuthz short_circuit'
1946endif
1947	echo >>$@.tmp '</Location>'
1948	echo >>$@.tmp '<Location /authz-test-work/mixed>'
1949	echo >>$@.tmp '  DAV               svn'
1950	echo >>$@.tmp '  SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
1951	echo >>$@.tmp '  AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1952ifeq ($(USE_HTTPV1),yes)
1953	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
1954endif
1955	echo >>$@.tmp '  SVNListParentPath On'
1956	echo >>$@.tmp '  AuthType          Basic'
1957	echo >>$@.tmp '  AuthName          "Subversion Repository"'
1958	echo >>$@.tmp '  AuthUserFile      $(HTTPD_CHECK_USERS)'
1959	echo >>$@.tmp '  Require           valid-user'
1960	echo >>$@.tmp '  Satisfy           Any'
1961ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1962	echo >>$@.tmp '    SVNPathAuthz short_circuit'
1963endif
1964	echo >>$@.tmp '</Location>'
1965	echo >>$@.tmp '<Location /authz-test-work/mixed-noauthwhenanon>'
1966	echo >>$@.tmp '  DAV               svn'
1967	echo >>$@.tmp '  SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
1968	echo >>$@.tmp '  AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1969ifeq ($(USE_HTTPV1),yes)
1970	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
1971endif
1972	echo >>$@.tmp '  SVNListParentPath On'
1973	echo >>$@.tmp '  AuthType          Basic'
1974	echo >>$@.tmp '  AuthName          "Subversion Repository"'
1975	echo >>$@.tmp '  AuthUserFile      $(HTTPD_CHECK_USERS)'
1976	echo >>$@.tmp '  Require           valid-user'
1977	echo >>$@.tmp '  AuthzSVNNoAuthWhenAnonymousAllowed On'
1978	echo >>$@.tmp '  SVNPathAuthz On'
1979ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1980	echo >>$@.tmp '    SVNPathAuthz short_circuit'
1981endif
1982	echo >>$@.tmp '</Location>'
1983	echo >>$@.tmp '<Location /authz-test-work/authn>'
1984	echo >>$@.tmp '  DAV               svn'
1985	echo >>$@.tmp '  SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
1986	echo >>$@.tmp '  AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
1987ifeq ($(USE_HTTPV1),yes)
1988	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
1989endif
1990	echo >>$@.tmp '  SVNListParentPath On'
1991	echo >>$@.tmp '  AuthType          Basic'
1992	echo >>$@.tmp '  AuthName          "Subversion Repository"'
1993	echo >>$@.tmp '  AuthUserFile      $(HTTPD_CHECK_USERS)'
1994	echo >>$@.tmp '  Require           valid-user'
1995ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
1996	echo >>$@.tmp '    SVNPathAuthz short_circuit'
1997endif
1998	echo >>$@.tmp '</Location>'
1999	echo >>$@.tmp '<Location /authz-test-work/authn-anonoff>'
2000	echo >>$@.tmp '  DAV               svn'
2001	echo >>$@.tmp '  SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
2002	echo >>$@.tmp '  AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
2003ifeq ($(USE_HTTPV1),yes)
2004	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
2005endif
2006	echo >>$@.tmp '  SVNListParentPath On'
2007	echo >>$@.tmp '  AuthType          Basic'
2008	echo >>$@.tmp '  AuthName          "Subversion Repository"'
2009	echo >>$@.tmp '  AuthUserFile      $(HTTPD_CHECK_USERS)'
2010	echo >>$@.tmp '  Require           valid-user'
2011	echo >>$@.tmp '  AuthzSVNAnonymous Off'
2012	echo >>$@.tmp '  SVNPathAuthz On'
2013	echo >>$@.tmp '</Location>'
2014	echo >>$@.tmp '<Location /authz-test-work/authn-lcuser>'
2015	echo >>$@.tmp '  DAV               svn'
2016	echo >>$@.tmp '  SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
2017	echo >>$@.tmp '  AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
2018ifeq ($(USE_HTTPV1),yes)
2019	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
2020endif
2021	echo >>$@.tmp '  SVNListParentPath On'
2022	echo >>$@.tmp '  AuthType          Basic'
2023	echo >>$@.tmp '  AuthName          "Subversion Repository"'
2024	echo >>$@.tmp '  AuthUserFile      $(HTTPD_CHECK_USERS)'
2025	echo >>$@.tmp '  Require           valid-user'
2026	echo >>$@.tmp '  AuthzForceUsernameCase Lower'
2027ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
2028	echo >>$@.tmp '    SVNPathAuthz short_circuit'
2029endif
2030	echo >>$@.tmp '</Location>'
2031	echo >>$@.tmp '<Location /authz-test-work/authn-group>'
2032	echo >>$@.tmp '  DAV               svn'
2033	echo >>$@.tmp '  SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
2034	echo >>$@.tmp '  AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
2035ifeq ($(USE_HTTPV1),yes)
2036	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
2037endif
2038	echo >>$@.tmp '  SVNListParentPath On'
2039	echo >>$@.tmp '  AuthType          Basic'
2040	echo >>$@.tmp '  AuthName          "Subversion Repository"'
2041	echo >>$@.tmp '  AuthUserFile      $(HTTPD_CHECK_USERS)'
2042	echo >>$@.tmp '  AuthGroupFile     $(HTTPD_CHECK_GROUPS)'
2043	echo >>$@.tmp '  Require           group random'
2044	echo >>$@.tmp '  AuthzSVNAuthoritative Off'
2045	echo >>$@.tmp '  SVNPathAuthz On'
2046	echo >>$@.tmp '</Location>'
2047	echo >>$@.tmp '<IfModule mod_authz_core.c>'
2048	echo >>$@.tmp '  <Location /authz-test-work/sallrany>'
2049	echo >>$@.tmp '    DAV               svn'
2050	echo >>$@.tmp '    SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
2051	echo >>$@.tmp '    AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
2052ifeq ($(USE_HTTPV1),yes)
2053	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
2054endif
2055	echo >>$@.tmp '    SVNListParentPath On'
2056	echo >>$@.tmp '    AuthType          Basic'
2057	echo >>$@.tmp '    AuthName          "Subversion Repository"'
2058	echo >>$@.tmp '    AuthUserFile      $(HTTPD_CHECK_USERS)'
2059	echo >>$@.tmp '    AuthzSendForbiddenOnFailure On'
2060	echo >>$@.tmp '    Satisfy All'
2061	echo >>$@.tmp '    <RequireAny>'
2062	echo >>$@.tmp '      Require valid-user'
2063	echo >>$@.tmp '      Require expr req("ALLOW") == "1"'
2064	echo >>$@.tmp '    </RequireAny>'
2065ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
2066	echo >>$@.tmp '    SVNPathAuthz short_circuit'
2067endif
2068	echo >>$@.tmp '  </Location>'
2069	echo >>$@.tmp '  <Location /authz-test-work/sallrall>'
2070	echo >>$@.tmp '    DAV               svn'
2071	echo >>$@.tmp '    SVNParentPath     $(SVN_WC)/subversion/tests/cmdline/svn-test-work/local_tmp'
2072	echo >>$@.tmp '    AuthzSVNAccessFile $(SVN_WC)/subversion/tests/cmdline/svn-test-work/authz'
2073ifeq ($(USE_HTTPV1),yes)
2074	echo >>$@.tmp '    SVNAdvertiseV2Protocol off'
2075endif
2076	echo >>$@.tmp '    SVNListParentPath On'
2077	echo >>$@.tmp '    AuthType          Basic'
2078	echo >>$@.tmp '    AuthName          "Subversion Repository"'
2079	echo >>$@.tmp '    AuthUserFile      $(HTTPD_CHECK_USERS)'
2080	echo >>$@.tmp '    AuthzSendForbiddenOnFailure On'
2081	echo >>$@.tmp '    Satisfy All'
2082	echo >>$@.tmp '    <RequireAll>'
2083	echo >>$@.tmp '      Require valid-user'
2084	echo >>$@.tmp '      Require expr req("ALLOW") == "1"'
2085	echo >>$@.tmp '    </RequireAll>'
2086ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
2087	echo >>$@.tmp '    SVNPathAuthz short_circuit'
2088endif
2089	echo >>$@.tmp '  </Location>'
2090	echo >>$@.tmp '</IfModule>'
2091	echo >>$@.tmp 'RedirectMatch permanent ^/svn-test-work/repositories/REDIRECT-PERM-(.*)$$ /svn-test-work/repositories/$$1'
2092	echo >>$@.tmp 'RedirectMatch ^/svn-test-work/repositories/REDIRECT-TEMP-(.*)$$ /svn-test-work/repositories/$$1'
2093	echo >>$@.tmp 'IncludeOptional "conf/$(SVN_REL_WC)*-custom.conf"'
2094	echo >> $@.tmp '#SVNInMemoryCacheSize 0'
2095	echo >> $@.tmp '#SVNCacheTextDeltas Off'
2096	echo >> $@.tmp '#SVNCacheRevProps Off'
2097	mv -f $@.tmp $@
2098
2099$(HTTPD_PROXY_CONF): $(HTTPD_CHECK_CONF)
2100	mkdir -p $(dir $@)
2101	echo > $@.tmp '# httpd config for a write-through proxy'
2102	echo >>$@.tmp 'ServerRoot "$(PREFIX)/httpd"'
2103	echo >>$@.tmp 'Listen localhost:$(HTTPD_PROXY_PORT)'
2104	echo >>$@.tmp 'LoadModule unixd_module modules/mod_unixd.so'
2105	echo >>$@.tmp 'LoadModule alias_module modules/mod_alias.so'
2106	echo >>$@.tmp 'LoadModule access_compat_module modules/mod_access_compat.so'
2107	echo >>$@.tmp 'LoadModule authn_core_module modules/mod_authn_core.so'
2108	echo >>$@.tmp 'LoadModule authn_file_module modules/mod_authn_file.so'
2109	echo >>$@.tmp 'LoadModule authz_core_module modules/mod_authz_core.so'
2110	echo >>$@.tmp 'LoadModule authz_user_module modules/mod_authz_user.so'
2111	echo >>$@.tmp 'LoadModule authz_groupfile_module modules/mod_authz_groupfile.so'
2112	echo >>$@.tmp 'LoadModule auth_basic_module modules/mod_auth_basic.so'
2113	echo >>$@.tmp 'LoadModule dav_module modules/mod_dav.so'
2114	echo >>$@.tmp 'LoadModule dav_svn_module $(MOD_DAV_SVN)'
2115	echo >>$@.tmp 'LoadModule authz_svn_module $(MOD_AUTHZ_SVN)'
2116	echo >>$@.tmp 'LoadModule dontdothat_module $(MOD_DONTDOTHAT)'
2117	echo >>$@.tmp 'DocumentRoot "$(PREFIX)/httpd/htdocs"'
2118	echo >>$@.tmp '# This Location lets you access repositories dropped in /tmp/svn-$(BRANCH)-proxy'
2119	echo >>$@.tmp '<Location /svn>'
2120	echo >>$@.tmp '    DAV svn'
2121	echo >>$@.tmp '    SVNParentPath /tmp/svn-$(BRANCH)-proxy'
2122	echo >>$@.tmp '    SVNMasterURI http://localhost:$(HTTPD_CHECK_PORT)/svn/'
2123	echo >>$@.tmp '    Requite all granted'
2124	echo >>$@.tmp '    #AuthType Basic'
2125	echo >>$@.tmp '    #AuthName "Subversion Repository"'
2126	echo >>$@.tmp '    #AuthUserFile $(HTTPD_CHECK_USERS)'
2127	echo >>$@.tmp '    #Require valid-user'
2128ifeq ($(USE_HTTPV1),yes)
2129	echo >> $@.tmp '   SVNAdvertiseV2Protocol off'
2130endif
2131ifeq ($(USE_AUTHZ_SHORT_CIRCUIT),yes)
2132	echo >> $@.tmp '   SVNPathAuthz short_circuit'
2133endif
2134	echo >>$@.tmp '</Location>'
2135	echo >>$@.tmp '# This Location allows repositories to be synced'
2136	echo >>$@.tmp '<Location /svn-proxy-sync>'
2137	echo >>$@.tmp 'DAV svn'
2138	echo >>$@.tmp 'SVNParentPath /tmp/svn-$(BRANCH)-proxy'
2139	echo >>$@.tmp 'Require all granted'
2140	echo >>$@.tmp '</Location>'
2141	mv -f $@.tmp $@
2142
2143.PHONY: libpath
2144libpath:
2145	@echo export LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$$LD_LIBRARY_PATH" \
2146		"PYTHONPATH=$(SVN_PREFIX)/lib/svn-python"
2147#
2148# OpenBSD requires an LD_PRELOAD hack to dlopen() libraries linked to
2149# libpthread (e.g. libsvn_auth_gnome_keyring.so) into executables that
2150# aren't linked to libpthread.
2151ifeq ($(UNAME),OpenBSD)
2152LIB_PTHREAD_HACK=LD_PRELOAD=libpthread.so
2153endif
2154
2155.PHONY: start-svnserve stop-svnserve start-httpd stop-httpd
2156
2157HTTPD_CMD = env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(LIB_PTHREAD_HACK) \
2158		$(PREFIX)/httpd/bin/apachectl
2159HTTPD_LOG_ROTATE = mv $(PREFIX)/httpd/logs/error_log $(PREFIX)/httpd/logs/error_log.old
2160HTTPD_START_CMD = $(HTTPD_CMD) -f $(HTTPD_CHECK_CONF) -k start
2161HTTPD_START_CMD_PROXY = $(HTTPD_CMD) -f $(HTTPD_PROXY_CONF)
2162HTTPD_START_CMD_DEBUG = $(HTTPD_START_CMD) -X
2163HTTPD_STOP_CMD = $(HTTPD_CMD) -f $(HTTPD_CHECK_CONF) -k stop; sleep 3
2164
2165SVNSERVE_START_CMD = (test -e $(PWD)/svnserve-*.pid && \
2166			ls $(PWD)/svnserve-*.pid | while read pidfile; do \
2167				kill `cat "$$pidfile"`; sleep 3; \
2168				rm -f $$pidfile; \
2169			done); \
2170			$(SVN_PREFIX)/bin/svnserve \
2171			--listen-host 127.0.0.1 \
2172			--pid-file $(PWD)/svnserve-$(WC).pid \
2173			-d -r $(svn_builddir)/subversion/tests/cmdline
2174SVNSERVE_STOP_CMD = kill `cat $(PWD)/svnserve-$(WC).pid`; sleep 3; \
2175			rm -f $(PWD)/svnserve-$(WC).pid
2176
2177start-httpd: $(HTTPD_CHECK_CONF)
2178	-$(HTTPD_LOG_ROTATE)
2179	$(HTTPD_START_CMD)
2180	@echo "To run tests over http, run:"
2181	@echo "    make check BASE_URL=http://localhost:$(HTTPD_CHECK_PORT)"
2182	@echo "The URL http://localhost:$(HTTPD_CHECK_PORT)/svn/"
2183	@echo "lets you access repositories dropped into /tmp"
2184
2185start-httpd-debug: $(HTTPD_CHECK_CONF)
2186	$(HTTPD_START_CMD_DEBUG) &
2187	@echo "To run tests over http, run:"
2188	@echo "    make check BASE_URL=http://localhost:$(HTTPD_CHECK_PORT)"
2189	@echo "The URL http://localhost:$(HTTPD_CHECK_PORT)/svn/"
2190	@echo "lets you access repositories dropped into /tmp"
2191	@echo "Trying to attach gdb to httpd..."
2192	@sleep 1
2193	gdb $(PREFIX)/httpd/bin/httpd `cat $(PREFIX)/httpd/logs/httpd.pid`
2194
2195start-httpd-proxy: $(HTTPD_PROXY_CONF)
2196	$(HTTPD_START_CMD_PROXY)
2197	@echo "The URL http://localhost:$(HTTPD_PROXY_PORT)/svn/"
2198	@echo "lets you access repositories dropped into /tmp/svn-$(BRANCH)-proxy"
2199
2200stop-httpd: $(HTTPD_CHECK_CONF)
2201	$(HTTPD_STOP_CMD)
2202
2203stop-httpd-proxy: $(HTTPD_PROXY_CONF)
2204	pkill -f '$(PREFIX)/httpd/bin/httpd -f $(HTTPD_PROXY_CONF)'
2205
2206start-svnserve: $(SVN_OBJDIR)/.compiled
2207	$(SVNSERVE_START_CMD)
2208
2209stop-svnserve:
2210	$(SVNSERVE_STOP_CMD)
2211
2212define do_check
2213-cd $(svn_builddir) && for fs in $(SVN_CHECK_FS_BACKENDS); do \
2214    echo "Begin test: $(subst svn-check-,,$@) x $$fs"; \
2215    test -d "$(RAMDISK)/tmp" && export TMPDIR="$(RAMDISK)/tmp"; \
2216    env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(LIB_PTHREAD_HACK) \
2217        env MAKEFLAGS= make check PARALLEL=$(PARALLEL) CLEANUP=$(CLEANUP) \
2218	  EXCLUSIVE_WC_LOCKS=$(EXCLUSIVE_WC_LOCKS) \
2219	  THREADED=$(THREADED) \
2220	  SVN_BIN_DIR=$(SVN_PREFIX)/bin \
2221	  MEMCACHED_SERVER=$(MEMCACHED_SERVER) $1 FS_TYPE=$$fs; \
2222    for log in tests.log fails.log; do \
2223        test -f $$log && mv -f $$log $$log.$@-$$fs; \
2224    done; \
2225done
2226endef
2227
2228TEST_WORK=$(svn_builddir)/subversion/tests/cmdline/svn-test-work
2229svn-check-prepare-ramdisk:
2230	-rm -rf "$(TEST_WORK)"; \
2231	if [ -d "$(RAMDISK)" ] && \
2232		touch "$(RAMDISK)/$(SVN_REL_WC).writetest" && \
2233		mkdir -p "$(RAMDISK)/$(SVN_REL_WC)"; then \
2234			rm -f "$(RAMDISK)/$(SVN_REL_WC).writetest"; \
2235			ln -s "$(RAMDISK)/$(SVN_REL_WC)" "$(TEST_WORK)"; \
2236			mkdir -p "$(RAMDISK)/tmp"; \
2237	fi
2238
2239ifndef NEON_FLAG
2240svn-check-neon:
2241	@echo Neon is not supported by this build of Subversion, skipping tests
2242	@true
2243else
2244svn-check-neon: $(HTTPD_CHECK_CONF) $(SVN_OBJDIR)/.compiled $(SVN_OBJDIR)/.bindings-compiled svn-check-prepare-ramdisk
2245	$(HTTPD_START_CMD)
2246	$(call do_check,BASE_URL=http://localhost:$(HTTPD_CHECK_PORT) HTTP_LIBRARY=neon)
2247	$(HTTPD_STOP_CMD)
2248endif
2249
2250svn-check-serf: $(HTTPD_CHECK_CONF) $(SVN_OBJDIR)/.compiled $(SVN_OBJDIR)/.bindings-compiled svn-check-prepare-ramdisk
2251	$(HTTPD_START_CMD)
2252	$(call do_check,BASE_URL=http://localhost:$(HTTPD_CHECK_PORT) HTTP_LIBRARY=serf)
2253	$(HTTPD_STOP_CMD)
2254
2255svn-check-local: svn-check-prepare-ramdisk
2256	$(call do_check)
2257
2258svn-check-svn: svn-check-prepare-ramdisk
2259	$(SVNSERVE_START_CMD)
2260	$(call do_check,BASE_URL=svn://127.0.0.1)
2261	$(SVNSERVE_STOP_CMD)
2262
2263.PHONY: svn-check-swig-pl svn-check-swig-py svn-check-swig-rb svn-check-javahl
2264svn-check-bindings: svn-check-swig-pl svn-check-swig-py svn-check-swig-rb \
2265	svn-check-javahl
2266
2267RUBYLIB=$(SVN_PREFIX)/lib/ruby/site_ruby$(shell grep \
2268	^svn_cv_ruby_sitedir_archsuffix $(svn_builddir)/config.log | \
2269	cut -d'=' -f2):$(SVN_PREFIX)/lib/ruby/site_ruby$(shell \
2270	grep ^svn_cv_ruby_sitedir_libsuffix $(svn_builddir)/config.log | \
2271	cut -d'=' -f2)
2272svn-check-swig-pl:
2273	-if [ $(ENABLE_PERL_BINDINGS) = yes ]; then \
2274		(cd $(svn_builddir) && \
2275			env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
2276			$(LIB_PTHREAD_HACK) \
2277			env MAKEFLAGS= make check-swig-pl 2>&1) | \
2278				tee $(svn_builddir)/tests.log.bindings.pl; \
2279	fi
2280
2281svn-check-swig-py:
2282	-(cd $(svn_builddir) && \
2283		env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
2284		env MAKEFLAGS= make check-swig-py 2>&1) | \
2285			tee $(svn_builddir)/tests.log.bindings.py
2286
2287# We add the svn prefix to PATH here because the ruby tests
2288# attempt to start an svnserve binary found in PATH.
2289svn-check-swig-rb:
2290	(cd $(svn_builddir) && \
2291		env RUBYLIB=$(RUBYLIB) \
2292		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
2293		PATH=$(SVN_PREFIX)/bin:$$PATH \
2294		$(LIB_PTHREAD_HACK) \
2295			env MAKEFLAGS= make check-swig-rb 2>&1) | \
2296			tee $(svn_builddir)/tests.log.bindings.rb
2297
2298svn-check-javahl:
2299	-if [ $(ENABLE_JAVA_BINDINGS) = yes ]; then \
2300		ln -s libsvnjavahl-1.so.0.0 $(PREFIX)/svn-$(WC)/lib/libsvnjavahl-1.so; \
2301		(cd $(svn_builddir) && \
2302			env LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) \
2303			MAKEFLAGS= make $(JAVAHL_CHECK_TARGET) 2>&1) | \
2304				tee $(svn_builddir)/tests.log.bindings.javahl; \
2305	fi
2306
2307svn-check: svn-check-prepare-ramdisk svn-check-local svn-check-svn \
2308	svn-check-neon svn-check-serf svn-check-bindings
2309
2310.PHONY: sign-email
2311ifdef NEON_FLAG
2312NEON_STR=ra_neon |
2313NEON_VER_LINE=@echo "neon:       $(NEON_VER)"
2314endif
2315sign-email:
2316	@echo "Summary: +1 to release"
2317	@echo ""
2318	@echo "Tested: [bdb | fsfs] x [ra_local | ra_svn | $(NEON_STR)ra_serf]"
2319	@echo "        swig bindings"
2320ifeq ($(ENABLE_JAVA_BINDINGS),yes)
2321	@echo "        javahl bindings"
2322endif
2323	@echo ""
2324	@echo "Test results: All passed."
2325	@echo ""
2326	@echo "Platform: `uname -r -s -m`"
2327	@echo ""
2328	@echo "Dependencies:"
2329	@echo "bdb:        $(BDB_VER)"
2330ifeq ($(USE_APR_ICONV),yes)
2331	@echo "apr-iconv:  $(APR_ICONV_VER)"
2332else
2333	@echo "GNU-iconv:  $(GNU_ICONV_VER)"
2334endif
2335	@echo "apr:        $(APR_VER)"
2336	@echo "apr-util:   $(APR_UTIL_VER)"
2337	@echo "httpd:      $(HTTPD_VER)"
2338	$(NEON_VER_LINE)
2339	@echo "serf:       $(SERF_VER)"
2340	@echo "cyrus-sasl: $(CYRUS_SASL_VER)"
2341	@echo "sqlite:     $(SQLITE_VER)"
2342ifdef LZ4_FLAG
2343	@echo "lz4:        $(LZ4_VER)"
2344endif
2345	@echo "libssl:     `openssl version`"
2346	@echo "swig:       `swig -version | grep Version | cut -d' ' -f3`"
2347	@echo "python:     $(PYTHON_VER)"
2348	@echo "perl:       `eval \`perl -V:version\`; echo $$version`"
2349	@echo "ruby:       $(RUBY_VER)"
2350ifeq ($(ENABLE_JAVA_BINDINGS),yes)
2351	@echo "java:       `java -version 2>&1 | grep version | cut -d' ' -f3  | sed -e 's/\"//g'`"
2352endif
2353	@echo ""
2354	@echo "Signatures:"
2355	@echo
2356	@echo "subversion-$(TAG).tar.gz"
2357	@echo "`cat subversion-$(TAG).tar.gz.asc`"
2358	@echo
2359	@echo "subversion-$(TAG).tar.bz2"
2360	@echo "`cat subversion-$(TAG).tar.bz2.asc`"
2361