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.

697 lines
18 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/scripts/functions
  9. # ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. # This function returns a "uniqe id" as output
  23. #
  24. get_unique() {
  25. date "+%s.$$.`/sbin/ifconfig -a | cksum | cut -f1 -d' '`"
  26. }
  27. # Hook variables
  28. #
  29. unset hook_functions hook_fcounter
  30. declare -a hook_functions='()'
  31. hook_fcounter=0
  32. # This function adds a code fragment to a named hook with the named priority
  33. #
  34. # hook_add hook_name priority code
  35. #
  36. hook_add() {
  37. hook_functions[hook_fcounter]="$3" # declare -a hookidx_$1
  38. eval "hookidx_$1[\${#hookidx_$1[@]}]=\"$2 $hook_fcounter\""
  39. eval "(( hookdirty_$1++ ))"; (( hook_fcounter++ ))
  40. }
  41. # This function executes all code fragments from the named hook
  42. #
  43. # hook_eval hook_name
  44. #
  45. hook_eval() {
  46. while read pri fnr ; do
  47. eval "${hook_functions[fnr]}"
  48. done < <( IFS=$'\n' ; eval "echo \"\${hookidx_$1[*]}\"" | sort )
  49. eval "unset hookdirty_$1"
  50. }
  51. # This function prints all hooks and their current contents
  52. #
  53. # hook_dump
  54. #
  55. hook_dump() {
  56. for hook in ${!hookidx_*} ; do
  57. hook=${hook#hookidx_}
  58. echo ; echo "Contents of hook $hook:"
  59. while read pri fnr ; do
  60. echo ; echo " $pri ($fnr)"
  61. echo "${hook_functions[fnr]}" | sed 's,^, ,'
  62. done < <( IFS=$'\n'
  63. eval "echo \"\${hookidx_$hook[*]}\"" | sort )
  64. if eval "[ -n \"\$hookdirty_\$hook\" ]"; then
  65. echo ; echo -n " Hook is marked as dirty: "
  66. eval "echo \"\${hookdirty_$hook}\""
  67. fi
  68. done
  69. echo
  70. }
  71. # This functions append, insert or remove values in variables:
  72. #
  73. # var_append PATH ":" "$HOME/bin"
  74. # var_insert CC_WRAPPER_INSERT " " "-O3"
  75. # var_remove CC_WRAPPER_INSERT " " "-O3"
  76. #
  77. # var_remove_regex CC_WRAPPER_INSERT " " "-O.*"
  78. #
  79. # var_insert_before_regex patchfiles " " "mypatch.diff" ".*\/foo.diff"
  80. #
  81. # 1st Parameter: Variable Name
  82. # 2nd Parameter: Delimiter Text
  83. # 3rd Parameter: Value (or regex)
  84. # 4th Parameter: regex for insert_before
  85. #
  86. var_append() {
  87. eval "[ \"\$$1\" ] && $1=\"\${$1}$2\"" || true
  88. eval "$1=\"\${$1}\$3\""
  89. }
  90. var_insert() {
  91. eval "[ \"\$$1\" ] && $1=\"$2\$$1\"" || true
  92. eval "$1=\"\$3\$$1\""
  93. }
  94. var_remove() {
  95. local a=${2//\/\\/}
  96. local b=${3//\/\\/}
  97. eval '[ "$'$1'" = "$3" ] && '$1'="" || true'
  98. eval $1'="${'$1'//$a$b$a/$2}"'
  99. eval $1'="${'$1'%$a$b}"'
  100. eval $1'="${'$1'#$b$a}"'
  101. }
  102. var_remove_regex() {
  103. eval "$1=\"\`echo \"\$$1\" | awk -- ' { split(\$0, a, \"$2\"); for (c1=c2=1; c1 in a; c1++) if ( a[c1] !~ /^$3\\\$/ ) b[c2++]=a[c1]; for (c1=1; c1 in b; c1++) printf \"%s%s\", (c1 > 0 ? \"$2\" : \"\"), b[c1]; }'\`\""
  104. }
  105. var_insert_before_regex() {
  106. eval "$1=\"\`echo \"\$$1\" | awk -- '{ split(\$0, a, \"$2\"); for (d=c1=c2=1; c1 in a; c1++) { if ( d && a[c1] ~ /^$4\\\$/ ) { b[c2++]=\"$3\"; d=0; } b[c2++]=a[c1]; } if (d) b[c2++]=\"$3\"; for (c1=1; c1 in b; c1++) printf \"%s%s\", (c1 > 0 ? \"$2\" : \"\"), b[c1]; }'\`\""
  107. }
  108. # This function can be used to duplicate a shell-function. E.g. when
  109. # overwriting a shell-function but the old one should stay available under
  110. # a new name:
  111. #
  112. # copy_function set_confopt set_confopt_foobar_old
  113. #
  114. # set_confopt() {
  115. # ....
  116. # set_confopt_foobar_old "$@"
  117. # ....
  118. # }
  119. #
  120. copy_function() {
  121. eval "$( declare -f $1 | sed "1 s,$1,$2," )"
  122. }
  123. # This function sets the 'confopt' and some other variables.
  124. # Re-run it in the package .conf file if you modify $prefix
  125. #
  126. set_confopt() {
  127. confopt="--prefix=$root/$prefix"
  128. bindir="$root/$prefix/bin"
  129. confopt="$confopt --bindir=\$bindir"
  130. sbindir="$root/$prefix/sbin"
  131. confopt="$confopt --sbindir=\$sbindir"
  132. libdir="$root/$prefix/lib"
  133. confopt="$confopt --libdir=\$libdir"
  134. if [ -z "$prefix" ]; then
  135. datadir="$root/usr/share"
  136. includedir="$root/usr/include"
  137. docdir="$root/usr/doc/$pkg"
  138. infodir="$root/usr/info"
  139. mandir="$root/usr/man"
  140. else
  141. datadir="$root/$prefix/share"
  142. includedir="$root/$prefix/include"
  143. docdir="$root/$prefix/doc/$pkg"
  144. infodir="$root/$prefix/info"
  145. mandir="$root/$prefix/man"
  146. fi
  147. confopt="$confopt --datadir=\$datadir"
  148. confopt="$confopt --includedir=\$includedir"
  149. confopt="$confopt --infodir=\$infodir"
  150. confopt="$confopt --mandir=\$mandir"
  151. if [ "${prefix#opt/}" != "$prefix" ] ; then
  152. sysconfdir="$root/etc/$prefix"
  153. localstatedir="$root/var/$prefix"
  154. elif [ "${prefix#usr}" != "$prefix" ] ; then
  155. sysconfdir="$root/etc"
  156. localstatedir="$root/var"
  157. else
  158. sysconfdir="$root/$prefix/etc"
  159. localstatedir="$root/$prefix/var"
  160. fi
  161. confopt="$confopt --sysconfdir=\$sysconfdir"
  162. confopt="$confopt --localstatedir=\$localstatedir"
  163. if [ "$ROCKCFG_CONFIGURE_OPTS" ] ; then
  164. confopt="$confopt $ROCKCFG_CONFIGURE_OPTS"
  165. fi
  166. if [ "$ROCKCFG_DEBUG" = 0 ] ; then
  167. confopt="$confopt --disable-debug"
  168. fi
  169. if [ "$stagelevel" -le 1 -o "$ROCKCFG_DISABLE_NLS" = 1 ] ; then
  170. confopt="${confopt//--enable-nls/} --disable-nls"
  171. fi
  172. confopt="$confopt \$extraconfopt"
  173. if [ "$stagelevel" -eq 0 ]; then
  174. confopt="$confopt --target=\$arch_target --host=\$arch_build"
  175. else
  176. confopt="$confopt --build=\$arch_build --host=\$arch_target"
  177. fi
  178. }
  179. #
  180. # eval_config_command $( eval echo $confopt )
  181. #
  182. function eval_config_command() {
  183. local config_command
  184. for x in /usr/share/automake/*
  185. do
  186. [ -x "$x" -a -f "$x" ] || continue
  187. x="$( basename "$x" )"
  188. if [ -L $x -a ! -e $x ] ; then
  189. echo "Fixing dead symlink $x."
  190. ln -sf /usr/share/automake/$x .
  191. fi
  192. done
  193. if [ $autogen -eq 1 -a -f configure.in ] ; then
  194. if [ -f configure.orig ] ; then
  195. echo "Found configure.orig. Not" \
  196. "running autogen script."
  197. elif [ -f autogen.sh ] ; then
  198. echo "Running package autogen script."
  199. sh autogen.sh
  200. else
  201. echo "Running builtin autogen script."
  202. libtoolize --force --automake ; aclocal
  203. if grep AM_INIT_AUTOMAKE configure.in
  204. then automake ; fi
  205. autoconf
  206. fi
  207. fi
  208. if [ $stagelevel -le 1 ] ; then
  209. create_config_cache >> config.cache
  210. grep -q '.--cache-file=' $configscript &&
  211. set -- "$@" "--cache-file=config.cache"
  212. export cache_file=config.cache
  213. fi
  214. config_command="$configprefix $configscript"
  215. sub_scripts="$( find $( dirname $configscript ) -name configure )"
  216. # remove unsupported config script options
  217. for x ; do
  218. if grep -q "[[ ]${x%%=*}[]= ):]" $configscript $sub_scripts ; then
  219. config_command="$config_command $x"
  220. elif [[ $x = --*able-* ]] && egrep -q "\-\-(en|dis)able-\*" $configscript ; then
  221. echo "Autodetection for option impossible: " \
  222. "$x passed thru."
  223. config_command="$config_command $x"
  224. else
  225. echo "Removing unsupported '$x' from" \
  226. "configure option string."
  227. fi
  228. done
  229. echo Running "$config_command"
  230. eval "$config_command"
  231. }
  232. # run 'make check' if Makefile supports it.
  233. #
  234. function run_check() {
  235. if grep -q -e "^check:" ./Makefile; then
  236. echo "Running make check ..."
  237. $MAKE check
  238. fi
  239. if grep -q -e "^test:" ./Makefile; then
  240. echo "Running make test ..."
  241. $MAKE test
  242. fi
  243. }
  244. # move the static libs from lib to usr/lib and correct the libdir used
  245. # inside the .la file
  246. #
  247. postflist_static_lib() {
  248. echo "processing static lib corrections ..."
  249. egrep '^lib/.*\.(a|la)$' $builddir/flist.txt |
  250. while read fn ; do
  251. [ -e $root/$fn -o -L $root/$fn ] || continue
  252. if [[ $fn = *.a ]] ; then
  253. mv -fv $root/$fn $root/usr/$fn
  254. else
  255. sed "s,\([ =']\)/lib\(.*\),\1/usr/lib\2,g" \
  256. $root/$fn > $root/usr/$fn
  257. rm $root/$fn
  258. fi
  259. add_flist $root/usr/$fn
  260. done
  261. }
  262. # Parse the *.desc file. Use the description from PKG-DESC-FORMAT and
  263. # save the tag data in $desc_*.
  264. #
  265. parse_desc() {
  266. tag="`grep '^\[' $base/Documentation/Developers/PKG-DESC-FORMAT | \
  267. sed 's, (\*),,; s,\] \[,|,g; s,\[,,; s,\],,;'`"
  268. descfile="$( pkg="$pkg" xpkg="$xpkg" descparser < $confdir/$1.desc )"
  269. for tag in $tag ; do
  270. tagdata="`echo "$descfile" | egrep "^\[($tag)\]" | \
  271. cut -f2- -d']' | sed 's,^ ,,'`"
  272. tag="`echo $tag | cut -f1 -d'|' | tr - _`"
  273. eval "desc_$tag=\"\$tagdata\""
  274. done
  275. }
  276. # This function is used for forcing a file to be in the flist
  277. #
  278. add_flist() {
  279. for addfile ; do
  280. echo "$addfile" | fl_wrparse -D -r "$xroot/" \
  281. >> $builddir/flist.txt
  282. done
  283. }
  284. # This function is used for forcing a package to be in the dependency list
  285. #
  286. add_dependency() {
  287. for addpackage ; do
  288. echo "$addpackage: add_dependency()" \
  289. >> $builddir/dependencies.debug
  290. done
  291. }
  292. # This function is used to subsitute some important variables
  293. # using a D_ prefix thru m4 ...
  294. rock_substitute() {
  295. sed -e s,D_prefix,$prefix,g -e s,D_sysconfdir,$sysconfdir,g \
  296. -e s,D_docdir,$docdir,g -e s,D_localstatedir,$localstatedir,g \
  297. -e s,D_datadir,$datadir,g -e s,D_infodir,$infodir,g \
  298. -e s,D_bindir,$bindir,g -e s,D_sbindir,$sbindir,g \
  299. -e s,D_libdir,$libdir,g -e s,D_mandir,$mandir,g $1
  300. }
  301. # This outputs a predefined config.cache file as it needed by some
  302. # packages to cross-build correctly in stages 0 and 1.
  303. #
  304. create_config_cache() {
  305. cat $base/scripts/config.cache
  306. echo -e "\n# Architecture specific stuff\n"
  307. echo "ac_cv_sizeof_short=$arch_sizeof_short"
  308. echo "ac_cv_sizeof_int=$arch_sizeof_int"
  309. echo "ac_cv_sizeof_long=$arch_sizeof_long"
  310. echo "ac_cv_sizeof_long_long=$arch_sizeof_long_long"
  311. echo "ac_cv_sizeof_char_p=$arch_sizeof_char_p"
  312. echo "ac_cv_c_bigendian=$arch_bigendian"
  313. echo "ac_cv_prog_CC=$CC"
  314. }
  315. # Abort build before actual build starts
  316. # (is overwritten in Build-Pkg)
  317. #
  318. abort() {
  319. echo -e "The package build aborted with the following config" \
  320. "error:\n$*" > $root/var/adm/logs/$stagelevel-$pkg.err
  321. echo_errorquote "`cat $root/var/adm/logs/$stagelevel-$pkg.err`"
  322. echo_pkg_abort $stagelevel $repository $pkg
  323. exit 1
  324. }
  325. # Dump Environment
  326. #
  327. dump_env() {
  328. # Dump $base - only set if there is not already an older value.
  329. #
  330. echo "base=\"\${base:-$base}\""
  331. # Dump all variables including their flags, but skip read-only
  332. # variables and $base.
  333. #
  334. # Substitute base directory with ${base}.
  335. #
  336. for name in ${!a*} ${!b*} ${!c*} ${!d*} ${!e*} ${!f*} ${!g*} ${!h*} \
  337. ${!i*} ${!j*} ${!k*} ${!l*} ${!m*} ${!n*} ${!o*} ${!p*} \
  338. ${!q*} ${!r*} ${!s*} ${!t*} ${!u*} ${!v*} ${!w*} ${!x*} \
  339. ${!y*} ${!z*} \
  340. ${!A*} ${!B*} ${!C*} ${!D*} ${!E*} ${!F*} ${!G*} ${!H*} \
  341. ${!I*} ${!J*} ${!K*} ${!L*} ${!M*} ${!N*} ${!O*} ${!P*} \
  342. ${!Q*} ${!R*} ${!S*} ${!T*} ${!U*} ${!V*} ${!W*} ${!X*} \
  343. ${!Y*} ${!Z*} ${!_*}
  344. do
  345. [ $name = base ] && continue
  346. if declare -p $name | head -n 1 | grep -qv '^declare -[a-z]*r'
  347. then
  348. declare -p $name | sed "s,\\(^\\|[\"=:]\\)$base\\([\"=:/]\\|\$\\),\\1\${base}\\2,g"
  349. fi
  350. done
  351. # Dump functions
  352. #
  353. declare -f | sed 's/^declare -f //; s/<<(/< <(/;'
  354. # Dump aliases
  355. #
  356. alias
  357. }
  358. # Check if a package is already installed
  359. #
  360. # It does check the build-list if not in the rebuild stage - and
  361. # the really installed package data for rebuilds (and so manual builds).
  362. #
  363. pkginstalled() {
  364. if [ "$stagelevel" -le 8 ] ; then
  365. local pattern="$1"; pattern="${pattern//+/\\+}"
  366. egrep -q "^X.* ($pattern) " $base/config/$config/packages
  367. else
  368. [ -f $root/var/adm/packages/$1 ]
  369. fi
  370. }
  371. # Register a window-manager
  372. #
  373. register_wm() {
  374. [ -e /usr/share/rock-registry/wm ] || mkdir -p $root/usr/share/rock-registry/wm
  375. echo -e "name=\"$2\"\nexec=\"$3\"\n" > $root/usr/share/rock-registry/wm/$1
  376. }
  377. # Register an application
  378. #
  379. register_application() {
  380. [ -e /usr/share/rock-registry/app ] \
  381. || mkdir -p /usr/share/rock-registry/app
  382. echo -e "name=\"$2\"\nexec=\"$3\"\n" > /usr/share/rock-registry/app/$1
  383. }
  384. # Register a xdm - display manager
  385. #
  386. register_xdm() {
  387. [ -e /usr/share/rock-registry/xdm ] \
  388. || mkdir -p /usr/share/rock-registry/xdm
  389. echo -e "name=\"$2\"\nexec=\"$3\"\n" > /usr/share/rock-registry/xdm/$1
  390. }
  391. # Create Package Database for gasgui install tool
  392. #
  393. create_package_db() {
  394. rm -f $3.tmp
  395. for file in $( ls -dr $1/descs/?* ) ; do
  396. pkg="${file##*/}"
  397. # only include the package if a binary file is available
  398. if [ "$ROCKCFG_PKGFILE_VER" = 1 ] ; then
  399. v=-$(grep '^Package Name and Version' \
  400. $1/packages/$pkg | cut -f6 -d' ')
  401. else
  402. v=""
  403. fi
  404. if [ "$ROCKCFG_CREATE_GEM" = 1 ] ; then
  405. bfile=${pkg}${v}.gem
  406. else
  407. bfile=${pkg}${v}.tar.bz2
  408. fi
  409. if [ -e $2/$bfile ] ; then
  410. [ "$pkg" = TRANS.TBL ] && continue
  411. ( echo -e "$pkg"
  412. echo -e "\027"
  413. cat $1/descs/$pkg
  414. echo -e "\027"
  415. cat $1/dependencies/$pkg
  416. echo -e "\027"
  417. cat $1/cksums/$pkg
  418. echo -e "\027"
  419. echo -e "\004"
  420. ) >> $3.tmp
  421. else
  422. echo_error "Binary file for $bfile not present." \
  423. "Skipped in package database."
  424. fi
  425. done
  426. gzip -c $3.tmp > $3 ; rm -f $3.tmp
  427. }
  428. # Add files to the 'badfiles' list
  429. #
  430. register_badfiles() {
  431. local x desc="$1"
  432. shift
  433. for x in "$@"; do
  434. var_append badfiles $'\n' " $x\$"
  435. badfiles_desc[$badfiles_nr]=" $x\$"$'\n'"$desc"
  436. (( badfiles_nr++ ))
  437. done
  438. }
  439. # Apply the given $patchfiles
  440. #
  441. apply_patchfiles() {
  442. for x in $patchfiles; do
  443. echo "Apply patch $x ..."
  444. if [[ $x = *.bz2 ]] ; then
  445. bzcat $x | patch $patchopt
  446. else
  447. patch $patchopt < $x
  448. fi
  449. eval "$@"
  450. done
  451. }
  452. # Main program for building a package
  453. #
  454. build_this_package() {
  455. if [ ".$desc_SRC" == "." ] ; then
  456. # Autodetect source tar and extract it
  457. #
  458. if [ $srctar = auto ] ; then
  459. xsourceballs=$( echo "$desc_D" | head -n 1 | tr ' ' '\t' | tr -s '\t' | \
  460. cut -f2 | sed 's,.\(t\?\)\(gz\|Z\)$,.\1bz2,' )
  461. if [ -z "$xsourceballs" ] ; then
  462. echo "Can't auto-detect srctar for package '$pkg'!"
  463. false
  464. fi
  465. else
  466. xsourceballs="$srctar"
  467. fi
  468. else
  469. sourceballs=$( echo "$desc_D" | tr ' ' '\t' | tr -s '\t' | \
  470. cut -f2 | sed 's,.\(t\?\)\(gz\|Z\)$,.\1bz2,' )
  471. xsrcpattern=$( echo "$desc_SRC" | tr ' ' '\t' | tr -s '\t' | tr '\t' '\n' )
  472. xsourceballs=$( echo "$sourceballs" | grep -F "$xsrcpattern" )
  473. fi
  474. for xsrctar in $xsourceballs; do
  475. saved_patchfiles="$patchfiles"
  476. var_append patchfiles " " \
  477. "`ls $confdir/*.patch.${xsrctar/-[0-9]*/} 2> /dev/null`"
  478. if [ $autoextract = 1 ]; then
  479. echo "Extracting $xsrctar ($taropt) ... "
  480. cd $builddir
  481. tar -v $taropt $archdir/$xsrctar | tee untar.txt |
  482. cut -f1 -d/ | sort -u > xsrcdir.txt
  483. #
  484. if [ $srcdir = auto ]; then
  485. xsrcdir=${xsrctar%.tar.bz2}
  486. xsrcdir=${xsrcdir%.tbz2}
  487. if [ ! -d $xsrcdir ] ; then
  488. for x in $pkg-$ver $pkg_$ver $pkg \
  489. "`cat xsrcdir.txt`" ; do
  490. [ -d "$x" ] && xsrcdir="$x"
  491. done
  492. fi
  493. else
  494. xsrcdir="$srcdir"
  495. fi
  496. #
  497. if [ "$chownsrcdir" = 1 ]; then
  498. echo "Fixing ownership and permissions ..."
  499. chown -R 0:0 $builddir/$xsrcdir
  500. fi
  501. #
  502. if [ "$nocvsinsrcdir" = 1 ]; then
  503. echo "Removing CVS and .svn directories ..."
  504. egrep '(^|/)(CVS|\.svn)(/|$)' untar.txt |
  505. while read x; do
  506. echo "Removing $x ..."
  507. rm -rf "$x"
  508. done
  509. fi
  510. #
  511. echo "Changeing into $builddir/$xsrcdir ..."
  512. cd $builddir/$xsrcdir
  513. # Apply patches
  514. #
  515. if [ $autopatch = 1 ]; then
  516. hook_eval prepatch
  517. apply_patchfiles
  518. hook_eval postpatch
  519. fi
  520. else
  521. cd $builddir
  522. fi
  523. if [ "$createprefix" = 1 ]; then
  524. echo "Creating $root/$prefix/<..> if required ..."
  525. for x in $docdir $root/$prefix/bin $root/$prefix/lib \
  526. $root/$prefix/share $sysconfdir $localstatedir
  527. do
  528. if [ ! -e $x ]; then
  529. mkdir -p $x
  530. rmemptydir="$rmemptydir $x"
  531. fi
  532. done
  533. fi
  534. if [ ".$custmain" = "." ]
  535. then
  536. # Run configure scripts etc.
  537. #
  538. hook_eval preconf
  539. #
  540. if [ $runconf = 1 ]; then
  541. if [ -n "$( type -p $configscript )" -o $autogen = 1 ]
  542. then
  543. eval_config_command $( eval echo $confopt )
  544. fi
  545. fi
  546. # automated package build
  547. # styles without make run first:
  548. if [ -f setup.py -a $runpysetup = 1 ] ; then
  549. pyconfopt="${pyconfopt:=--prefix $root/$prefix}"
  550. eval python setup.py build install $pyconfopt
  551. else # styles that include a make run
  552. if [ ! -f Makefile -a ! -f makefile -a \
  553. -f Makefile.PL -a $runmkpl = 1 ]; then
  554. perl Makefile.PL INSTALLDIRS=perl
  555. fi
  556. #
  557. if [ ! -f Makefile -a ! -f makefile -a \
  558. -f Imakefile -a $runxmkmf = 1 ]; then
  559. xmkmf -a
  560. fi
  561. #
  562. # Build it
  563. #
  564. hook_eval premake
  565. if [ "$makeopt" ]
  566. then eval "$MAKE $makeopt"; fi
  567. hook_eval inmake
  568. if [ "$makeinstopt" ]
  569. then eval "$MAKE $makeinstopt"; fi
  570. hook_eval postmake
  571. fi
  572. else
  573. eval "$custmain"
  574. for x in preconf premake inmake postmake; do
  575. if eval "[ -n \"\$hookdirty_$x\" ]"; then
  576. echo "Hook $x is still marked as dirty ..."
  577. hook_eval $x
  578. fi
  579. done
  580. fi
  581. if [ "$createdocs" != 0 ]; then
  582. if [ ! -e $docdir ]; then
  583. mkdir -p $docdir
  584. rmemptydir="$rmemptydir $docdir"
  585. fi
  586. [ -z "$createdocs" ] && createdocs="$ROCKCFG_CREATE_DOCS"
  587. fi
  588. for file in $confdir/*.desktop ; do
  589. [ -f $file ] || continue
  590. echo -n "Install desktop file '$file': "
  591. mkdir -p $root/usr/share/rock-registry/app
  592. rock_substitute $file > \
  593. $root/usr/share/rock-registry/app/`basename $file`
  594. done
  595. if [ "$createdocs" = 1 ]; then
  596. echo "Trying to copy the default documentation ..."
  597. [ -d $builddir/$xsrcdir ] && cd $builddir/$xsrcdir
  598. for x in `find -type d \( -name 'doc' -o -name 'docs' -o \
  599. -name '[Dd]ocumentation' \) ! -empty`
  600. do
  601. if [ -d "$x" -a "`echo $x/*`" != "$x/*" ]
  602. then cp -rLv $x/* $docdir || true ; fi
  603. done
  604. for x in [A-Z][A-Z]* *.lsm ChangeLog*; do
  605. [ "${x#*.[cho0-9]}" ] || continue
  606. [ "${x#*.info*}" ] || continue
  607. if [ -f $x ] ; then cp -v $x $docdir/$x ; fi
  608. done
  609. for x in $confdir/*.doc; do
  610. if [ -f $x ]; then cp -v $x $docdir/${x%.doc}; fi
  611. done
  612. find $docdir/ -name '*.[0-9]' -o -name '*.info*' \
  613. -o -name '[Mm]akefile*' | \
  614. xargs -r rm -f 2> /dev/null || true
  615. find $docdir/* -type d -empty 2> /dev/null | \
  616. xargs -r rmdir 2> /dev/null || true
  617. fi
  618. hook_eval postdoc
  619. patchfiles="$saved_patchfiles"
  620. done
  621. if [ "$rmemptydir" ]; then
  622. rmdir $rmemptydir 2> /dev/null || true
  623. fi
  624. return 0
  625. }