build.xml 41 KB
Newer Older
1 2
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="antlib:org.apache.tools.ant"
3
         name="abcl-master" default="abcl.wrapper" basedir=".">
4
    <description>Compiling, testing, and packaging Armed Bear Common Lisp</description>
5 6

    <target name="abcl" depends="abcl.wrapper"/>
7
        
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    <target name="help">
      <echo>
Main Ant targets:

 abcl.wrapper 
   -- [default] create executable wrapper for ABCL.
 abcl.compile  
   -- compile ABCL to ${build.classes.dir}.
 abcl.jar      
   -- create packaged ${abcl.jar.path}.
 abcl.source.zip abcl.source.tar
   -- create source distributions in ${dist.dir}.
 abcl.clean 
   -- remove ABCL intermediate files
      </echo>

      <echo>
For help on the automatic tests available, use the Ant target 'help.test'.
      </echo>
    </target>
28

29
    <!-- Behavior of the build system can be customized via setting
30 31
         properties in the 'abcl.properties' file. -->
    <property file="abcl.properties"/>
32 33

    <property name="build.dir" 
34
              value="${basedir}/build"/>
35
    <property name="build.classes.dir" 
36
              value="${build.dir}/classes"/>
37
    <property name="src.dir" 
38
              value="${basedir}/src"/>
39
    <property name="dist.dir" 
40
              value="${basedir}/dist"/>
41
    <property name="abcl.jar.path"
42
              value="${dist.dir}/abcl.jar"/>
43
    <property name="abcl.ext.dir"
44
              value="${basedir}/ext"/>
45

46 47 48
    <property name="abcl.runtime.jar.path"
              value="${abcl.jar.path}"/>

49 50 51 52 53 54 55
    <fail message="Please build using Ant 1.7.1 or higher.">
        <condition>
            <not>
                <antversion atleast="1.7.1"/>
            </not>
        </condition>
    </fail>
56

57
    <!-- Checks if JSR-223 support is available - thanks to Mark Evenson -->
58
    <available property="abcl.jsr-223.p"
59
               classname="javax.script.ScriptEngine"/>
60

61 62 63
    <patternset id="abcl.source.java">
      <include name="org/armedbear/lisp/*.java"/>
      <include name="org/armedbear/lisp/util/*.java"/>
64
      <include name="org/armedbear/lisp/protocol/*.java"/>
65
      <include name="org/armedbear/lisp/java/**/*.java"/>
66 67 68
      <include name="org/armedbear/lisp/scripting/*.java" if="abcl.jsr-223.p"/>
      <include name="org/armedbear/lisp/scripting/util/*.java" if="abcl.jsr-223.p"/>
      <include name="org/armedbear/Main.java"/>
69
    </patternset>
70

71 72
    <patternset id="abcl.source.lisp">
      <include name="org/armedbear/lisp/*.lisp"/>
73
      <include name="org/armedbear/lisp/java/**/*.lisp"/>
74
      <include name="org/armedbear/lisp/tests/*.lisp"/>
75
      <exclude name="org/armedbear/lisp/j.lisp"/>
76
      <include name="org/armedbear/lisp/scripting/lisp/*.lisp" if="abcl.jsr-223.p"/>
77 78
    </patternset>

79 80 81
    <!-- Lisp files required at runtime -->
    <patternset id="abcl.source.lisp.dist">
      <include name="org/armedbear/lisp/boot.lisp"/>
82
      <include name="org/armedbear/lisp/scripting/lisp/*.lisp" if="abcl.jsr-223.p"/>
83
      <include name="**/*.lisp" if="abcl.compile.lisp.skip"/>
84 85 86
    </patternset>

    <patternset id="abcl.objects">
87
      <!-- "system.lisp" is dynamically created by COMPILE-fSYSTEM -->
88
      <include name="org/armedbear/lisp/system.lisp"/> 
89 90 91
      <include name="org/armedbear/lisp/**/*.class"/>
      <include name="org/armedbear/lisp/**/*.cls"/> 
      <include name="org/armedbear/lisp/**/*.abcl"/>
92
      <include name="org/armedbear/lisp/version"/>
93 94
      <include name="org/armedbear/lisp/scripting/*.class" if="abcl.jsr-223.p"/>
      <include name="org/armedbear/lisp/scripting/util/*.class" if="abcl.jsr-223.p"/>
95
      <patternset refid="abcl.source.lisp.dist"/>
96
      <include name="abcl.rdf"/>
97 98 99 100 101 102 103 104 105 106
    </patternset>
    
    <path id="abcl.classpath.dist">
      <pathelement location="${abcl.jar.path}"/>
    </path>
    
    <path id="abcl.classpath.build">
      <pathelement location="${build.classes.dir}"/>
    </path>

107
    <target name="abcl.compile" depends="abcl.clean.maybe,abcl.compile.lisp">
108
      <echo>Compiled ABCL with Java version: ${java.version}</echo>
