#!/bin/sh

case $1 in
  ONEW_CONF)      echo "############## search ONEW_CONF"
      if [ "$2" = "NO_SYMLINK" ]; then
         LN="ln"
      else
         LN="ln -s"
      fi

      if [ ! -f  ONEW_CONF ]; then
        if [ -f ../ONEW_CONF   ]; then $LN ../ONEW_CONF .; else
          if [ -f ../../ONEW_CONF ]; then $LN ../../ONEW_CONF .; else
            touch ONEW_CONF
          fi
        fi
      fi
  ;;

  *)              echo "############## include ONEW_CONF* into $1"
      sed -n '1,/^# BOOT_BEGIN/p' < Makefile  > $1

      if [ -f ONEW_CONF.default ]; then
        cat ONEW_CONF.default                 >> $1
      else
        if [ -f ../ONEW_CONF.default ];  then
          cat ../ONEW_CONF.default            >> $1
        fi
      fi
      cat ONEW_CONF                           >> $1
      sed -n '/^# BOOT_END/,$p'   < Makefile  >> $1
  ;;
esac


syntax highlighted by Code2HTML, v. 0.9.1