Fix build error with GCC6
[profile/ivi/log4cxx.git] / src / ant / apr-util-build.xml
1 <?xml version="1.0"?>
2 <!--
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
9
10       http://www.apache.org/licenses/LICENSE-2.0
11
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.
17
18 -->
19 <!DOCTYPE project [
20 <!ENTITY common SYSTEM 'common.xml'>
21 <!ENTITY find-apr SYSTEM 'find-apr.xml'>
22 <!ENTITY license '
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
29
30       http://www.apache.org/licenses/LICENSE-2.0
31
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.
37 '>
38 ]>
39
40 <!--
41
42 This file builds APR using Apache Ant (http://ant.apache.org)
43 and the C++ compilation tasks from http://ant-contrib.sourceforge.net.
44
45
46 -->
47 <project name="aprutil" default="check" basedir=".">
48
49 &common;
50 &find-apr;
51
52 <property name="src.dir" location="${basedir}"/>
53 <property name="include.dir" location="${src.dir}/include"/>
54 <property name="target.dir" location="${basedir}/target"/>
55
56
57 <target name="usage" description="Displays usage notes">
58         <echo>
59         </echo>
60 </target>
61
62 <target name="init" depends="common-init">
63     <condition property="arch" value="win32">
64         <isset property="is-windows"/>
65     </condition>
66     <property name="arch" value="unix"/>
67 </target>
68
69 <target name="clean" description="Deletes build products">
70         <delete dir="${target.dir}"/>
71 </target>
72
73
74 <target name="configure-check" depends="init">
75         <condition property="aprutil-config-available" value="true">
76               <and>
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"/>
83                </and>
84         </condition>
85 </target>
86
87
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"/>
98 </target>
99
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}"/>
104         </exec>
105         <exec executable="sh" dir="${src.dir}/xml/expat">
106             <arg value="./configure"/>
107         </exec>
108 </target>
109
110
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"/>
115         </isfileselected>
116     </condition>
117     <condition property="has-iconv" value="1">
118         <isfileselected file="${include.dir}/apu.h">
119             <contains text="#define APU_HAVE_ICONV 1" ignorewhitespace="true"/>
120         </isfileselected>
121     </condition>
122     <condition property="has-sqlite3" value="1">
123         <isfileselected file="${include.dir}/apu.h">
124             <contains text="#define APU_HAVE_SQLITE3 1" ignorewhitespace="true"/>
125         </isfileselected>
126     </condition>
127 </target>
128
129
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"'/>
138     </replace>
139
140     <mkdir dir="${executable.dir}/apr-util-ofiles"/>
141     <property name="project.compiler" value="${compiler}"/>
142         <property name="project.type" value="msvc6"/>
143     
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"
148         subsystem="console"
149         multithreaded="true"
150         runtime="${runtime}"        
151         outtype="static"
152         objdir="${executable.dir}/apr-util-ofiles"
153         warnings="none"
154         debug="${debug}"
155         projectsOnly="true">
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"/>
162         <defineset>
163             <define name="XMLPARSEAPI" value=" "/>
164         </defineset>
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"/>
168
169         <libset libs="cw32mt" if="is-bcc"/>
170         <project type="${project.type}" outfile="${projects.dir}/xml" if="project.if">
171                         <comment>&license;</comment>
172         </project>
173     </cc>
174
175 </target>
176
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}"
183         subsystem="console"
184         multithreaded="true"
185         runtime="${runtime}"
186         outtype="${lib.type}"
187         objdir="${executable.dir}/apr-util-ofiles"
188         warnings="none"
189         debug="${debug}"
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"/>
207         <defineset>
208             <define name="XMLPARSEAPI" value=" "/>
209         </defineset>
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"/>
213
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"/>
221         </defineset>
222         <project type="${project.type}" outfile="${projects.dir}/aprutil" if="project.if">
223                         <comment>&license;</comment>
224             <dependency file="${projects.dir}/apr"/>
225         </project>
226     </cc>
227     <property name="apr.lib.dir" location="${executable.dir}"/>
228 </target>
229
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}"
236         subsystem="console"
237         multithreaded="true"
238         runtime="${runtime}"
239         outtype="executable"
240         objdir="${executable.dir}/apr-util-test-ofiles"
241         debug="${debug}"
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"/>
250         </defineset>
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"/>
264         </project>
265     </cc>
266 </target>
267
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"/>
271     </copy>
272 </target>
273
274 <target name="run-test" depends="copy-apr">
275     <exec executable="${executable.dir}/${test}"
276           dir="${executable.dir}"
277           failonerror="true">
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}"/>
282         <env key="Path"
283            value="${apr.lib.dir}:${aprutil.lib.dir}:${env.Path}"/>
284     </exec>
285 </target>
286
287
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"/>
293     </antcall>
294 </target>
295
296 <target name="run-testall" depends="build-testall">
297     <antcall target="run-test">
298         <param name="test" value="testall"/>
299     </antcall>
300 </target>
301
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"/>
307     </antcall>
308 </target>
309
310 <target name="run-dbd" depends="build-dbd">
311     <antcall target="run-test">
312         <param name="test" value="dbd"/>
313     </antcall>
314 </target>
315
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"/>
320     </antcall>
321 </target>
322
323 <target name="run-testssl" depends="build-testssl">
324     <antcall target="run-test">
325         <param name="test" value="testssl"/>
326     </antcall>
327 </target>
328
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"/>
333     </antcall>
334 </target>
335
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"/>
340     </antcall>
341 </target>
342
343
344
345 <target name="build-check"
346     depends="build-testall, build-dbd, build-testssl, build-echod"
347     description="Builds all tests"/>
348
349 <target name="check"
350     depends="build-check"
351      description="Runs all tests"/>
352
353
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"/>
363             </antcall>
364     </target>
365
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}"/>
375         </antcall>
376     </target>
377
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}"/>
387       </antcall>
388     </target>
389
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}"/>
399       </antcall>
400     </target>
401
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}"/>
411     </antcall>
412   </target>
413
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}"/>
423         </antcall>
424     </target>
425
426
427
428 </project>