109
    </target>
110

111 112 113 114 115 116
    <target name="abcl.clean.maybe" unless="abcl.build.incremental">
      <echo>Cleaning all intermediate compilation artifacts.</echo>
      <echo>Setting 'abcl.build.incremental' enables incremental compilation.</echo>
      <antcall target="abcl.clean"/>
    </target>
      
117

118 119
    <target name="abcl.init">
      <tstamp>
120
        <format property="build" pattern="EEE MMM dd yyyy HH:mm:ss zzz"/>
121 122
      </tstamp>

123
      <tstamp>
124
        <format property="build.stamp" pattern="yyyymmdd-HHmm"/>
125 126 127
      </tstamp>

      <property name="abcl.test.log.file"
128
                value="abcl-test-${build.stamp}.log"/>
129

130
      <property name="java.path"
131
                value="${java.home}/bin/java"/>
132

133 134
      <!-- Deprecated. Two main types of build environents: 'unix' or 'windows'. -->
      <condition property="unix"> 
135 136 137 138
        <or>
          <os family="unix"/>
          <os family="mac"/>
        </or>
139 140
      </condition>
      <condition property="windows"> 
141
        <os family="windows"/>
142
      </condition>
143

144 145
      <!-- Deprecated. -->
      <available file="${src.dir}org/armedbear/lisp/Interpreter.java" 
146
                 property="abcl.lisp.p"/>
147

148 149
      <echo>java.version: ${java.version}</echo>
      <condition property="abcl.java.version.p">
150
        <or>
151 152
          <matches string="${java.version}" 
                   pattern="1\.5"/>
153
          <!-- Don't use 1.6.0_09 or earlier. -->
154 155 156 157
          <matches string="${java.version}" 
                   pattern="1\.6\.0_[1-9][0-9]"/>
          <!-- 1.7.0_04 works much better. -->
          <matches string="${java.version}" 
158
                   pattern="1\.7\.0_(0[4-9])|([1-9][0-9])"/>
159 160
          <matches string="${java.version}" 
                   pattern="1\.8\.0"/>
161
        </or>  
162
      </condition>
163

164 165 166
    </target>
    
    <target name="abcl.java.warning" 
167 168
            depends="abcl.init"
            unless="abcl.java.version.p">
169
      <echo>WARNING: Use of Java version ${java.version} not recommended.</echo>
170
    </target>
171
        
172
    <target name="abcl.jsr-223.notice"
173 174
            depends="abcl.init"
            unless="abcl.jsr-223.p">
175
      <echo>
176 177 178
        Notice: JSR-223 support won't be built since it is not
                supported, neither natively by your JVM nor by 
                libraries in the CLASSPATH.
179
      </echo>
180 181
    </target>

182
    <target name="abcl.compile.java" 
183
            depends="abcl.init,abcl.java.warning,abcl.jsr-223.notice">
184 185
      <mkdir dir="${build.dir}"/>
      <mkdir dir="${build.classes.dir}"/>
186
      <!-- Stock build for Java 1.5 (aka Java 2) container -->
187
      <javac destdir="${build.classes.dir}"
188 189
             debug="true"
             target="1.5"
190
             source="1.5"
191
             includeantruntime="false"
192 193 194
             failonerror="true">
        <src path="${src.dir}"/>
        <patternset refid="abcl.source.java"/>
195 196
      </javac>
      <echo message="${build}" 
197
            file="${build.classes.dir}/org/armedbear/lisp/build"/>
198 199
    </target>

200 201 202 203 204 205 206 207 208 209 210 211 212 213
    <!-- Additional artifacts to stage relative to Ant ${basedir} -->
    <patternset id="abcl.stage">
      <include name="abcl.rdf"/>
    </patternset>

    <target name="abcl.stage"
	    depends="abcl.copy.lisp">
      <copy todir="${build.classes.dir}" preservelastmodified="yes">
	<fileset dir="${basedir}/">
	  <patternset refid="abcl.stage"/>
	</fileset>
      </copy>
    </target>
    
214 215
    <target name="abcl.copy.lisp">
      <copy todir="${build.classes.dir}" preservelastmodified="yes">
216
        <fileset dir="${src.dir}">
217
          <patternset refid="abcl.source.lisp.dist"/>
218
        </fileset>
219 220 221 222 223
      </copy>
    </target>

    <!-- Adjust the patternset for ABCL source to use the much faster
         Ant 'uptodate' task to check if we need to compile the system
224
         fasls.  Highly inter-dependent with the behavior specified in
225 226
         'compile-system.lisp', i.e. files not listed in
         there should NOT occur here. -->
227 228
    <patternset id="abcl.source.lisp.fasls">
      <patternset refid="abcl.source.lisp"/>
229
      <exclude name="org/armedbear/lisp/scripting/**/*.lisp"/>
