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.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!/bin/sh
  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. # OS specific support. $var _must_ be set to either true or false.
  17. cygwin=false;
  18. darwin=false;
  19. case "`uname`" in
  20. CYGWIN*) cygwin=true ;;
  21. Darwin*) darwin=true
  22. if [ -z "$JAVA_HOME" ] ; then
  23. JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
  24. fi
  25. ;;
  26. esac
  27. # For Cygwin, ensure paths are in UNIX format before anything is touched
  28. if $cygwin ; then
  29. [ -n "$JAVA_HOME" ] &&
  30. JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  31. [ -n "$CLASSPATH" ] &&
  32. CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
  33. fi
  34. # You will need to specify JAVA_HOME if compiling with 1.2 or later.
  35. if [ -n "$JAVA_HOME" ] ; then
  36. if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
  37. CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar
  38. fi
  39. if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
  40. CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/classes.zip
  41. fi
  42. else
  43. echo "Warning: JAVA_HOME environment variable not set."
  44. echo " If build fails because sun.* classes could not be found"
  45. echo " you will need to set the JAVA_HOME environment variable"
  46. echo " to the installation directory of java."
  47. fi
  48. # IBM's JDK on AIX uses strange locations for the executables:
  49. # JAVA_HOME/jre/sh for java and rmid
  50. # JAVA_HOME/sh for javac and rmic
  51. if [ -z "$JAVAC" ] ; then
  52. if [ -n "$JAVA_HOME" ] ; then
  53. if [ -x "$JAVA_HOME/sh/javac" ] ; then
  54. JAVAC=${JAVA_HOME}/sh/javac;
  55. else
  56. JAVAC=${JAVA_HOME}/bin/javac;
  57. fi
  58. else
  59. JAVAC=javac
  60. fi
  61. fi
  62. if [ -z "$JAVACMD" ] ; then
  63. if [ -n "$JAVA_HOME" ] ; then
  64. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  65. JAVACMD=$JAVA_HOME/jre/sh/java
  66. else
  67. JAVACMD=$JAVA_HOME/bin/java
  68. fi
  69. else
  70. JAVACMD=java
  71. fi
  72. fi
  73. if [ ! -x "$JAVACMD" ] ; then
  74. echo "Error: JAVA_HOME is not defined correctly."
  75. echo " We cannot execute $JAVACMD"
  76. exit
  77. fi
  78. ANT_HOME=.
  79. export ANT_HOME
  80. echo ... Bootstrapping Ant Distribution
  81. if [ -d "bootstrap" ] ; then
  82. rm -r bootstrap
  83. fi
  84. if [ -d "build" ] ; then
  85. rm -r build
  86. fi
  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/property/*.java \
  112. ${TOOLS}/ant/types/*.java \
  113. ${TOOLS}/ant/types/resources/*.java \
  114. ${TOOLS}/ant/*.java ${TOOLS}/ant/taskdefs/*.java \
  115. ${TOOLS}/ant/taskdefs/compilers/*.java \
  116. ${TOOLS}/ant/taskdefs/condition/*.java
  117. ret=$?
  118. if [ $ret != 0 ]; then
  119. echo ... Failed compiling Ant classes !
  120. exit $ret
  121. fi
  122. echo ... Copying Required Files
  123. cp src/main/org/apache/tools/ant/taskdefs/defaults.properties \
  124. ${CLASSDIR}/org/apache/tools/ant/taskdefs
  125. cp src/main/org/apache/tools/ant/types/defaults.properties \
  126. ${CLASSDIR}/org/apache/tools/ant/types
  127. cp src/script/antRun bin
  128. chmod +x bin/antRun
  129. echo ... Building Ant Distribution
  130. "${JAVACMD}" -classpath "${CLASSPATH}" -Dant.home=. $ANT_OPTS org.apache.tools.ant.Main -emacs "$@" bootstrap
  131. ret=$?
  132. if [ $ret != 0 ]; then
  133. echo ... Failed Building Ant Distribution !
  134. exit $ret
  135. fi
  136. echo ... Cleaning Up Build Directories
  137. rm -rf ${CLASSDIR}
  138. rm -rf bin
  139. echo ... Done Bootstrapping Ant Distribution