Annotation of elwix/build_tools.sh, revision 1.8

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.8     ! misho       8: # $Id: build_tools.sh,v 1.7.2.6 2017/01/22 21:36:40 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.3       misho     129:        cd $CROSS_FT_VIMAGE
1.8     ! misho     130:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           131:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           132:        ${CBUILD} DESTDIR=${WORLD} install || exit 1
1.2       misho     133:        cd -
                    134: 
1.3       misho     135:        cd $CROSS_FT_ATH
1.8     ! misho     136:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           137:        cp ${CROSSTOOLDIR}/usr/include/private/bsdstat/bsdstat.h ${BSDTOOLS}/ath/common || exit 1
        !           138:        ${CBUILD} DESTDIR=${WORLD} LIBBSDSTATDIR="${BSDSTATDIR}" || exit 1
        !           139:        ${CBUILD} DESTDIR=${WORLD} install || exit 1
1.7       misho     140:        cd -
                    141: 
1.8     ! misho     142: #      cd $CROSS_FT_IPW
        !           143: #      ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           144: #      ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           145: #      ${CBUILD} DESTDIR=${WORLD}/usr/local/bin install || exit 1
        !           146: #      cd -
1.2       misho     147: 
1.8     ! misho     148: #      cd $CROSS_FT_IWI
        !           149: #      ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           150: #      ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           151: #      ${CBUILD} DESTDIR=${WORLD}/usr/local/bin install || exit 1
        !           152: #      cd -
1.2       misho     153: 
1.8     ! misho     154: #      cd $CROSS_FT_MWL
        !           155: #      ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           156: #      cp ${CROSSTOOLDIR}/usr/include/private/bsdstat/bsdstat.h ${BSDTOOLS}/mwl/mwlstats || exit 1
        !           157: #      ${CBUILD} DESTDIR=${WORLD} LIBBSDSTATDIR="${BSDSTATDIR}" || exit 1
        !           158: #      ${CBUILD} DESTDIR=${WORLD} install || exit 1
        !           159: #      cd -