230 231 232 233 234 235 236
      <exclude name="org/armedbear/lisp/boot.lisp"/>
      <exclude name="org/armedbear/lisp/emacs.lisp"/>
      <exclude name="org/armedbear/lisp/run-benchmarks.lisp"/>
    </patternset>

    <target name="abcl.fasls.uptodate">
      <uptodate property="abcl.fasls.uptodate.p" value="true">
237 238 239 240
        <srcfiles dir="${src.dir}">
          <patternset refid="abcl.source.lisp.fasls"/>
        </srcfiles>
        <mapper type="glob" from="*.lisp" to="${build.classes.dir}/*.abcl"/>
241 242
      </uptodate>
    </target>
243 244 245

    <path id="abcl.home.dir.path">
        <path location="${src.dir}/org/armedbear/lisp/"/>
246
    </path>         
247 248 249 250
    <pathconvert property="abcl.home.dir" refid="abcl.home.dir.path"/>

    <path id="abcl.lisp.output.path"
          location="${build.classes.dir}/org/armedbear/lisp/"/>
251
    <pathconvert dirsep="/" property="abcl.lisp.output" refid="abcl.lisp.output.path"/>
252 253 254

    <property name="system.lisp.file" 
              value="${build.classes.dir}/org/armedbear/lisp/system.lisp"/>
255

256
    <target name="abcl.compile.lisp" 
257
            depends="abcl.stage,abcl.compile.java,abcl.system.update.maybe,abcl.fasls.uptodate"
258
            unless="abcl.fasls.uptodate.p">
259 260 261 262 263 264 265
      <abcl.compile.lisp/>
    </target>

    <macrodef name="abcl.compile.lisp">
      <element name="additional.jvmarg" optional="true"/>
      <sequential>
        <echo>
266 267
Compiling Lisp system 
from ${abcl.home.dir}
268 269 270 271 272 273 274
 to  ${abcl.lisp.output}</echo>
 
     <!-- Not good if ${abcl.home.dir} == ${abcl.lisp.output} -->
     <delete>
       <fileset dir="${abcl.home.dir}" includes="**/*.abcl **/*.cls **/*._"/>
     </delete>
     <java classpath="${build.classes.dir}" 
275 276
            fork="true"
            failonerror="true"
277
            inputstring="(handler-case (compile-system :zip nil :quit t :output-path &quot;${abcl.lisp.output}/&quot;) (t (x) (progn (format t &quot;~A: ~A~%&quot; (type-of x) x) (exit :status -1))))"
278
            classname="org.armedbear.lisp.Main">
279
        <jvmarg value="-Dabcl.home=${abcl.home.dir}${file.separator}"/>
280
        <jvmarg value="-Dabcl.autoload.verbose=Y"/>
281
        <additional.jvmarg/>
282
        <arg value="--noinit"/>
283
        <arg value="--nosystem"/>
284 285
        <arg value="--eval"/>
        <arg value="(setf *load-verbose* t)"/>
286
      </java>
287 288 289
      <concat destfile="${system.lisp.file}" append="true">
        <fileset file="${abcl.startup.file}"/>
      </concat>
290 291 292 293 294 295
        </sequential>
    </macrodef>

    <property name="abcl.compile.lisp.debug.jvmarg"
              value="-agentlib:jdwp=transport=dt_socket,server=y,address=6789,suspend=y"/>
    <target name="abcl.compile.lisp.debug" 
296
            depends="abcl.stage,abcl.compile.java,abcl.system.update.maybe,abcl.fasls.uptodate"
297 298 299 300 301 302 303
            unless="abcl.fasls.uptodate.p">
      <echo>Debugging with jvmarg ${abcl.compile.lisp.debug.jvmarg}</echo>
      <abcl.compile.lisp> 
          <additional.jvmarg>
            <jvmarg value="${abcl.compile.lisp.debug.jvmarg}"/>
          </additional.jvmarg>
      </abcl.compile.lisp>
304 305
    </target>

306
    <property name="abcl.build.path"
307
              value="${build.classes.dir}/org/armedbear/lisp/build"/>
308 309
    <target name="abcl.stamp" 
            depends="abcl.compile,abcl.stamp.version,abcl.stamp.hostname">
310
      <mkdir dir="${abcl.build.path}/.."/>
311 312
      <loadfile property="abcl.version"
                srcFile="${abcl.version.path}"/>
313 314 315
      <echo message="${build}" file="${abcl.build.path}"/>    
    </target>

316 317 318 319 320 321 322 323 324 325

    <!-- Environment variables may be accessed as ${env.NAME} -->
    <property environment="env"/>

    <!-- Can we derive an SVN version from the current build tree? -->
    <condition property="abcl.version.svn.p">
      <and>
        <available
            file="${basedir}/.svn"
            type="dir"/>
326 327 328 329 330 331 332 333 334 335 336 337 338 339
        <or>
            <available
                file="svnversion.exe"
                filepath="${env.Path}"/>
            <available
                file="svnversion.exe"
                filepath="${env.PATH}"/>
             <available
                file="svnversion"
                filepath="${env.Path}"/>
            <available
                file="svnversion"
                filepath="${env.PATH}"/>
        </or>
