/apache-log4j-1.2.17/src/ntdll/build.xml
XML | 180 lines | 128 code | 20 blank | 32 comment | 0 complexity | 9062b4ef8499a1f597b65702b3fd11ec MD5 | raw file
Possible License(s): Apache-2.0
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17-->
18
19<!--
20Usage notes:
21
22To build NTEventLogAppender.dll using MinGW, place mingw\bin on path for Windows or install mingw
23package on other platforms. Build will execute gcc and windres on Windows and
24i586-mingw32msvc-gcc and i586-mingw32msvc-windres on other platforms.
25
26To build NTEventLogAppender.dll using Microsoft tools, run the appropriate vcvars for the
27target platform and specify msbuild as the target on the ant command line.
28
29-->
30
31
32<project name="ntdll" default="build" basedir=".">
33 <property name="target.dir" value="target"/>
34 <property name="object.dir" value="target/obj"/>
35 <property name="src.dir" location="${basedir}"/>
36 <property name="failonerror" value="false"/>
37 <property name="failifexecutionfails" value="${failonerror}"/>
38 <property name="jni.include.dir" location="${java.home}/../include"/>
39 <property environment="env"/>
40 <condition property="jni.win32.include.dir" value="${jni.include.dir}/win32">
41 <available file="${jni.include.dir}/win32"/>
42 </condition>
43 <property name="jni.win32.include.dir" value="${env.JNI_WIN32_INCLUDE_DIR}"/>
44 <available property="jni_md.h_available" file="${jni.win32.include.dir}/jni_md.h"/>
45
46 <target name="clean" description="Deletes generated files">
47 <delete dir="${target.dir}"/>
48 </target>
49
50 <!--
51 Regenerates resource files from EventLogCategories.mc. Avoids
52 need for Microsoft Platform SDK unless you are modifying EventLogCategories.mc
53 -->
54 <target name="mc" description="Update EventLogCategories.rc from .mc">
55 <exec executable="mc">
56 <arg value="-h"/>
57 <arg file="${basedir}"/>
58 <arg value="-r"/>
59 <arg file="${basedir}"/>
60 <arg file="EventLogCategories.mc"/>
61 </exec>
62 </target>
63
64
65
66 <target name="windres">
67 <condition property="mingw-prefix" value="">
68 <os family="windows"/>
69 </condition>
70 <property name="mingw-prefix" value="i586-mingw32msvc-"/>
71 <mkdir dir="${object.dir}"/>
72 <exec executable="${mingw-prefix}windres"
73 dir="${src.dir}"
74 resultproperty="windres_status"
75 failonerror="${failonerror}"
76 failifexecutionfails="${failifexecutionfails}">
77 <arg value="-o"/>
78 <arg file="${object.dir}/NTEventLogAppender.o"/>
79 <arg file="${src.dir}/NTEventLogAppender.rc"/>
80 </exec>
81 <condition property="windres_success">
82 <equals arg1="${windres_status}" arg2="0"/>
83 </condition>
84 <condition property="do_compile">
85 <and>
86 <isset property="windres_success"/>
87 <isset property="jni_md.h_available"/>
88 </and>
89 </condition>
90 </target>
91
92 <target name="compile" depends="windres" if="do_compile">
93 <fail unless="classes.dir">-Dclasses.dir=/path/to/log4j/classes must be specified</fail>
94 <javah class="org.apache.log4j.nt.NTEventLogAppender,org.apache.log4j.Priority"
95 destdir="${object.dir}"
96 classpath="${classes.dir}"/>
97
98 <exec executable="${mingw-prefix}gcc">
99 <arg value="-Wall"/>
100 <arg value="-D_JNI_IMPLEMENTATION_"/>
101 <arg value="-Wl,--kill-at"/>
102 <arg value="-fno-rtti"/>
103 <arg value="-fno-exceptions"/>
104 <arg value="-s"/>
105 <arg value="-I${jni.win32.include.dir}"/>
106 <arg value="-I${jni.include.dir}"/>
107 <arg value="-I${object.dir}"/>
108 <arg value="-shared"/>
109 <arg file="${src.dir}/nteventlog.cpp"/>
110 <arg file="${object.dir}/NTEventLogAppender.o"/>
111 <arg value="-o"/>
112 <arg file="${target.dir}/NTEventLogAppender.dll"/>
113 </exec>
114 </target>
115
116 <target name="windres-echo" depends="windres" unless="windres_success">
117 <echo>${mingw-prefix}windres could not be found or failed, NTEventLogAppender.dll build skipped.</echo>
118 </target>
119
120 <target name="jni_md.h-echo" unless="jni_md.h_available">
121 <echo>${jni.win32.include.dir}/jni_md.h not found, NTEventLogAppender.dll build skipped.</echo>
122 </target>
123
124 <target name="build" depends="compile, windres-echo, jni_md.h-echo" description="Build with MinGW gcc">
125 </target>
126
127 <target name="rc">
128 <exec executable="rc"
129 dir="${src.dir}"
130 resultproperty="rc_status"
131 failonerror="${failonerror}"
132 failifexecutionfails="${failifexecutionfails}">
133 <arg file="${src.dir}/NTEventLogAppender.rc"/>
134 </exec>
135 <condition property="rc_success">
136 <equals arg1="${rc_status}" arg2="0"/>
137 </condition>
138 <condition property="do_cl">
139 <and>
140 <isset property="rc_success"/>
141 <isset property="jni_md.h_available"/>
142 </and>
143 </condition>
144 </target>
145
146 <target name="cl" depends="rc" if="do_cl">
147 <fail unless="classes.dir">-Dclasses.dir=/path/to/log4j/classes must be specified</fail>
148 <mkdir dir="${object.dir}"/>
149 <javah class="org.apache.log4j.nt.NTEventLogAppender,org.apache.log4j.Priority"
150 destdir="${object.dir}"
151 classpath="${classes.dir}"/>
152
153 <property name="object.location" location="${object.dir}"/>
154 <exec executable="cl" dir="${target.dir}">
155 <arg value="/MT"/>
156 <arg value="/D_JNI_IMPLEMENTATION_"/>
157 <arg value="/O2"/>
158 <arg value="/GR-"/>
159 <arg value="/LD"/>
160 <arg value="/I${jni.win32.include.dir}"/>
161 <arg value="/I${jni.include.dir}"/>
162 <arg value="/I${object.location}"/>
163 <arg value="/I${src.dir}"/>
164 <arg file="${src.dir}/nteventlog.cpp"/>
165 <arg file="${src.dir}/NTEventLogAppender.res"/>
166 <arg file="${src.dir}/NTEventLogAppender.def"/>
167 <arg value="advapi32.lib"/>
168 <arg value="/FeNTEventLogAppender.dll"/>
169 </exec>
170 </target>
171
172 <target name="rc-echo" depends="rc" unless="rc_success">
173 <echo>rc could not be found or failed, NTEventLogAppender.dll build skipped.</echo>
174 </target>
175
176
177 <target name="msbuild" depends="cl, rc-echo, jni_md.h-echo" description="Build using Microsoft tools">
178 </target>
179
180</project>