aboutsummaryrefslogtreecommitdiff
path: root/build.xml
blob: 730e7ad13b4448e03c9acb4c039d545f70e70ce3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?xml version="1.0"?>

<project name="pdj" default="package" basedir=".">
	<property file="build.properties"/>
	<property file="${os.name}-build.properties"/>
	
	<!-- ============================================================== -->
	<property name="jdk.include" value="${jdk.home}/include"/>
	<property name="pd.include" value="${pd.home}/src"/>
	
	<!-- java classes that uses a native interface -->
	<property name="native.classes" value="
			com.cycling74.max.MaxObject,   
			com.cycling74.max.MaxClock,    
			com.cycling74.max.MaxSystem,   
			com.cycling74.msp.MSPBuffer,  
			com.cycling74.msp.MSPObject"/>
			
	<target name="clean" depends="-init">
		<delete dir="${dist.dir}"/>
		<delete dir="${work.dir}"/>
		<delete dir="${javadoc.dir}"/>
		<delete>
			<fileset dir="." includes="**/history.xml,**/dependencies.xml,index.html"/>
		</delete>
	</target>
	
	<target name="-init">
		<mkdir dir="${classes.dir}"/>
		<mkdir dir="${dist.dir}"/>
		<taskdef resource="cpptasks.tasks" classpath="lib/ant/cpptasks.jar"/>
		<typedef resource="cpptasks.types" classpath="lib/ant/cpptasks.jar"/>
		<available classname="junit.framework.Test" property="isJunitFound"/>
		
		<!-- this is to set a special condition if you are using gcc (mingw) on win32
      -->
      
		<condition property="win32.gcc">
	      <and>
	          <equals arg1="${compiler}" arg2="gcc"/>
	          <equals arg1="${isWin32}" arg2="true"/>
	      </and>
		</condition>
		
		<condition property="win32.msvc">
	      <and>
	          <equals arg1="${compiler}" arg2="msvc"/>
	          <equals arg1="${isWin32}" arg2="true"/>
	      </and>
		</condition>
		
		<!-- if the OS X bundle is d_fat, then pdj must be build with the -arch option
		     This property does only apply on OS X.
		  -->
		<condition property="isFatBin">
		    <or>
    		    <contains string="${os.version}" substring="10.4"/>
    		    <contains string="${os.version}" substring="10.5"/>
    		</or>
		</condition>
	</target>
	
	<target name="cl-java" depends="-init">
		<javac destdir="${classes.dir}" srcdir="${java.src.dir}" debug="true" 
			target="1.4" source="1.4">
			<exclude name="**/test/**" unless="isJunitFound"/>
			<exclude name="**/*Test.java" unless="isJunitFound"/>
		</javac>
		
		<jar jarfile="${pdj.jar}" basedir="${classes.dir}">
			<exclude name="*.class"/>
			<exclude name="**/test/**" unless="isJunitFound"/>
			<exclude name="**/*Test.class" unless="isJunitFound"/>
		</jar>
		
		<uptodate property="javah.up2date" srcfile="${pdj.jar}" targetfile="${javah.file}"/>
	</target>
	
	<target name="initlib-win32" if="win32.gcc">
		<copy file="${pd.home}/obj/pd.a" tofile="${work.dir}/libpd.a"/>
	</target>
	
	<target name="javah" depends="cl-java" unless="javah.up2date">
		<javah class="${native.classes}" classpath="${pdj.jar}" outputFile="${javah.file}" force="true"/>
	</target>
	
	<target name="-linux-rename" if="isLinux">
		<move file="${dist.dir}/libpdj.so" tofile="${dist.dir}/pdj.pd_linux"/>
	</target>
	
	<target name="-osx-rename" if="isOSX">
		<move file="${dist.dir}/libpdj.${pdj.archBuild}.bundle" tofile="${pdj.outfile}"/>
	</target>
	
	<target name="-windows-rename" if="win32.gcc">
	  <move file="${dist.dir}/libpdj.so" tofile="${dist.dir}/pdj.dll"/>
	</target>
	
	<target name="cl" depends="javah, initlib-win32">
		<cc debug="true" objdir="${work.dir}" outtype="${linker.type}" 
			outfile="${pdj.outfile}" name="${compiler}">
			
			<fileset dir="${src.dir}" includes="*.c">
				<exclude name="pdj-linux.c" unless="isLinux"/>
				<exclude name="pdj-win32.c" unless="isWin32"/>
				<exclude name="pdj-osx.c" unless="isOSX"/>
			</fileset>
			
			<!-- compiler args -->
			<defineset define="DEBUG"/>
			<defineset define="PROFILER"/>
			<defineset define="PD"/>
			<defineset define="NT" if="isWin32"/>
			<defineset define="WIN32GCC" if="win32.gcc"/>
			<compilerarg value="-Wall" if="isLinux"/>
		
			<compilerarg value="-fno-common" if="isOSX"/>
			<compilerarg value="-fPIC" if="isOSX"/>
			<compilerarg value="-arch" if="isFatBin"/>
			<compilerarg value="i386" if="isFatBin"/>
			<compilerarg value="-arch" if="isFatBin"/>
			<compilerarg value="ppc" if="isFatBin"/>
			<compilerarg value="-isysroot" if="isFatBin"/>
			<compilerarg value="/Developer/SDKs/MacOSX10.4u.sdk" if="isFatBin"/>
			<!-- includes files -->
			<includepath location="${jdk.include}"/>
			<includepath location="${jdk.include}/linux" if="isLinux"/>
			<includepath location="${jdk.include}/win32" if="isWin32"/>
			<includepath location="${pd.include}"/>
			<includepath location="${work.dir}"/>
			
			<!-- linker specific -->
			<libset dir="${pd.home}/bin" libs="pd" if="win32.msvc"/>
			<libset dir="${work.dir}" libs="pd" if="win32.gcc"/>
			<libset libs="Advapi32" if="isWin32"/>
			<linkerarg value="/export:pdj_setup" if="win32.msvc"/>

			<linkerarg value="-export-dynamic" if="isLinux"/>
			<linkerarg value="-Xlinker" if="isLinux"/>
			
			<!-- OS X :-\ -->
			<linker name="gcc" if="isOSX"/>
			<linkerarg value="-arch" if="isFatBin"/>
			<linkerarg value="i386" if="isFatBin"/>
			<linkerarg value="-arch" if="isFatBin"/>
			<linkerarg value="ppc" if="isFatBin"/>
			<linkerarg value="-framework" if="isOSX"/>
			<linkerarg value="JavaVM" if="isOSX"/>
			<linkerarg value="-framework" if="isOSX"/>
			<linkerarg value="CoreFoundation" if="isOSX"/>
			<linkerarg value="-flat_namespace" if="isOSX"/>
			<linkerarg value="-framework" if="isOSX"/>
			<linkerarg value="AppKit" if="isOSX"/>
			<linkerarg value="-undefined" if="isOSX"/>
			<linkerarg value="suppress" if="isOSX"/>
			<linkerarg value="-lm" if="isOSX"/>
			<linkerarg value="-bundle" if="isOSX"/>
			<linkerarg value="-isysroot" if="isFatBin"/>
			<linkerarg value="/Developer/SDKs/MacOSX10.4u.sdk" if="isFatBin"/>
		</cc>
		
		<antcall target="-linux-rename"/>
		<antcall target="-osx-rename"/>
		<antcall target="-windows-rename"/>
	</target>
	
	<target name="package" depends="cl">
		<copy todir="${dist.dir}">
			<fileset dir="res">
				<exclude name="docs/pdj.odt"/>
			</fileset>
		</copy>
		<copy todir="${dist.dir}/classes">
			<!-- include the default package (examples) source -->
			<fileset dir="src/java" includes="*.java"/>
			<fileset dir="${classes.dir}" includes="*.class"/>
		</copy>
	</target>
	
	<target name="dist" depends="clean">
		<tar destfile="../pdj-${pdj.version}.tar.gz" compression="gzip">
			<tarfileset dir="." prefix="pdj-${pdj.version}"/>
		</tar>
	</target>
	
	<target name="javadoc" depends="cl-java">
		<mkdir dir="${javadoc.dir}"/>
		<javadoc source="src" destdir="${javadoc.dir}" windowtitle="pdj-MXJ API">
			<fileset dir="src/java">
				<include name="com/cycling74/max/*.java"/>
				<include name="com/cycling74/msp/*.java"/>
				<include name="com/cycling74/net/*.java"/>
				<exclude name="*.java"/>
				<exclude name="**/test/**"/>
				<exclude name="**/*Test.java"/>
			</fileset>
			<link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
			<doctitle><![CDATA[<h1>The MXJ Java API for pure-data</h1>
		    <p>This API is based on MXJ for Max/MSP.</p>]]></doctitle>
			<bottom><![CDATA[This API is based on mxj for <a  
		    	href="http://www.cycling74.com/products/maxmsp.html">
		    	Max/MSP</a> by Cycling74. Please see original MXJ
			    implementation.]]></bottom>
		</javadoc>
	</target>
	
	<target name="dist-www" depends="javadoc">
		<tar destfile="../pdj-web.tar.gz" compression="gzip">
			<tarfileset dir="www">
				<exclude name=".*"/>
			</tarfileset>
		</tar>
	</target>

	<target name="dist-win32" depends="package,javadoc">
		<zip destfile="${dist.dir}/pdj-${pdj.version}-win32.zip">
			<zipfileset dir="www/api" includes="**" prefix="javadoc"/>
			<fileset dir="${dist.dir}">
				<include name="docs/*.pdf"/>
				<include name="classes/**"/>
				<include name="*.jar"/>
				<include name="*.pd"/>
				<include name="*.properties"/>
				<include name="*.dll"/>
			</fileset>
			<fileset dir=".">
				<include name="README"/>
				<include name="LICENSE"/>
			</fileset>
		</zip>
	</target>
	
	<target name="dist-osx" depends="package,javadoc">
		<tar destfile="../pdj-${pdj.version}-osx.tar.gz" compression="gzip">
			<tarfileset dir="www/api" includes="**" prefix="pdj/javadoc"/>
			<tarfileset dir="${dist.dir}" prefix="pdj">
				<include name="docs/*.pdf"/>
				<include name="classes/**"/>
				<include name="*.jar"/>
				<include name="*.pd"/>
				<include name="*.properties"/>
				<include name="*.${pdj.archBuild}"/>
				<include name="pdj.d_fat" if="isFatBin"/>
			</tarfileset>
			<tarfileset dir="." prefix="pdj">
				<include name="README"/>
				<include name="LICENSE"/>
			</tarfileset>
		</tar>
	</target>
	
	<!-- test targets -->
	
	<target name="test" depends="package">
		<exec dir="${dist.dir}" executable="${pd.home}/bin/pd">
			<arg line="-lib pdj ${pdj.test-patch}"/>
		</exec>
	</target>
	
	<target name="test-dsp" depends="package">
		<exec dir="${dist.dir}" executable="${pd.home}/bin/pd">
			<arg line="-lib pdj ${pdj-tilde.test-patch}"/>
		</exec>
	</target>
	
	<target name="test-mxdublin" depends="package">
		<ant antfile="../mxdublin/build.xml" target="package" dir="../mxdublin"/>
		<exec dir="${dist.dir}" executable="${pd.home}/bin/pd">
			<arg line="-lib pdj ../../mxdublin/res/test/test-mxdublin.pd"/>
		</exec>
	</target>
	
	<target name="test-mxdublin-help" depends="package">
		<ant antfile="../mxdublin/build.xml" target="package" dir="../mxdublin"/>
		<exec dir="${dist.dir}" executable="${pd.home}/bin/pd">
			<arg line="-lib pdj ../../mxdublin/res/examples/help-mxdublin.pd"/>
		</exec>
	</target>
	
	<target name="test-helpatch" depends="package">
		<exec dir="${dist.dir}" executable="${pd.home}/bin/pd">
			<arg line="-lib pdj ../res/help-pdj.pd"/>
		</exec>
	</target>
	
</project>