You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

bootstrap.sh 4.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #!/bin/sh
  2. # Copyright 2000-2004 The Apache Software Foundation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # OS specific support. $var _must_ be set to either true or false.
  16. cygwin=false;
  17. darwin=false;
  18. case "`uname`" in
  19. CYGWIN*) cygwin=true ;;
  20. Darwin*) darwin=true
  21. if [ -z "$JAVA_HOME" ] ; then
  22. JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
  23. fi
  24. ;;
  25. esac
  26. # For Cygwin, ensure paths are in UNIX format before anything is touched
  27. if $cygwin ; then
  28. [ -n "$JAVA_HOME" ] &&
  29. JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  30. [ -n "$CLASSPATH" ] &&
  31. CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  32. fi
  33. # You will need to specify JAVA_HOME if compiling with 1.2 or later.
  34. if [ -n "$JAVA_HOME" ] ; then
  35. if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
  36. CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
  37. fi
  38. if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
  39. CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/classes.zip
  40. fi
  41. else
  42. echo "Warning: JAVA_HOME environment variable not set."
  43. echo " If build fails because sun.* classes could not be found"
  44. echo " you will need to set the JAVA_HOME environment variable"
  45. echo " to the installation directory of java."
  46. fi
  47. # IBM's JDK on AIX uses strange locations for the executables:
  48. # JAVA_HOME/jre/sh for java and rmid
  49. # JAVA_HOME/sh for javac and rmic
  50. if [ -z "$JAVAC" ] ; then
  51. if [ -n "$JAVA_HOME" ] ; then
  52. if [ -x "$JAVA_HOME/sh/javac" ] ; then
  53. JAVAC=${JAVA_HOME}/sh/javac;
  54. else
  55. JAVAC=${JAVA_HOME}/bin/javac;
  56. fi
  57. else
  58. JAVAC=javac
  59. fi
  60. fi
  61. if [ -z "$JAVACMD" ] ; then
  62. if [ -n "$JAVA_HOME" ] ; then
  63. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  64. JAVACMD=$JAVA_HOME/jre/sh/java
  65. else
  66. JAVACMD=$JAVA_HOME/bin/java
  67. fi
  68. else
  69. JAVACMD=java
  70. fi
  71. fi
  72. if [ ! -x "$JAVACMD" ] ; then
  73. echo "Error: JAVA_HOME is not defined correctly."
  74. echo " We cannot execute $JAVACMD"
  75. exit
  76. fi
  77. ANT_HOME=.
  78. export ANT_HOME
  79. echo ... Bootstrapping Ant Distribution
  80. if [ -d "bootstrap" ] ; then
  81. rm -r bootstrap
  82. fi
  83. if [ -d "build" ] ; then
  84. rm -r build
  85. fi
  86. CLASSPATH=lib/xercesImpl.jar:lib/xml-apis.jar:${CLASSPATH}
  87. DIRLIBS=lib/optional/*.jar
  88. for i in ${DIRLIBS}
  89. do
  90. # if the directory is empty, then it will return the input string
  91. # this is stupid, so case for it
  92. if [ "$i" != "${DIRLIBS}" ] ; then
  93. CLASSPATH=$CLASSPATH:"$i"
  94. fi
  95. done
  96. TOOLS=src/main/org/apache/tools
  97. CLASSDIR=build/classes
  98. CLASSPATH=${CLASSDIR}:src/main:${CLASSPATH}
  99. # For Cygwin, switch to Windows format before running java
  100. if $cygwin; then
  101. CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
  102. fi
  103. export CLASSPATH
  104. mkdir -p build
  105. mkdir -p ${CLASSDIR}
  106. mkdir -p bin
  107. echo ... Compiling Ant Classes
  108. "${JAVAC}" $BOOTJAVAC_OPTS -d ${CLASSDIR} ${TOOLS}/bzip2/*.java ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \
  109. ${TOOLS}/ant/util/regexp/RegexpMatcher.java \
  110. ${TOOLS}/ant/util/regexp/RegexpMatcherFactory.java \
  111. ${TOOLS}/ant/types/*.java \
  112. ${TOOLS}/ant/*.java ${TOOLS}/ant/taskdefs/*.java \
  113. ${TOOLS}/ant/taskdefs/compilers/*.java \
  114. ${TOOLS}/ant/taskdefs/condition/*.java
  115. ret=$?
  116. if [ $ret != 0 ]; then
  117. echo ... Failed compiling Ant classes !
  118. exit $ret
  119. fi
  120. echo ... Copying Required Files
  121. cp src/main/org/apache/tools/ant/taskdefs/defaults.properties \
  122. ${CLASSDIR}/org/apache/tools/ant/taskdefs
  123. cp src/main/org/apache/tools/ant/types/defaults.properties \
  124. ${CLASSDIR}/org/apache/tools/ant/types
  125. cp src/script/antRun bin
  126. chmod +x bin/antRun
  127. echo ... Building Ant Distribution
  128. "${JAVACMD}" -classpath "${CLASSPATH}" -Dant.home=. $ANT_OPTS org.apache.tools.ant.Main -emacs "$@" bootstrap
  129. ret=$?
  130. if [ $ret != 0 ]; then
  131. echo ... Failed Building Ant Distribution !
  132. exit $ret
  133. fi
  134. echo ... Cleaning Up Build Directories
  135. rm -rf ${CLASSDIR}
  136. rm -rf bin
  137. echo ... Done Bootstrapping Ant Distribution