mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

306 lines
10 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/scripts/Build-Tools
  11. # ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. config=default
  25. stagelevel=9
  26. cleanup=0
  27. while [ "$1" ] ; do
  28. case "$1" in
  29. -cleanup) cleanup=1 ; shift ;;
  30. -cfg) config=$2 ; shift ; shift ;;
  31. -[0-9]) options="$options $1" ; stagelevel=${1#-} ; shift ;;
  32. *) echo "Usage: $0 [ -cfg config ] [ -0 | -9 ] \\"
  33. echo " ${0//?/ } [ -cleanup ]" ; exit 1 ;;
  34. esac
  35. done
  36. . ./scripts/parse-config
  37. . ./scripts/functions
  38. var_remove PATH ":" $base/build/$ROCKCFG_ID/ROCK/$toolsdir/bin
  39. var_remove PATH ":" $base/build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper
  40. mkdir -p build/$ROCKCFG_ID/ROCK/$toolsdir/bin
  41. mkdir -p build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper
  42. mkdir -p build/$ROCKCFG_ID/ROCK/$toolsdir/lib
  43. if [ $toolsdir = tools.cross ]; then
  44. mkdir -p build/$ROCKCFG_ID/ROCK/$toolsdir/{var/adm,etc,share,include}
  45. [ -L build/$ROCKCFG_ID/ROCK/$toolsdir/usr ] ||
  46. ln -s . build/$ROCKCFG_ID/ROCK/$toolsdir/usr
  47. [ -L build/$ROCKCFG_ID/ROCK/$toolsdir/sbin ] ||
  48. ln -s bin build/$ROCKCFG_ID/ROCK/$toolsdir/sbin
  49. [ -L build/$ROCKCFG_ID/ROCK/$toolsdir/var/adm/logs ] ||
  50. ln -s ../../../../var/adm/logs \
  51. build/$ROCKCFG_ID/ROCK/$toolsdir/var/adm/logs
  52. mkdir -p build/$ROCKCFG_ID/var/adm/logs
  53. fi
  54. x="$( bash scripts/xfind.sh config/$config/. package/. scripts/. \
  55. misc/. architecture/. target/. ! -name '*.cache' \
  56. -newer build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate \
  57. -printf 'Found new/updated file: %p\n' 2> /dev/null )"
  58. if [ "$x" ] ; then
  59. echo_header Found $( echo "$x" | wc -l ) new/updated \
  60. files in source tree:
  61. echo "$x" | head -n 3 | sed 's,/\./,/,g' |
  62. while read y ; do echo_status $y ; done
  63. [ "$( echo "$x" | tail -n +4 )" ] &&
  64. echo_status "** list truncated to save space on the terminal **"
  65. if [ "$ROCK_DEBUG_TOOLS_SKIP" = 1 ]; then
  66. echo_error "Found \$ROCK_DEBUG_TOOLS_SKIP ..."
  67. else
  68. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate
  69. if echo "$x" | grep -qv " config/$config/" ; then
  70. echo_header Re-running configuration:
  71. while read line ; do
  72. echo_status $line
  73. done < <( ./scripts/Config -cfg $config -oldconfig )
  74. fi
  75. fi
  76. fi
  77. if [ $cleanup = 1 ] ; then
  78. echo_header "Removing old stuff in $toolsdir/ directory ..."
  79. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/*
  80. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/bin/getdu
  81. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/bin/getfiles
  82. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/bin/fl_wrparse
  83. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/bin/fl_stparse
  84. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/lib/fl_wrapper.so
  85. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config
  86. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config-fixarch
  87. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate
  88. fi
  89. if [ ! -f build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate ] ; then
  90. echo_header "Building tools in build/.../ROCK/$toolsdir:"
  91. # CC, CXX, F77 and KCC Wrapper
  92. #
  93. wrappers="cmd_wrapper" ; wrappervars=""
  94. echo_status "Building $toolsdir/wrapper/cmd_wrapper."
  95. $BUILDCC -Wall -O2 misc/tools-source/cmd_wrapper.c \
  96. -DENVPREFIX='"CMD"' -DMYNAME='"cmd_wrapper"' \
  97. -o build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/tmp.$$ || exit 1
  98. mv build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/tmp.$$ \
  99. build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/cmd_wrapper
  100. #
  101. build_wrapper() {
  102. local x="$( echo ${1//,/ } )" y z
  103. wrappervars="$wrappervars $x"
  104. while shift ; [ $# != 0 ]
  105. do
  106. wrappers="$wrappers $1"
  107. tmp=`mktemp -p build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper`
  108. {
  109. echo '#!/bin/bash'
  110. for y in $x ; do
  111. echo -n "[ \"\$${y}_WRAPPER_DEBUG\" = 1 ] && "
  112. echo "export CMD_WRAPPER_DEBUG=1"
  113. done
  114. for y in $x ; do
  115. echo -n "[ \"\$${y}_WRAPPER_BYPASS\" = 1 ] && "
  116. echo "export CMD_WRAPPER_BYPASS=1"
  117. done
  118. z=""; echo -n 'export CMD_WRAPPER_APPEND_PO="'
  119. for y in $x; do
  120. echo -n "${z}\$${y}_WRAPPER_APPEND_PO"; z=" "
  121. done ; echo '"'
  122. z=""; echo -n 'export CMD_WRAPPER_OTHERS="'
  123. for y in $x; do
  124. echo -n "${z}\$${y}_WRAPPER_OTHERS"; z=":"
  125. done ; echo '"'
  126. z=""; echo -n 'export CMD_WRAPPER_INSERT="'
  127. for y in $x; do
  128. echo -n "${z}\$${y}_WRAPPER_INSERT"; z=" "
  129. done ; echo '"'
  130. z=""; echo -n 'export CMD_WRAPPER_REMOVE="'
  131. for y in $x; do
  132. echo -n "${z}\$${y}_WRAPPER_REMOVE"; z=" "
  133. done ; echo '"'
  134. z=""; echo -n 'export CMD_WRAPPER_APPEND="'
  135. for y in $x; do
  136. echo -n "${z}\$${y}_WRAPPER_APPEND"; z=" "
  137. done ; echo '"'
  138. z=""; echo -n 'export CMD_WRAPPER_FILTER="'
  139. for y in $x; do
  140. echo -n "${z}\$${y}_WRAPPER_FILTER"; z="|"
  141. done ; echo '"'
  142. echo 'exec cmd_wrapper $( basename $0 ) "$@"'
  143. } > $tmp
  144. chmod +rx $tmp
  145. mv $tmp "build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/$1"
  146. done
  147. }
  148. #
  149. while read script ; do . $script
  150. done < <( bash scripts/xfind.sh package/. target/$target/. misc/. -name 'wrappers.in' )
  151. #
  152. echo_status "Building $toolsdir/wrapper/strip_wrapper."
  153. cat << 'EOT' > build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/strip_wrapper.$$
  154. #!/bin/sh
  155. if [ "$STRIP_WRAPPER_NOLOOP" = 1 ] ; then
  156. echo "Aaaaaeik! Strip wrapper is looping!" >&2
  157. exit 1
  158. fi
  159. if [ "$ROCKCFG_DEBUG" = 0 ] ; then
  160. PATH=${PATH//$STRIP_WRAPPER_MYPATH:/}
  161. export STRIP_WRAPPER_NOLOOP=1
  162. exec "`basename $0`" "$@"
  163. fi
  164. exit 0
  165. EOT
  166. chmod +x build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/strip_wrapper.$$
  167. mv build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/strip_wrapper.$$ \
  168. build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/strip_wrapper
  169. wrappers="$wrappers strip_wrapper"
  170. #
  171. for x in strip $arch_target-strip ; do
  172. [ $crossnative = cross -a $x = strip ] && continue
  173. if [ -x "`type -p $x`" ] ; then
  174. ln -sf strip_wrapper \
  175. build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/$x
  176. wrappers="$wrappers $x"
  177. fi
  178. done
  179. #
  180. echo_status "Building $toolsdir/wrapper/install_wrapper."
  181. cp misc/tools-source/install_wrapper.sh build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/install_wrapper
  182. chmod +x build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/install_wrapper
  183. ln -sf install_wrapper build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/install
  184. ln -sf install_wrapper build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/cp
  185. ln -sf install_wrapper build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/ln
  186. ln -sf install_wrapper build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/mv
  187. wrappers="$wrappers install_wrapper install cp ln mv"
  188. #
  189. for x in $( ls build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/ )
  190. do
  191. z=0
  192. for y in $wrappers ; do
  193. [ "$x" = "$y" ] && z=1
  194. done
  195. if [ "$z" = 0 ] ; then
  196. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/wrapper/$x
  197. fi
  198. done
  199. # Various small tools
  200. #
  201. for x in getdu getfiles fl_wrparse fl_stparse descparser; do
  202. echo_status "Building $toolsdir/bin/$x."
  203. $BUILDCC -Wall -O2 misc/tools-source/$x.c \
  204. -o build/$ROCKCFG_ID/ROCK/$toolsdir/bin/$x.$$ || exit 1
  205. mv build/$ROCKCFG_ID/ROCK/$toolsdir/bin/$x.$$ \
  206. build/$ROCKCFG_ID/ROCK/$toolsdir/bin/$x
  207. done
  208. # Flist Wrapper Library
  209. #
  210. if [ "$ROCKCFG_FLIST" = "flwrapper" ] ; then
  211. echo_status "Building $toolsdir/lib/fl_wrapper.so."
  212. $BUILDCC -Wall -O2 -ldl -shared misc/tools-source/fl_wrapper.c \
  213. -o build/$ROCKCFG_ID/ROCK/$toolsdir/lib/fl_wrapper.so.$$ || exit 1
  214. mv build/$ROCKCFG_ID/ROCK/$toolsdir/lib/fl_wrapper.so.$$ \
  215. build/$ROCKCFG_ID/ROCK/$toolsdir/lib/fl_wrapper.so
  216. echo_status "Testing $toolsdir/lib/fl_wrapper.so."
  217. if ! sh -c "LD_PRELOAD=\"\$LD_PRELOAD:build/\$ROCKCFG_ID/`
  218. `$toolsdir/lib/fl_wrapper.so\" date ; `
  219. `exit $?" >/dev/null 2>&1
  220. then
  221. echo_error "Detected a problem with the flist" \
  222. "wrapper lib on your system."
  223. echo_error "Please specify another flist-creation" \
  224. "system in your build configuration."
  225. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/lib/fl_wrapper.so
  226. echo ; exit 1
  227. fi
  228. fi
  229. # Create Parse-Config Collection
  230. #
  231. echo_status "Creating $toolsdir/lib/parse-config."
  232. bash scripts/xfind.sh \
  233. architecture/$arch/. package/. target/$target/. misc/ -type f \
  234. '(' -name 'parse-config' -o -name 'parse-config-*' ')' \
  235. '(' ! -name 'parse-config-x' -o ! -name 'parse-config-*-x' ')' \
  236. '(' ! -name '*~' ')' \
  237. -printf '%f\t%p\n' | sort | awk '{ $1="."; print; }' \
  238. > build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config.$$
  239. mv build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config.$$ \
  240. build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config
  241. bash scripts/xfind.sh \
  242. architecture/$arch/. package/. target/$target/. misc/ -type f \
  243. -name 'parse-config-fixarch' \
  244. -printf '%f\t%p\n' | sort | awk '{ $1="."; print; }' \
  245. > build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config-fixarch.$$
  246. mv build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config-fixarch.$$ \
  247. build/$ROCKCFG_ID/ROCK/$toolsdir/lib/parse-config-fixarch
  248. # Create pkg_*_{pre,post}.conf files
  249. #
  250. rm -f build/$ROCKCFG_ID/ROCK/$toolsdir/lib/pkg_*_{pre,post}.conf
  251. echo_status "Creating $toolsdir/lib/pkg_*_{pre,post}.conf"
  252. for x in `grep "^X" config/$config/packages | cut -d ' ' -f 4,5 | tr ' ' '/'`; do
  253. for y in `echo package/$x/pkg_*_{pre,post}.conf`; do
  254. if [ -f $y ]; then
  255. echo " . $y" >> build/$ROCKCFG_ID/ROCK/$toolsdir/lib/${y##*/}
  256. fi
  257. done
  258. done
  259. echo -e "${wrappervars// /\n}" | grep . | sort -u |
  260. while read x ; do
  261. echo "export ${x}_WRAPPER_DEBUG=0 ${x}_WRAPPER_BYPASS=0"
  262. echo "export ${x}_WRAPPER_OTHERS='' ${x}_WRAPPER_REMOVE=''"
  263. echo "export ${x}_WRAPPER_INSERT='' ${x}_WRAPPER_APPEND=''"
  264. echo "export ${x}_WRAPPER_FILTER='' ${x}_WRAPPER_APPEND_PO=''"
  265. done > build/$ROCKCFG_ID/ROCK/$toolsdir/lib/wrapper-config.$$
  266. mv build/$ROCKCFG_ID/ROCK/$toolsdir/lib/wrapper-config.$$ \
  267. build/$ROCKCFG_ID/ROCK/$toolsdir/lib/wrapper-config
  268. touch build/$ROCKCFG_ID/ROCK/$toolsdir/.lastupdate
  269. fi
  270. exit 0