340 341 342 343 344
      </and>
    </condition>

    <target name="abcl.version.src" depends="abcl.version.src.3"/>

345 346 347
    <target name="abcl.version.src.0" if="windows">
      <exec
          executable="svnversion.exe"
348
          outputproperty="abcl.version.svn.raw"
349 350 351 352 353
          failifexecutionfails="false"
          searchpath="true" />
    </target>

    <target name="abcl.version.src.1" depends="abcl.version.src.0">
354 355
      <exec 
          executable="svnversion"
356
          outputproperty="abcl.version.svn.raw"
357 358
          failifexecutionfails="false"
          searchpath="true" />
359 360 361 362 363
    </target>

    <target name="abcl.version.src.2" 
            depends="abcl.version.src.1"
            if="abcl.version.svn.p">
364 365 366 367 368 369 370 371 372 373

      <!-- Transform all occurances of ":" ==> "-" in the version string -->
      <tempfile property="version-tmp.path"/>
      <echo message="${abcl.version.svn.raw}"
            file="${version-tmp.path}"/>
      <replace file="${version-tmp.path}"
               token=":" value="-"/>
      <loadfile property="abcl.version.svn" srcFile="${version-tmp.path}"/>
      <delete file="${version-tmp.path}"/>

374 375 376 377 378 379 380 381 382 383 384 385
      <echo>abcl.version.svn: ${abcl.version.svn}</echo>
      <property name="abcl.version.src"
                value="svn-${abcl.version.svn}"/>
    </target>

    <target name="abcl.version.src.3"
            depends="abcl.version.src.2"
            unless="abcl.version.svn.p">
      <property name="abcl.version.src"
                value=""/>
    </target>

386 387
    <property name="abcl.home.dir"
              value="${src.dir}/org/armedbear/lisp/"/>
388
    <property name="abcl.version.path"
389
              value="${build.classes.dir}/org/armedbear/lisp/version"/>
390

391 392 393 394
    <target name="abcl.clean.version">
      <delete file="${abcl.version.path}"/>
    </target>

395 396 397 398 399 400
    <target name="abcl.stamp.version.uptodate">
      <uptodate property="abcl.stamp.version.uptodate.p" 
                targetfile="${abcl.version.path}"
                srcfile="${build.classes.dir}/org/armedbear/lisp/Version.class"/>
    </target>

401
    <target name="abcl.stamp.version" 
402 403
            depends="abcl.version.src,abcl.stamp.version.1,abcl.stamp.version.2"
            unless="abcl.stamp.version.uptodate.p">
404 405 406 407 408
      <mkdir dir="${abcl.version.path}/.."/>
      <echo>ABCL implementation version: ${abcl.implementation.version}</echo>
      <echo file="${abcl.version.path}">${abcl.implementation.version}</echo>
    </target>
    
409 410 411
    <target name="abcl.stamp.version.generate" 
            depends="abcl.compile.java"
            unless="abcl.stamp.version.uptodate.p">
412
      <java fork="true"
413 414 415
            classpath="${build.classes.dir}"
            outputproperty="abcl.version"
            classname="org.armedbear.lisp.Version"
416
            logerror="yes"/> <!-- Don't catch stderr output -->
417
    </target>
418

419
    <target name="abcl.stamp.version.0" 
420 421
            depends="abcl.stamp.version.uptodate,abcl.stamp.version.generate">
    </target>
422

423 424 425 426 427 428 429 430 431 432 433 434
    <target name="abcl.stamp.version.1"
            depends="abcl.stamp.version.0"
            unless="abcl.version.svn.p">
      <property name="abcl.implementation.version"
                value="${abcl.version}"/>
    </target>

    <target name="abcl.stamp.version.2" 
            depends="abcl.stamp.version.0"
            if="abcl.version.svn.p">
      <property name="abcl.implementation.version"
                value="${abcl.version}-${abcl.version.src}"/>
435 436 437 438 439 440 441
    </target>

    <target name="abcl.stamp.hostname" if="unix">
      <exec executable="hostname" outputproperty="abcl.hostname"/>
      <echo>abcl.hostname: ${abcl.hostname}</echo>
    </target>

442
    <target name="abcl.system.uptodate">
443 444 445 446 447
      <condition property="abcl.system.needs-update.p">
        <and>
          <available file="${system.lisp.file}"/>
          <available file="${abcl.startup.file}"/>
          <uptodate
448 449
                srcfile="${system.lisp.file}"
                targetfile="${abcl.startup.file}"/>
450 451
        </and>
      </condition>
452 453
    </target>
    
454 455
    <target name="abcl.system.update.maybe" depends="abcl.system.uptodate" 
            if="abcl.system.needs-update.p">
456 457 458
      <touch file="${src.dir}/org/armedbear/lisp/compile-system.lisp"/>
    </target>

