Annotation of elwix/build_tools.sh, revision 1.9

1.2       misho       1: #!/bin/sh
                      2: #
                      3: # ELWIX build script for tools
                      4: #
                      5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
                      6: #    by Michael Pounov <misho@elwix.org>
                      7: #
1.9     ! misho       8: # $Id: build_tools.sh,v 1.8.2.5 2018/07/06 00:23:20 misho Exp $
1.2       misho       9: #
                     10: 
                     11: [ -r ./config/rc.elwix ] && . ./config/rc.elwix
                     12: if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
                     13:        echo
                     14:        echo "ELWIX project is not configured !?!"
                     15:        echo
                     16:        exit 1
                     17: fi
                     18: V=${VERSION}
1.7       misho      19: #[ -r ${CENV} ] && . ${CENV}
1.2       misho      20: unset INSTALL
                     21: unset VERSION
                     22: VERSION="$V"
                     23: 
1.7       misho      24: # Set TARGET_CPUTYPE only for world compiling. Don't use this in kernel build!
                     25: X_TARGET_CPUTYPE="TARGET_CPUTYPE=${TARGET_CPUTYPE}"
1.6       misho      26: 
1.2       misho      27: if [ ! -d $BSDSRC ]; then
                     28:        echo
                     29:        echo "ELWIX project is not configured - missing BSD sources !?!"
                     30:        echo
                     31:        exit 1
                     32: fi
                     33: 
                     34: if [ ! -d $DEST ]; then
                     35:        echo
                     36:        echo "ELWIX project is not configured - missing Dest directory !?!"
                     37:        echo
                     38:        exit 1
                     39: fi
                     40: 
                     41: clean_tools()
                     42: {
1.8       misho      43:        echo "+++ Clean ELWIX FreeBSD tools ... ${WORLD}/usr/local"
1.2       misho      44: 
                     45:        rm -rf ${WORLD}/usr/local
                     46:        install -d ${WORLD}/usr/local
                     47:        install -d ${WORLD}/usr/local/bin
                     48:        install -d ${WORLD}/usr/local/include
                     49:        install -d ${WORLD}/usr/local/lib
                     50:        install -d ${WORLD}/usr/local/libdata
                     51:        install -d ${WORLD}/usr/local/sbin
                     52: 
                     53: }
                     54: 
                     55: clean_bootstrap()
                     56: {
                     57:        echo "+++ Clean ELWIX pkgsrc bootstrap tools ..."
                     58: 
1.6       misho      59:        rm -Rf ${WORLD}/usr/pkgsrc/bootstrap/work
1.2       misho      60:        rm -f /elwix ${WORLD}/usr/pkgsrc
1.6       misho      61:        rm -Rf ${WORLD}/elwix
1.2       misho      62:        install -d ${WORLD}/elwix
                     63:        ln -sf ${WORLD}/elwix /elwix
                     64:        ln -sf ${PKGSRC} ${WORLD}/usr/pkgsrc
                     65: 
                     66:        install -d ${PKGDIR}
                     67:        install -d ${PKGDIR}/db
                     68:        install -d ${PKGDIR}/etc
                     69: }
                     70: 
1.6       misho      71: compile_deps()
                     72: {
                     73:        echo "+++ Compile ELWIX programs bootstrap tools ..."
                     74:        if [ -d tools -a -f tools/Makefile ]; then
                     75:                cd tools
                     76:                make cleandepend
                     77:                make clean
                     78:                make obj
                     79:                make
                     80:                make install
                     81:                cd -
                     82:        fi
                     83: }
                     84: 
