12c7b1c5 (kx 2023-03-24 02:53:04 +0300 1) #!/bin/sh
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 2)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 3) CWD=`pwd`
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 4)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 5) program=`basename $0`
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 6)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 7) usage() {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 8) cat << EOF
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 9)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 10) Usage: $program [options]
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 11)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 12) Options:
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 13) -h,--help Display this message.
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 14) -d,--target-dest-dir=DIR The target ROOTFS directory
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 15) [default: DIR=/].
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 16)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 17) EOF
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 18) }
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 19)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 20) TARGET_DEST_DIR=/
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 21) ACDIR=usr/share/aclocal
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 22) INCDIR=usr/include
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 23) SYSTEM_ACDIR=
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 24) SYSTEM_INCDIR=
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 25)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 26) while [ 0 ] ; do
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 27) if [ "$1" = "-h" -o "$1" = "--help" ] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 28) usage
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 29) exit 0
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 30) elif [ "$1" = "-d" -o "$1" = "--target-dest-dir" ] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 31) if [ "$2" = "" ] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 32) echo -e "\n${program}: ERROR: --target-dest-dir is not specified.\n"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 33) usage
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 34) exit 1
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 35) fi
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 36) TARGET_DEST_DIR="$2"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 37) shift 2
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 38) elif [[ $1 == --target-dest-dir=* ]] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 39) TARGET_DEST_DIR="`echo $1 | cut -f2 -d'='`"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 40) shift 1
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 41) else
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 42) if [ "$1" != "" ] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 43) echo -e "\n${program}: ERROR: Unknown argument: $1.\n"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 44) usage
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 45) exit 1
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 46) fi
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 47) break
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 48) fi
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 49) done
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 50)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 51) if [ ! -d "${TARGET_DEST_DIR}" ] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 52) echo -e "\n${program}: ERROR: --target-dest-dir is not a directory.\n"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 53) usage
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 54) exit 1
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 55) fi
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 56)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 57) #
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 58) # Absolute path:
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 59) #
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 60) if [ "${TARGET_DEST_DIR:0:1}" != "/" ] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 61) TARGET_DEST_DIR=${CWD}/${TARGET_DEST_DIR}
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 62) fi
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 63)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 64) #
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 65) # Remove last '/' char:
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 66) #
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 67) if [ "${TARGET_DEST_DIR: -1}" = "/" ] ; then
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 68) len=${#TARGET_DEST_DIR}
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 69) let "len = len - 1"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 70) tmp="${TARGET_DEST_DIR:0:$len}"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 71) TARGET_DEST_DIR=${tmp}
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 72) fi
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 73)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 74) SYSTEM_ACDIR="${TARGET_DEST_DIR}/${ACDIR}"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 75) SYSTEM_INCDIR="${TARGET_DEST_DIR}/${INCDIR}"
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 76)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 77)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 78) aclocal --install -I m4 --force --system-acdir=${SYSTEM_ACDIR}
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 79) autoheader --include=${SYSTEM_INCDIR}
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 80) automake --foreign --add-missing --copy --force-missing
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 81) autoconf --force
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 82)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 83) #
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 84) # Add 'cCgit Features' header to split help output:
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 85) #
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 86) cat >cscm-features <<_CGIT
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 87) _ACEOF
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 88)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 89) cat <<\\_ACEOF
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 90)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 91) cScm Features:
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 92) _CGIT
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 93)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 94) sed -i '/^[ ]*\-\-with\-controldir=DIR/ {
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 95) r cscm-features
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 96) N
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 97) }' configure
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 98)
12c7b1c5 (kx 2023-03-24 02:53:04 +0300 99) rm -f cscm-features