459
    <target name="abcl.jar.uptodate" depends="abcl.compile,abcl.stamp">
460
      <uptodate property="abcl.jar.uptodate.p" targetfile="${abcl.jar.path}">
461 462 463
        <srcfiles dir="${build.classes.dir}">
          <patternset refid="abcl.objects"/>
        </srcfiles>
464 465 466
      </uptodate>
    </target>

467
    <target name="abcl.jar" depends="abcl.jar.uptodate,abcl-contrib.jar"
468
            unless="abcl.jar.uptodate.p">
469 470
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${abcl.jar.path}"
471
           compress="true"
472
           update="true"
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
           basedir="${build.classes.dir}">
        <patternset refid="abcl.objects"/>
        <manifest>
          <attribute name="Main-Class" value="org.armedbear.lisp.Main"/>
          <section name="org/armedbear/lisp">
            <attribute name="Implementation-Title" 
                       value="ABCL"/>
            <attribute name="Implementation-Version"  
                       value="${abcl.implementation.version}"/>
            <attribute name="Implementation-Build" 
                       value="${build}"/>
          </section>
        </manifest>
        <metainf dir="${src.dir}/META-INF"> 
          <exclude name="services/javax.script.ScriptEngineFactory"
                   unless="abcl.jsr-223.p"/>
        </metainf>
490 491 492 493
      </jar>
    </target>
    
    <target name="abcl.wrapper" 
494
            depends="abcl.jar,abcl.contrib,abcl.wrapper.unix,abcl.wrapper.windows">
495
      <description>
496
        Creates in-place executable shell wrapper in '${abcl.wrapper.file}'
497 498 499 500
      </description>
      <!-- Set from commandline or in 'build.properties' -->
      <property name="additional.jars" value=""/>
      <path id="abcl.runtime.classpath">
501
        <pathelement location="${abcl.runtime.jar.path}"/>
502
        <pathelement path="${additional.jars}"/>
503 504 505 506 507
      </path>
      <!-- set via '-Djava.options=JAVA_OPTIONS' or in 'build.properties -->
      <property name="java.options" value=""/>

      <copy file="${abcl.wrapper.in.file}" toFile="${abcl.wrapper.file}" overwrite="yes">
508 509 510 511 512 513 514 515
        <filterset>
          <filter token="JAVA" 
                  value="${java.path}"/>
          <filter token="ABCL_JAVA_OPTIONS" 
                  value="${java.options}"/>
          <filter token="ABCL_CLASSPATH"
                  value="${toString:abcl.runtime.classpath}"/>
        </filterset>
516 517
      </copy>
      <chmod file="${abcl.wrapper.file}" perm="a+x"/>
518 519

      <echo>Created executable ABCL wrapper in '${abcl.wrapper.file}'</echo>
520 521 522 523 524 525 526 527 528 529 530 531
      <echo>N.B. This wrapper requires '${abcl.jar.path}' not be moved.</echo>
    </target>

    <target name="abcl.wrapper.unix" if="unix">
      <property name="abcl.wrapper.file" value="abcl"/>
      <property name="abcl.wrapper.in.file" value="abcl.in"/>
    </target>

    <target name="abcl.wrapper.windows" if="windows">
      <property name="abcl.wrapper.file" value="abcl.bat"/>
      <property name="abcl.wrapper.in.file" value="abcl.bat.in"/>
    </target>
532

533 534 535 536 537 538
    <patternset id="abcl.contrib.source">
          <include name="**/*.asd"/>
          <include name="**/*.lisp"/>
          <include name="**/README.markdown"/>
    </patternset>

539 540 541 542
    <patternset id="abcl.contrib.docs">
          <include name="**/README.markdown"/>
    </patternset>

543 544 545 546 547
    <property name="abcl-contrib.jar"
              value="${dist.dir}/abcl-contrib.jar"/>
    <condition property="abcl.contrib.uptodate.p">
      <uptodate targetfile="${abcl-contrib.jar}">
        <srcfiles dir="contrib">
548
          <patternset refid="abcl.contrib.source"/>
549 550 551 552
        </srcfiles>
      </uptodate>
    </condition>

553
    <target name="abcl-contrib.jar" depends="abcl.contrib"/>
554 555
    <target name="abcl.contrib" unless="abcl.contrib.uptodate.p">
      <jar destfile="${abcl-contrib.jar}"
556 557
           compress="true"
           basedir="contrib">
558
        <patternset refid="abcl.contrib.source"/>
559 560
      </jar>
      <echo>