1.2       misho      85: compile_bootstrap()
                     86: {
                     87:        echo "+++ Compile ELWIX pkgsrc bootstrap tools ..."
                     88:        if [ ! -d ${WORLD}/usr/pkgsrc/bootstrap/work ]; then
                     89:                cd ${WORLD}/usr/pkgsrc/bootstrap
1.6       misho      90:                ./cleanup --prefix /elwix/pkg --pkgdbdir /elwix/pkg/db 
1.2       misho      91:                ./bootstrap --prefix /elwix/pkg --pkgdbdir /elwix/pkg/db
                     92:                cd -
                     93:        else
                     94:                echo " Skip bootstrap pkgsrc - already inited pkgsrc"
                     95:        fi
                     96: 
                     97:        cat >>/elwix/pkg/etc/mk.conf << _EOF
                     98: 
                     99: .if defined(USE_CROSS_COMPILE) && !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
                    100: USE_DESTDIR=           yes
                    101: DEPENDS_TARGET=                package-install
                    102: 
                    103: TOOLDIR=                ${CROSSTOOLDIR}
                    104: CROSS_DESTDIR=         ${WORLD}
                    105: 
                    106: TARGET=                        ${TARGET}
                    107: TARGET_ARCH=           ${TARGET_ARCH}
                    108: MACHINE_PLATFORM=      FreeBSD-${PLATFORM}-${TARGET_ARCH}
                    109: MACHINE_GNU_PLATFORM=  ${TARGET_ARCH}-elwix-freebsd
                    110: 
                    111: PKGSRC_COMPILER=       gcc
                    112: USE_PKGSRC_GCC=                no
                    113: USE_NATIVE_GCC=                yes
                    114: 
                    115: .endif                 # end cross-compilation settings
                    116: _EOF
                    117: }
                    118: 
                    119: compile_fbsdtools()
                    120: {
                    121:        echo "+++ Compile ELWIX FreeBSD tools ..."
                    122: 
1.8       misho     123:        if [ "$(uname -m)" != ${TARGET} ]; then
                    124:                BSDSTATDIR="${BSDOBJ}/${TARGET}.${TARGET_ARCH}${BSDSRC}/lib/libbsdstat"
                    125:        else
                    126:                BSDSTATDIR="${BSDOBJ}${BSDSRC}/lib/libbsdstat"
                    127:        fi
                    128: 
1.9     ! misho     129:        cd $CROSS_FT_ATH
        !           130:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           131: #      cp ${CROSSTOOLDIR}/usr/include/private/bsdstat/bsdstat.h ${BSDTOOLS}/ath/common || exit 1
        !           132:        ${CBUILD} DESTDIR=${WORLD} LIBBSDSTATDIR="${BSDSTATDIR}" || exit 1
        !           133:        ${CBUILD} DESTDIR=${WORLD} install || exit 1
        !           134:        cd -
        !           135: 
        !           136:        cd $CROSS_FT_CXGB
1.8       misho     137:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
                    138:        ${CBUILD} DESTDIR=${WORLD} || exit 1
1.9     ! misho     139:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
1.2       misho     140:        cd -
                    141: 
1.9     ! misho     142:        cd $CROSS_FT_IFINFO
1.8       misho     143:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
1.9     ! misho     144:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           145:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
1.7       misho     146:        cd -
                    147: 
1.9     ! misho     148: #      cd $CROSS_FT_MCTEST
1.8       misho     149: #      ${CBUILD} DESTDIR=${WORLD} clean || exit 1
1.9     ! misho     150: #      ${CBUILD} DESTDIR=${WORLD} MK_MAN="no" || exit 1
        !           151: #      ${CBUILD} DESTDIR=${WORLD}/usr/local/bin MK_MAN="no" BINDIR="" install || exit 1
1.8       misho     152: #      cd -
1.2       misho     153: 
1.9     ! misho     154: #      cd $CROSS_FT_NETMAP
1.8       misho     155: #      ${CBUILD} DESTDIR=${WORLD} clean || exit 1
                    156: #      ${CBUILD} DESTDIR=${WORLD} || exit 1
1.9     ! misho     157: #      ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
1.8       misho     158: #      cd -
1.2       misho     159: 
1.9     ! misho     160:        cd $CROSS_FT_NETBLAST
        !           161:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           162:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           163:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
        !           164:        cd -
        !           165: 
        !           166:        cd $CROSS_FT_NETRCV
        !           167:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           168:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           169:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
        !           170:        cd -
        !           171: 
        !           172:        cd $CROSS_FT_NETSND
        !           173:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           174:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           175:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
        !           176:        cd -
1.2       misho     177: }
                    178: 
                    179: compile_files()
                    180: {
                    181:        cd files
1.8       misho     182:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
                    183:        ${CBUILD} DESTDIR=${WORLD} obj || exit 1
                    184:        ${CBUILD} DESTDIR=${WORLD} depend || exit 1
                    185:        ${CBUILD} DESTDIR=${WORLD} || exit 1
                    186:        ${CBUILD} DESTDIR=${WORLD} install || exit 1
1.2       misho     187:        cd -
                    188: }
                    189: 
