home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / conf / maker < prev    next >
Text File  |  1994-10-17  |  989b  |  51 lines

  1. #! /bin/sh
  2. # fake make for people who don't have an include feature in theirs
  3.  
  4. CONFIG_MAKE=${CONFIG_MAKE-../include/config.make}
  5.  
  6. mfs=
  7. options=
  8. for dummy
  9. do
  10.     case "$1" in
  11.     -f)    mfs="$mfs $2" ; shift    ;;
  12.     --)    shift ; break        ;;
  13.     -*)    options="$options $1"    ;;
  14.     *)    break            ;;
  15.     esac
  16.     shift
  17. done
  18.  
  19. if test " $mfs" = " "
  20. then
  21.     if test -r Makefile
  22.     then
  23.         mfs=Makefile
  24.     elif test -r makefile
  25.     then
  26.         mfs=makefile
  27.     else
  28.         echo "$0: cannot locate makefile" >&2
  29.         exit 1
  30.     fi
  31. fi
  32.  
  33. tmp=/tmp/maker$$
  34. status=1
  35. trap "rm -f $tmp ; trap 0 ; exit \$status" 0 1 2 15
  36.  
  37. ( cat $CONFIG_MAKE ; echo '===' ; cat $mfs ) |
  38. awk '    BEGIN { includeline = 0 ; inconfig = 1 }
  39.     $0 ~ /^===$/ && inconfig == 1 { inconfig = 0 ; next }
  40.     inconfig == 1 { config[++nconfig] = $0 ; next }
  41.     $0 == "# =()<@<INCLUDE>@>()=" { includeline = NR + 1 }
  42.     NR == includeline {
  43.         for (i = 1; i <= nconfig; i++)
  44.             print config[i]
  45.         next
  46.     }
  47.     { print }' >$tmp
  48. ${REALMAKE-make} -f $tmp $options $*
  49. status=$?
  50. # and the exit trap does the actual exiting
  51.