561 562
Packaged contribs in ${abcl-contrib.jar}. To use contribs, ensure that
this file is in the same directory as 'abcl.jar', and then
563 564

  CL-USER> (require 'abcl-contrib)
565

566
will place all the contribs in the ASDF registry. 
567

568
To load a contrib, something like
569

570
  CL-USER> (require 'jss) 
571

572
will compile (if necessary) and load JSS.
573 574
</echo>
    </target>
575

576 577 578 579 580 581 582 583 584 585 586 587 588 589
    <target name="abcl.contrib.javadoc.jar">
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-contrib-javadoc.jar" basedir="contrib">
        <patternset refid="abcl.contrib.docs" />
      </jar>
    </target>

    <target name="abcl.contrib.source.jar">
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-contrib-sources.jar" basedir="contrib">
        <patternset refid="abcl.contrib.source" />
      </jar>
    </target>

590 591 592
    <target name="abcl.debug.jpda" depends="abcl.jar">
      <description>Invoke ABCL with JPDA listener on port 6789</description>
      <java fork="true"
593 594 595 596
            classpathref="abcl.classpath.dist"
            classname="org.armedbear.lisp.Main">
        <jvmarg 
            value="-agentlib:jdwp=transport=dt_socket,address=6789,server=y"/>
597
      </java>
598
      <echo>JPDA listening on localhost:6789</echo>
599 600
    </target>

601 602 603
    <target name="abcl.build.debug.jpda" depends="abcl.compile.java">
      <description>Invoke ABCL with JPDA listener on port 6789</description>
      <java fork="true"
604 605 606 607
            classpathref="abcl.classpath.build"
            classname="org.armedbear.lisp.Main">
        <jvmarg
            value="-agentlib:jdwp=transport=dt_socket,address=6789,server=y"/>
608 609 610 611 612
        <jvmarg value="-Dabcl.home=${abcl.home.dir}${file.separator}"/>
      </java>
      <echo>JPDA listening on localhost:6789</echo>
    </target>

613 614
    <target name="abcl.run" depends="abcl.jar">
      <java fork="true"
615 616
            classpathref="abcl.classpath.dist"
            classname="org.armedbear.lisp.Main">
617 618 619
      </java>
    </target>

620 621
    <target name="abcl.clean">
      <delete dir="${build.dir}"/>
622
      <delete file="${abcl.jar.path}"/>
623
      <delete file="abcl"/>
624
      <delete file="abcl.bat"/>
625 626
    </target>

627 628 629 630 631 632 633 634
    <property name="slime.fasls" 
              value="${user.home}/.slime/"/>
    <property name="quicklisp.common-lisp.fasls"
              value="${user.home}/.cache/common-lisp/"/>
    <target name="abcl.clean.application.fasls">
      <echo>WARNING:  This target is removing local application inter-Lisp fasls, forcing recompilation.
      </echo>
      <echo>Deleting local SLIME fasls under ${slime.fasls}</echo>
635
      <delete dir="${slime.fasls}"/>
636 637 638 639
      <echo>Deleting local Quicklisp fasls under ${quicklisp.common-lisp.fasls}</echo>
      <delete dir="${quicklisp.common-lisp.fasls}"/>
    </target>

640 641
    <target name="abcl.dist" depends="abcl.jar">
      <copy file="${abcl.jar.path}"
642
            toFile="${dist.dir}/abcl-${abcl.version}.jar"/>
643 644 645 646 647
    </target>

    <target name="abcl.distclean" depends="abcl.clean">
      <delete dir="${dist.dir}"/>
      <delete file="abcl"/>
648
      <delete file="abcl.bat"/>
649 650 651
    </target>

    <target name="TAGS">
652 653 654
      <delete file="TAGS"/>
      <apply executable="etags" parallel="true" verbose="true" maxparallel="300">
        <arg value="--append"/>
655
        <arg value="--regex=|[ \t]+//[ \t]+###[ \t]+\([^ \t]+\)|\1|"/>
656
        <arg value='--regex=|[ \t]*@DocString([ \n\r\t]*name=\"\([^\"]*\)|\1|m'/>
657 658 659 660
        <fileset dir="${src.dir}">
          <patternset refid="abcl.source.java"/>
          <patternset refid="abcl.source.lisp"/>
        </fileset>
661 662 663 664
      </apply>
    </target>

    <patternset id="abcl.dist.misc"
665
                description="Additional includes in the source distributions relative to basedir">
666
      <include name="abcl.rdf"/>
667
      <include name="build.xml"/>
668
      <include name="abcl.properties.in"/>
669 670
      <include name="COPYING"/>
      <include name="README"/>
671
      <include name="CHANGES"/>
672 673
      <include name="abcl.in"/>
      <include name="abcl.bat.in"/>
674 675

      <include name="abcl.asd"/>
676
      
677
      <include name="examples/**"/>
678 679

      <include name="contrib/**"/>
680 681
      
      <include name="test/**"/>
682

683
      <include name="build-from-lisp.bash"/>
684
      
685 686 687
      <!-- The remainder of these files are used by the Lisp hosted
           build in 'build-abcl.lisp' but not used by Ant, so include
           them in the source distribution. -->
688 689 690 691 692 693 694 695
      <include name="make-jar.in"/>
      <include name="make-jar.bat.in"/>

      <include name="build-abcl.lisp"/>
      <include name="customizations.lisp.in"/>

    </patternset>

696 697 698
    <patternset 
        id="abcl.source.misc"
        description="Additional includes in the source distribution relative to source root">
699 700
      <include name="org/armedbear/lisp/LICENSE"/>
      <include name="manifest-abcl"/>
701
      <include name="META-INF/services/javax.script.ScriptEngineFactory"/>
702
    </patternset>
703

704 705
    <target name="abcl.source.prepare" depends="abcl.stamp.version">
      <property name="abcl.build.src.dir"
706
                value="${build.dir}/abcl-src-${abcl.version}"/>
707
      <mkdir dir="${abcl.build.src.dir}/src"/>
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722
      <copy todir="${abcl.build.src.dir}/src"
            preservelastmodified="true">
        <fileset dir="${src.dir}"
                 id="abcl.source.src">
            <patternset refid="abcl.source.java"/>
            <patternset refid="abcl.source.lisp"/>
            <patternset refid="abcl.source.misc"/>
        </fileset>
      </copy>
      <copy todir="${abcl.build.src.dir}"
            preservelastmodified="true">
        <fileset dir="${basedir}">
            <patternset refid="abcl.dist.misc"/>
        </fileset>
      </copy>
723 724
    </target>

725 726
    <!--  Files in source distribution that always get LF EOL (aka
         'unix') -->    
727
    <patternset id="abcl.dist.lf">
728 729 730 731 732 733 734 735 736
      <include name="abcl.in"/>
    </patternset>

    <!--  Files in source distribution that always get CRLF EOL (aka
         'dos') -->    
    <patternset id="abcl.dist.crlf">
      <include name="abcl.bat.in"/>
    </patternset>

737
    <target name="abcl.source.unix" depends="abcl.source.prepare">
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753
      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="lf">
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="crlf">
          <patternset refid="abcl.dist.crlf"/>
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="lf">
          <patternset refid="abcl.dist.lf"/>
      </fixcrlf>
754
    </target>
755

756
    <target name="abcl.source.tar" depends="abcl.source.unix">
757 758
      <mkdir dir="${dist.dir}"/>
      <tar destfile="${dist.dir}/abcl-src-${abcl.version}.tar.gz"
759 760 761 762
           compression="gzip">
        <tarfileset dir="${build.dir}">
          <include name="abcl-src-${abcl.version}/**"/>
        </tarfileset>
763 764 765
      </tar>
    </target>

766
    <target name="abcl.source.windows" depends="abcl.source.prepare">
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="crlf">
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="crlf">
          <patternset refid="abcl.dist.crlf"/>
      </fixcrlf>

      <fixcrlf srcdir="${abcl.build.src.dir}"
               preservelastmodified="true"
               eol="lf">
          <patternset refid="abcl.dist.lf"/>
      </fixcrlf>
783
    </target>
784

785
    <target name="abcl.source.zip" depends="abcl.source.windows">
786 787
      <mkdir dir="${dist.dir}"/>
      <zip destfile="${dist.dir}/abcl-src-${abcl.version}.zip"
788 789
           compress="true">
        <zipfileset dir="${abcl.build.src.dir}" prefix="abcl-src-${abcl.version}"/>
790 791
      </zip>
    </target>
792 793 794 795 796 797 798 799 800 801 802 803 804 805

    <target name="abcl.source.jar" depends="abcl.source.unix">
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-${abcl.version}-sources.jar">
        <metainf dir="${abcl.build.src.dir}">
          <include name="COPYING"/>
        </metainf>
        <fileset dir="${abcl.build.src.dir}/src">
          <include name="**/*.java"/>
          <include name="**/*.lisp"/>
        </fileset>
      </jar>
    </target>

806 807 808 809 810 811 812 813 814 815 816 817 818 819 820
    <property name="abcl.javadoc.dir" value="${build.dir}/javadoc"/>

    <target name="abcl.javadoc">
      <mkdir dir="${abcl.javadoc.dir}"/>
      <javadoc destdir="${abcl.javadoc.dir}"
               sourcepath="${src.dir}"/>
    </target>
    
    <target name="abcl.javadoc.jar" depends="abcl.stamp.version,abcl.javadoc">
      <mkdir dir="${dist.dir}"/>
      <jar destfile="${dist.dir}/abcl-${abcl.version}-javadoc.jar">
        <fileset dir="${abcl.javadoc.dir}"/>
      </jar>
    </target>

821
    <target name="abcl.binary.prepare" depends="abcl.jar,abcl.contrib,abcl.documentation,abcl.stamp.version">
822 823 824 825 826 827 828 829
      <property name="abcl.build.binary.dir"
                value="${build.dir}/abcl-bin-${abcl.version}"/>
      <mkdir dir="${abcl.build.binary.dir}"/>
      <copy todir="${abcl.build.binary.dir}"
            preservelastmodified="true">
        <fileset dir="${basedir}/dist">
          <patternset>
            <include name="abcl.jar"/>
830
            <include name="abcl-contrib.jar"/>
831
            <include name="*.pdf"/>
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
          </patternset>
        </fileset>
        <fileset dir="${basedir}">
          <patternset>
            <include name="README"/>
            <include name="CHANGES"/>
          </patternset>
        </fileset>
      </copy>
    </target>

    <target name="abcl.binary.tar" depends="abcl.binary.prepare">
      <tar destfile="${dist.dir}/abcl-bin-${abcl.version}.tar.gz"
           compression="gzip">
        <tarfileset dir="${build.dir}">
          <include name="abcl-bin-${abcl.version}/**"/>
          </tarfileset>
      </tar>
    </target>

    <target name="abcl.binary.zip" depends="abcl.binary.prepare">
      <zip destfile="${dist.dir}/abcl-bin-${abcl.version}.zip"
           compress="true">
        <zipfileset dir="${abcl.build.binary.dir}" prefix="abcl-bin-${abcl.version}"/>
      </zip>
    </target>
858

859 860 861 862 863 864 865
    <target name="help.test">
      <echo>
The following Ant targets run various test suites:
  
  abcl.test
    --  Run all available tests.
  abcl.test.java
866
    --  Run the ABCL junit Java tests under ${basedir}/test/src/
867 868 869 870 871
  abcl.test.lisp
    --  Run the 'test.ansi.compiled', 'test.abcl', 'test.cl-bench' targets
  test.ansi.compiled
    --  Run the compiled version of the ANSI test suite
  test.abcl
872
    --  Run the Lisp RT tests collected in ${basedir}/test/lisp/abcl/
873 874 875 876 877 878
  test.cl-bench 
    --  Run the cl-bench test suite.

The ANSI tests require that the [ansi-tests][1] be manually installed in 
${basedir}/../ansi-tests.

879
[1]: git+https://gitlab.common-lisp.net/ansi-test/ansi-test.git
880

881
The CL-BENCH tests require that [cl-bench][2] be manually installed in
882 883 884 885 886 887
${basedir}/../cl-bench

[2]: http://www.chez.com/emarsden/downloads/cl-bench.tar.gz
      </echo>
    </target>

888
    <property name="abcl.test.classes.dir"
889
              value="${build.dir}/classes-test"/>
890 891

    <property name="abcl.test.src.dir"
892
              value="${basedir}/test/src"/>
893 894

    <patternset id="abcl.test.source.java">
895
      <include name="org/armedbear/lisp/**/*.java"/>
896 897
    </patternset>

898
    <property name="junit.path"
899
              value="${abcl.ext.dir}/junit-4.8.1.jar"/>
900

901 902

    <path id="abcl.test.compile.classpath">
903
      <pathelement location="${junit.path}"/>
904 905 906
      <pathelement location="${build.classes.dir}"/>
    </path>

907 908 909
    <target name="abcl.test.pre-compile" depends="abcl.ext"/>

    <target name="abcl.ext.p">
910 911
      <!--XXX generalize over enumeration of all contributions to
           abcl.ext if we get more of them.  -->
912
      <available file="${junit.path}" property="abcl.ext.p"/>
913 914 915
    </target>
    <target name="abcl.ext" depends="abcl.ext.p" unless="abcl.ext.p">

916
      <mkdir dir="${abcl.ext.dir}"/>
917 918 919 920
      <get 
          src="http://cloud.github.com/downloads/KentBeck/junit/junit-4.8.1.jar"
          usetimestamp="true"
          dest="${junit.path}"/>
921
    </target>
922
        
923
    <target name="abcl.test.compile" 
924
            depends="abcl.test.pre-compile">
925 926
      <mkdir dir="${abcl.test.classes.dir}"/>
      <javac destdir="${abcl.test.classes.dir}"
927 928 929 930 931
             classpathref="abcl.test.compile.classpath"
             debug="true"
             target="1.5">
        <src path="${abcl.test.src.dir}"/>
        <patternset refid="abcl.test.source.java"/>
932 933 934 935 936 937 938
      </javac>
    </target>

    <path id="abcl.test.run.classpath">
      <path refid="abcl.test.compile.classpath"/>
      <pathelement location="${abcl.test.classes.dir}"/>
    </path>
939

940
    <target name="abcl.test" 
941 942
            depends="abcl.test.java,abcl.test.lisp"/>
        
943 944
    <target name="abcl.test.java" depends="abcl.test.compile">
      <java fork="true"
945 946
            classpathref="abcl.test.run.classpath"
            classname="org.junit.runner.JUnitCore">
947 948
        <arg value="org.armedbear.lisp.PathnameTest"/>
        <arg value="org.armedbear.lisp.StreamTest"/>
949
        <arg value="org.armedbear.lisp.SeekableStringWriterTest"/>
950
        <arg value="org.armedbear.lisp.UtilitiesTest"/>