1.9     ! misho     190: compile_sw()
1.2       misho     191: {
1.9     ! misho     192:        CROSS_OPTS=$(eval echo "\$$2_OPTS")
1.2       misho     193: 
1.9     ! misho     194:        cd $1$2
        !           195:        ${CEXEC} INSTALL="/usr/bin/install" ./configure $CROSS_OPTS ${CROSS_PFX}
1.2       misho     196:        ${CBUILD} clean
                    197:        ${CBUILD}
                    198:        ${CBUILD} install
                    199:        cd -
1.9     ! misho     200: }
1.2       misho     201: 
1.9     ! misho     202: compile_tools()
        !           203: {
        !           204:        echo "+++ Compile ELWIX Cross ..."
1.2       misho     205: 
1.9     ! misho     206:        for i in ${CROSS_TOOLS}; do
        !           207:                if [ -d "${CROSS_PATH}$i" ]; then
        !           208:                        compile_sw ${CROSS_PATH} $i
        !           209:                else
        !           210:                        Die "Error:: ${CROSS_PATH}$i not found!"
        !           211:                fi
        !           212:        done
1.6       misho     213: }
                    214: 
                    215: install_tools()
                    216: {
                    217:        LIBS="${ROMFS_USR2}/lib"
                    218:        LIBEXEC="${ROMFS_USR2}/libexec"
                    219:        BIN="${ROMFS_USR2}/bin"
                    220:        SBIN="${ROMFS_USR2}/sbin"
                    221:        ETC="${ROMFS_USR2}/etc"
                    222: 
1.8       misho     223:        echo "+++ Install ELWIX RomFS secondary firmware ... ${ROMFS_USR2}"
1.6       misho     224: 
                    225:        StripFiles \*.so\* ${PKG}/lib
                    226:        InstallFiles \*.so\* ${PKG}/lib $LIBS
                    227:        StripFiles \* ${PKG}/libexec
                    228:        InstallFiles \* ${PKG}/libexec $LIBEXEC
                    229:        StripFiles \* ${PKG}/bin
                    230:        InstallFiles \* ${PKG}/bin $BIN
                    231:        StripFiles \* ${PKG}/sbin
                    232:        InstallFiles \* ${PKG}/sbin $SBIN
                    233: 
                    234:        InstallFiles \* ${PKG}/etc $ETC
                    235: 
                    236:        chown -R root:wheel $SBIN $BIN $LIBDATA $LIBEXEC $LIBS
                    237: }
                    238: 
                    239: build_tools()
                    240: {
1.8       misho     241:        echo "+++ Build ELWIX core firmware image ... ${WORLD}/usr/local --> ${REL}/${LOCALFS_IMG}"
1.6       misho     242: 
                    243:        cd ${WORLD}/usr/local
1.8       misho     244:        find . -name ".debug" -exec rm -rf {} \;
1.6       misho     245:        pax -w -z -v -f${REL}/${LOCALFS_IMG} .
                    246:        cd -
1.8       misho     247: 
                    248:        echo "+++ Completed ELWIX core firmware image ... ${REL}/${LOCALFS_IMG}"
1.2       misho     249: }
                    250: 
                    251: ### main()
1.9     ! misho     252: if [ -n "${1}" ]; then
        !           253:        rm ${WORLD}/usr/local/elwix.ver
        !           254: fi
        !           255: 
1.8       misho     256: if [ "${COMPILE_DEPTOOLS}" = "YES" ]; then
                    257:        compile_deps || exit 1
                    258: fi
1.6       misho     259: 
1.7       misho     260: #if ! SnitVer ${WORLD}/elwix/elwix.ver; then
                    261: #      clean_bootstrap
                    262: #      compile_bootstrap || exit 1
                    263: #
                    264: #      echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >${WORLD}/elwix/elwix.ver
                    265: #else
                    266: #      echo "Skipped ELWIX bootstrap pkgsrc tools build ..."
                    267: #fi
1.2       misho     268: 
                    269: if ! SnitVer ${WORLD}/usr/local/elwix.ver; then
1.7       misho     270:        clean_tools || exit 1
                    271: 
                    272:        compile_fbsdtools || exit 1
                    273:        compile_files || exit 1
                    274:        compile_tools || exit 1
                    275: 
                    276:        build_tools || exit 1
1.6       misho     277: 
                    278:        echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >${WORLD}/usr/local/elwix.ver
1.2       misho     279: else
                    280:        echo "Skipped ELWIX tools build ..."
                    281: fi
                    282: 
                    283: echo "+++ Complete build ELWIX tools"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>