1.2       misho     160: }
                    161: 
                    162: compile_files()
                    163: {
                    164:        cd files
1.8     ! misho     165:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           166:        ${CBUILD} DESTDIR=${WORLD} obj || exit 1
        !           167:        ${CBUILD} DESTDIR=${WORLD} depend || exit 1
        !           168:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           169:        ${CBUILD} DESTDIR=${WORLD} install || exit 1
1.2       misho     170:        cd -
                    171: }
                    172: 
                    173: compile_tools()
                    174: {
                    175:        echo "+++ Compile ELWIX Cross ..."
                    176: 
1.7       misho     177:        cd $CROSS_ELWIX
1.8     ! misho     178:        ${CEXEC} INSTALL="/usr/bin/install" ${ELWIX_CFG}
1.2       misho     179:        ${CBUILD} clean
                    180:        ${CBUILD}
                    181:        ${CBUILD} install
                    182:        cd -
                    183: 
1.7       misho     184:        cd $CROSS_AITSCHED
1.8     ! misho     185:        ${CEXEC} INSTALL="/usr/bin/install" ${AITSCHED_CFG}
1.2       misho     186:        ${CBUILD} clean
                    187:        ${CBUILD}
                    188:        ${CBUILD} install
                    189:        cd -
                    190: 
                    191:        cd $CROSS_AITIO
1.8     ! misho     192:        ${CEXEC} INSTALL="/usr/bin/install" ${AITIO_CFG}
1.2       misho     193:        ${CBUILD} clean
                    194:        ${CBUILD}
                    195:        ${CBUILD} install
                    196:        cd -
                    197: 
                    198:        cd $CROSS_AITCFG
1.8     ! misho     199:        ${CEXEC} INSTALL="/usr/bin/install" ${AITCFG_CFG}
1.2       misho     200:        ${CBUILD} clean
                    201:        ${CBUILD}
                    202:        ${CBUILD} install
                    203:        cd -
                    204: 
1.6       misho     205:        cd $CROSS_AITRPC
1.8     ! misho     206:        ${CEXEC} INSTALL="/usr/bin/install" ${AITRPC_CFG}
1.2       misho     207:        ${CBUILD} clean
                    208:        ${CBUILD}
                    209:        ${CBUILD} install
                    210:        cd -
                    211: 
                    212:        cd $CROSS_AITWWW
1.8     ! misho     213:        ${CEXEC} INSTALL="/usr/bin/install" ${AITWWW_CFG}
1.2       misho     214:        ${CBUILD} clean
                    215:        ${CBUILD}
                    216:        ${CBUILD} install
                    217:        cd -
                    218: 
                    219:        cd $CROSS_AITPELCO
1.8     ! misho     220:        ${CEXEC} INSTALL="/usr/bin/install" ${AITPELCO_CFG}
1.2       misho     221:        ${CBUILD} clean
                    222:        ${CBUILD}
                    223:        ${CBUILD} install
                    224:        cd -
                    225: 
                    226:        cd $CROSS_AITSYNC
1.8     ! misho     227:        ${CEXEC} INSTALL="/usr/bin/install" ${AITSYNC_CFG}
1.2       misho     228:        ${CBUILD} clean
                    229:        ${CBUILD}
                    230:        ${CBUILD} install
                    231:        cd -
                    232: 
                    233:        cd $CROSS_AITCLI
1.8     ! misho     234:        ${CEXEC} INSTALL="/usr/bin/install" ${AITCLI_CFG}
1.2       misho     235:        ${CBUILD} clean
                    236:        ${CBUILD}
                    237:        ${CBUILD} install
                    238:        cd -
                    239: 
                    240:        cd $CROSS_AITMQTT
1.8     ! misho     241:        ${CEXEC} INSTALL="/usr/bin/install" ${AITMQTT_CFG}
1.2       misho     242:        ${CBUILD} clean
                    243:        ${CBUILD}
                    244:        ${CBUILD} install
                    245:        cd -
                    246: 
                    247:        cd $CROSS_EMBEDTOOLS
1.8     ! misho     248:        ${CEXEC} INSTALL="/usr/bin/install" ${EMBEDTOOLS_CFG}
1.2       misho     249:        ${CBUILD} clean
                    250:        ${CBUILD}
                    251:        ${CBUILD} install
                    252:        cd -
                    253: 
                    254:        cd $CROSS_ANSH
1.8     ! misho     255:        ${CEXEC} INSTALL="/usr/bin/install" ${ANSH_CFG}
1.2       misho     256:        ${CBUILD} clean
                    257:        ${CBUILD}
                    258:        ${CBUILD} install
                    259:        cd -
                    260: 
                    261:        cd $CROSS_MQTT
1.8     ! misho     262:        ${CEXEC} INSTALL="/usr/bin/install" ${MQTT_CFG}
1.2       misho     263:        ${CBUILD} clean
                    264:        ${CBUILD}
                    265:        ${CBUILD} install
                    266:        cd -
                    267: 
1.6       misho     268:        cd $CROSS_WIFINATOR
1.8     ! misho     269:        ${CEXEC} INSTALL="/usr/bin/install" ${WIFINATOR_CFG}
1.6       misho     270:        ${CBUILD} clean
                    271:        ${CBUILD}
                    272:        ${CBUILD} install
                    273:        cd -
1.7       misho     274: 
                    275:        cd $CROSS_TFTPD
1.8     ! misho     276:        ${CEXEC} INSTALL="/usr/bin/install" ${TFTPD_CFG}
1.7       misho     277:        ${CBUILD} clean
                    278:        ${CBUILD}
                    279:        ${CBUILD} install
                    280:        cd -
1.6       misho     281: }
                    282: 
                    283: install_tools()
                    284: {
                    285:        LIBS="${ROMFS_USR2}/lib"
                    286:        LIBEXEC="${ROMFS_USR2}/libexec"
                    287:        BIN="${ROMFS_USR2}/bin"
                    288:        SBIN="${ROMFS_USR2}/sbin"
                    289:        ETC="${ROMFS_USR2}/etc"
                    290: 
1.8     ! misho     291:        echo "+++ Install ELWIX RomFS secondary firmware ... ${ROMFS_USR2}"
1.6       misho     292: 
                    293:        StripFiles \*.so\* ${PKG}/lib
                    294:        InstallFiles \*.so\* ${PKG}/lib $LIBS
                    295:        StripFiles \* ${PKG}/libexec
                    296:        InstallFiles \* ${PKG}/libexec $LIBEXEC
                    297:        StripFiles \* ${PKG}/bin
                    298:        InstallFiles \* ${PKG}/bin $BIN
                    299:        StripFiles \* ${PKG}/sbin
                    300:        InstallFiles \* ${PKG}/sbin $SBIN
                    301: 
                    302:        InstallFiles \* ${PKG}/etc $ETC
                    303: 
                    304:        chown -R root:wheel $SBIN $BIN $LIBDATA $LIBEXEC $LIBS
                    305: }
                    306: 
                    307: build_tools()
                    308: {
1.8     ! misho     309:        echo "+++ Build ELWIX core firmware image ... ${WORLD}/usr/local --> ${REL}/${LOCALFS_IMG}"
1.6       misho     310: 
                    311:        cd ${WORLD}/usr/local
1.8     ! misho     312:        find . -name ".debug" -exec rm -rf {} \;
1.6       misho     313:        pax -w -z -v -f${REL}/${LOCALFS_IMG} .
                    314:        cd -
1.8     ! misho     315: 
        !           316:        echo "+++ Completed ELWIX core firmware image ... ${REL}/${LOCALFS_IMG}"
1.2       misho     317: }
                    318: 
                    319: ### main()
1.8     ! misho     320: if [ "${COMPILE_DEPTOOLS}" = "YES" ]; then
        !           321:        compile_deps || exit 1
        !           322: fi
1.6       misho     323: 
1.7       misho     324: #if ! SnitVer ${WORLD}/elwix/elwix.ver; then
                    325: #      clean_bootstrap
                    326: #      compile_bootstrap || exit 1
                    327: #
                    328: #      echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >${WORLD}/elwix/elwix.ver
                    329: #else
                    330: #      echo "Skipped ELWIX bootstrap pkgsrc tools build ..."
                    331: #fi
1.2       misho     332: 
                    333: if ! SnitVer ${WORLD}/usr/local/elwix.ver; then
1.7       misho     334:        clean_tools || exit 1
                    335: 
                    336:        compile_fbsdtools || exit 1
                    337:        compile_files || exit 1
                    338:        compile_tools || exit 1
                    339: 
                    340:        build_tools || exit 1
1.6       misho     341: 
                    342:        echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >${WORLD}/usr/local/elwix.ver
1.2       misho     343: else
                    344:        echo "Skipped ELWIX tools build ..."
                    345: fi
                    346: 
                    347: echo "+++ Complete build ELWIX tools"

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