3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
20 <!ENTITY common SYSTEM 'common.xml'>
21 <!ENTITY find-apr SYSTEM 'find-apr.xml'>
23 Licensed to the Apache Software Foundation (ASF) under one or more
24 contributor license agreements. See the NOTICE file distributed with
25 this work for additional information regarding copyright ownership.
26 The ASF licenses this file to You under the Apache License, Version 2.0
27 (the "License"); you may not use this file except in compliance with
28 the License. You may obtain a copy of the License at
30 http://www.apache.org/licenses/LICENSE-2.0
32 Unless required by applicable law or agreed to in writing, software
33 distributed under the License is distributed on an "AS IS" BASIS,
34 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35 See the License for the specific language governing permissions and
36 limitations under the License.
42 This file builds APR using Apache Ant (http://ant.apache.org)
43 and the C++ compilation tasks from http://ant-contrib.sourceforge.net.
47 <project name="aprutil" default="check" basedir=".">
52 <property name="src.dir" location="${basedir}"/>
53 <property name="include.dir" location="${src.dir}/include"/>
54 <property name="target.dir" location="${basedir}/target"/>
57 <target name="usage" description="Displays usage notes">
62 <target name="init" depends="common-init">
63 <condition property="arch" value="win32">
64 <isset property="is-windows"/>
66 <property name="arch" value="unix"/>
69 <target name="clean" description="Deletes build products">
70 <delete dir="${target.dir}"/>
74 <target name="configure-check" depends="init">
75 <condition property="aprutil-config-available" value="true">
77 <available file="${include.dir}/apu.h"/>
78 <available file="${include.dir}/apu_want.h"/>
79 <available file="${include.dir}/private/apu_config.h"/>
80 <available file="${include.dir}/private/apu_select_dbm.h"/>
81 <available file="${src.dir}/xml/expat/lib/expat.h"/>
82 <available file="${src.dir}/xml/expat/config.h"/>
88 <target name="win-configure" depends="configure-check" if="is-windows" unless="aprutil-config-available">
89 <copy tofile="${include.dir}/apu.h" file="${include.dir}/apu.hw"/>
90 <replaceregexp file="${include.dir}/apu.h" match="#define *APU_HAVE_APR_ICONV.*" replace="#define APU_HAVE_APR_ICONV 0"/>
91 <copy tofile="${include.dir}/apu_want.h" file="${include.dir}/apu_want.hw"/>
92 <copy tofile="${include.dir}/apr_ldap.h" file="${include.dir}/apr_ldap.hw"/>
93 <replaceregexp file="${include.dir}/apr_ldap.h" match="#define APR_HAS_LDAP.*" replace="#define APR_HAS_LDAP 0"/>
94 <copy tofile="${include.dir}/private/apu_config.h" file="${include.dir}/private/apu_config.hw"/>
95 <copy tofile="${include.dir}/private/apu_select_dbm.h" file="${include.dir}/private/apu_select_dbm.hw"/>
96 <copy tofile="${src.dir}/xml/expat/lib/expat.h" file="${src.dir}/xml/expat/lib/expat.h.in"/>
97 <copy tofile="${src.dir}/xml/expat/lib/config.h" file="${src.dir}/xml/expat/lib/winconfig.h"/>
100 <target name="unix-configure" depends="configure-check, find-apr" if="is-unix" unless="aprutil-config-available">
101 <exec executable="sh" dir="${src.dir}">
102 <arg value="./configure"/>
103 <arg value="--with-apr=${apr.dir}"/>
105 <exec executable="sh" dir="${src.dir}/xml/expat">
106 <arg value="./configure"/>
111 <target name="configure" depends="unix-configure, win-configure">
112 <condition property="has-iconv" value="1">
113 <isfileselected file="${include.dir}/apu.h">
114 <contains text="#define APR_HAVE_ICONV 1" ignorewhitespace="true"/>
117 <condition property="has-iconv" value="1">
118 <isfileselected file="${include.dir}/apu.h">
119 <contains text="#define APU_HAVE_ICONV 1" ignorewhitespace="true"/>
122 <condition property="has-sqlite3" value="1">
123 <isfileselected file="${include.dir}/apu.h">
124 <contains text="#define APU_HAVE_SQLITE3 1" ignorewhitespace="true"/>
130 <target name="build-xml" depends="configure" description="Builds Expat">
131 <!-- uses replace instead of preprocessor since
132 the quotes on VERSION cause problems with cpptasks -->
133 <replace file="${src.dir}/xml/expat/lib/xmlparse.c">
134 <replacefilter token="XML_MAJOR_VERSION" value="1"/>
135 <replacefilter token="XML_MINOR_VERSION" value="95"/>
136 <replacefilter token="XML_MICRO_VERSION" value="1"/>
137 <replacefilter token="VERSION" value='"expat_1.95.1"'/>
140 <mkdir dir="${executable.dir}/apr-util-ofiles"/>
141 <property name="project.compiler" value="${compiler}"/>
142 <property name="project.type" value="msvc6"/>
144 <!-- this only generate a project file necessary to mimic
145 this visual studio project provided with APR -->
146 <cc name="${project.compiler}"
147 outfile="${executable.dir}/expat"
152 objdir="${executable.dir}/apr-util-ofiles"
156 <fileset dir="${src.dir}/xml/expat/lib"
157 includes="xmlparse.c xmlrole.c xmltok.c"/>
158 <fileset dir="${src.dir}/xml/expat/lib" includes="*.h"/>
159 <fileset dir="${src.dir}/xml/expat" includes="*.h"/>
160 <includepath path="${src.dir}/xml/expat/lib"/>
161 <includepath path="${src.dir}/xml/expat"/>
163 <define name="XMLPARSEAPI" value=" "/>
165 <defineset define="WIN32" if="is-windows"/>
166 <defineset define="_HAVE_CONFIG_H _REENTRANT _GNU_SOURCE" if="is-gcc"/>
167 <compilerarg value="${pic-option}" if="pic-option"/>
169 <libset libs="cw32mt" if="is-bcc"/>
170 <project type="${project.type}" outfile="${projects.dir}/xml" if="project.if">
171 <comment>&license;</comment>
177 <target name="build" depends="build-xml, find-apr" description="Build library">
178 <property name="apr.lib.prefix" value=""/>
179 <property name="apr.lib.name" value="apr-1"/>
180 <property name="apr.lib.suffix" value=""/>
181 <cc name="${project.compiler}"
182 outfile="${executable.dir}/aprutil-1${lib-suffix}"
186 outtype="${lib.type}"
187 objdir="${executable.dir}/apr-util-ofiles"
190 projectsOnly="${projectsOnly}">
191 <fileset dir="${src.dir}" includes="**/*.c"
192 excludes="test/*.c *.c ldap/*.c xml/expat/lib/*"/>
193 <fileset dir="${src.dir}/xml/expat/lib"
194 includes="xmlparse.c xmlrole.c xmltok.c"/>
195 <fileset dir="${src.dir}/xml/expat/lib" includes="*.h"/>
196 <fileset dir="${src.dir}/xml/expat" includes="*.h"/>
197 <fileset dir="${include.dir}" includes="*.h"/>
198 <fileset dir="${include.dir}/private" includes="*.h"/>
199 <includepath path="${apr.include.dir}"/>
200 <includepath path="${include.dir}"/>
201 <includepath path="${include.dir}/private"/>
202 <includepath path="${src.dir}/xml/expat/lib"/>
203 <includepath path="${src.dir}/xml/expat"/>
204 <defineset define="APU_DECLARE_EXPORT" if="is-shared"/>
205 <defineset define="APU_DECLARE_STATIC" unless="is-shared"/>
206 <defineset define="APR_DECLARE_STATIC" unless="is-apr-shared"/>
208 <define name="XMLPARSEAPI" value=" "/>
210 <defineset define="WIN32" if="is-windows"/>
211 <defineset define="_HAVE_CONFIG_H _REENTRANT _GNU_SOURCE" if="is-gcc"/>
212 <compilerarg value="${pic-option}" if="pic-option"/>
214 <libset dir="${executable.dir}" libs="xml ${apr.lib.prefix}${apr.lib.name}${apr.lib.suffix}"/>
215 <libset libs="cw32mt" if="is-bcc"/>
216 <libset libs="pthread dl" if="is-unix"/>
217 <libset libs="iconv" if="has-iconv"/>
218 <libset libs="sqlite3" if="has-sqlite3"/>
219 <defineset if="is-bcc">
220 <define name="EILSEQ" value="50"/>
222 <project type="${project.type}" outfile="${projects.dir}/aprutil" if="project.if">
223 <comment>&license;</comment>
224 <dependency file="${projects.dir}/apr"/>
227 <property name="apr.lib.dir" location="${executable.dir}"/>
230 <target name="build-test">
231 <mkdir dir="${executable.dir}/apr-util-test-ofiles"/>
232 <property name="project.compiler" value="${compiler}"/>
233 <property name="project.type" value="msvc6"/>
234 <cc name="${project.compiler}"
235 outfile="${executable.dir}/${test}"
240 objdir="${executable.dir}/apr-util-test-ofiles"
242 projectsOnly="${projectsOnly}">
243 <fileset dir="${src.dir}/test" includes="${include.files}" excludes="${exclude.files}"/>
244 <includepath path="${include.dir}"/>
245 <includepath path="${apr.include.dir}"/>
246 <defineset define="APU_DECLARE_STATIC" unless="is-shared"/>
247 <defineset define="APR_DECLARE_STATIC" unless="is-apr-shared"/>
248 <defineset if="is-windows">
249 <define name="WIN32" value="1"/>
251 <defineset define="_HAVE_CONFIG_H _REENTRANT _GNU_SOURCE" if="is-gcc"/>
252 <compilerarg value="${pic-option}" if="pic-option"/>
253 <libset dir="${apr.lib.dir}" libs="apr-1${lib-suffix}" if="apr.lib.dir"/>
254 <libset libs="apr-1${lib-suffix}" unless="apr.lib.dir"/>
255 <libset dir="${executable.dir}" libs="aprutil-1${lib-suffix}"/>
256 <libset libs="cw32mt" if="is-bcc"/>
257 <libset libs="pthread dl" if="is-unix"/>
258 <libset libs="iconv" if="has-iconv"/>
259 <libset libs="sqlite3" if="has-sqlite3"/>
260 <project type="${project.type}" outfile="${projects.dir}/${test}" if="project.if">
261 <comment>&license;</comment>
262 <dependency file="${projects.dir}/apr"/>
263 <dependency file="${projects.dir}/aprutil" depends="apr"/>
268 <target name="copy-apr" if="is-windows">
269 <copy todir="${executable.dir}" overwrite="true">
270 <fileset dir="${apr.lib.dir}" includes="apr-1${lib-suffix}.dll"/>
274 <target name="run-test" depends="copy-apr">
275 <exec executable="${executable.dir}/${test}"
276 dir="${executable.dir}"
278 <env key="DYLD_LIBRARY_PATH"
279 value="${apr.lib.dir}:${aprutil.lib.dir}:${env.DYLD_LIBRARY_PATH}"/>
280 <env key="LD_LIBRARY_PATH"
281 value="${apr.lib.dir}:${aprutil.lib.dir}:${env.LD_LIBRARY_PATH}"/>
283 value="${apr.lib.dir}:${aprutil.lib.dir}:${env.Path}"/>
288 <target name="build-testall" depends="build">
289 <antcall target="build-test">
290 <param name="test" value="testall"/>
291 <param name="include.files" value="**/*.c"/>
292 <param name="exclude.files" value="dbd.c testssl.c echod.c sockperf.c nw*.c"/>
296 <target name="run-testall" depends="build-testall">
297 <antcall target="run-test">
298 <param name="test" value="testall"/>
302 <target name="build-dbd" depends="build">
303 <antcall target="build-test">
304 <param name="test" value="dbd"/>
305 <param name="include.files" value="dbd.c"/>
306 <param name="exclude.files" value="*.y"/>
310 <target name="run-dbd" depends="build-dbd">
311 <antcall target="run-test">
312 <param name="test" value="dbd"/>
316 <target name="build-testssl" depends="build">
317 <antcall target="build-test">
318 <param name="test" value="testssl"/>
319 <param name="include.files" value="testssl.c"/>
323 <target name="run-testssl" depends="build-testssl">
324 <antcall target="run-test">
325 <param name="test" value="testssl"/>
329 <target name="build-echod" depends="build">
330 <antcall target="build-test">
331 <param name="test" value="echod"/>
332 <param name="include.files" value="echod.c"/>
336 <target name="build-sockperf" depends="build">
337 <antcall target="build-test">
338 <param name="test" value="sockperf"/>
339 <param name="include.files" value="sockperf.c"/>
345 <target name="build-check"
346 depends="build-testall, build-dbd, build-testssl, build-echod"
347 description="Builds all tests"/>
350 depends="build-check"
351 description="Runs all tests"/>
354 <target name="build-projects">
355 <mkdir dir="${projects.dir}"/>
356 <antcall target="build">
357 <param name="project.if" value="true"/>
358 <param name="project.type" value="${project.type}"/>
359 <param name="project.compiler" value="${project.compiler}"/>
360 <param name="projects.dir" value="${projects.dir}"/>
361 <param name="debug" value="${debug}"/>
362 <param name="projectsOnly" value="true"/>
366 <target name="build-projects-vc6" depends="init"
367 description="Builds project files for Microsoft Visual C++ 6">
368 <antcall target="build-projects">
369 <param name="projects.dir" value="${projects.dir}"/>
370 <param name="project.type" value="msvc6"/>
371 <param name="project.compiler" value="msvc"/>
372 <param name="os.family" value="windows"/>
373 <param name="projects.dir" value="${projects.dir}"/>
374 <param name="debug" value="${debug}"/>
378 <target name="build-projects-vc7" depends="init"
379 description="Builds project files for Microsoft Visual Studio .NET">
380 <antcall target="build-projects">
381 <param name="projects.dir" value="${projects.dir}"/>
382 <param name="project.type" value="msvc7"/>
383 <param name="project.compiler" value="msvc"/>
384 <param name="os.family" value="windows"/>
385 <param name="projects.dir" value="${projects.dir}"/>
386 <param name="debug" value="${debug}"/>
390 <target name="build-projects-vc8" depends="init"
391 description="Builds project files for Microsoft Visual C++ 2005">
392 <antcall target="build-projects">
393 <param name="projects.dir" value="${projects.dir}"/>
394 <param name="project.type" value="msvc8"/>
395 <param name="project.compiler" value="msvc"/>
396 <param name="os.family" value="windows"/>
397 <param name="projects.dir" value="${projects.dir}"/>
398 <param name="debug" value="${debug}"/>
402 <target name="build-projects-vc9" depends="init"
403 description="Builds project files for Microsoft Visual C++ 2008">
404 <antcall target="build-projects">
405 <param name="projects.dir" value="${projects.dir}"/>
406 <param name="project.type" value="msvc9"/>
407 <param name="project.compiler" value="msvc"/>
408 <param name="os.family" value="windows"/>
409 <param name="projects.dir" value="${projects.dir}"/>
410 <param name="debug" value="${debug}"/>
414 <target name="build-projects-xcode" depends="init"
415 description="Builds project files for Apple Xcode">
416 <antcall target="build-projects">
417 <param name="projects.dir" value="${projects.dir}"/>
418 <param name="project.type" value="xcode"/>
419 <param name="project.compiler" value="${compiler}"/>
420 <param name="os.family" value="mac"/>
421 <param name="projects.dir" value="${projects.dir}"/>
422 <param name="debug" value="${debug}"/>