Annotation of elwix/build_tools.sh, revision 1.8.2.1

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.2.1 ! misho       8: # $Id: build_tools.sh,v 1.8 2017/02/13 16:52:46 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.2.1 ! misho     142:        cd $CROSS_FT_CXGB
        !           143:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           144:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           145:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
        !           146:        cd -
        !           147: 
        !           148:        cd $CROSS_FT_IFINFO
        !           149:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           150:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           151:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
        !           152:        cd -
        !           153: 
        !           154:        cd $CROSS_FT_MCTEST
        !           155:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           156:        ${CBUILD} DESTDIR=${WORLD} MK_MAN="no" || exit 1
        !           157:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin MK_MAN="no" BINDIR="" install || exit 1
        !           158:        cd -
1.2       misho     159: 
1.8.2.1 ! misho     160: #      cd $CROSS_FT_NETMAP
1.8       misho     161: #      ${CBUILD} DESTDIR=${WORLD} clean || exit 1
                    162: #      ${CBUILD} DESTDIR=${WORLD} || exit 1
1.8.2.1 ! misho     163: #      ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
1.8       misho     164: #      cd -
1.2       misho     165: 
1.8.2.1 ! misho     166:        cd $CROSS_FT_NETBLAST
        !           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_NETRCV
        !           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 -
        !           177: 
        !           178:        cd $CROSS_FT_NETSND
        !           179:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
        !           180:        ${CBUILD} DESTDIR=${WORLD} || exit 1
        !           181:        ${CBUILD} DESTDIR=${WORLD}/usr/local/bin BINDIR="" install || exit 1
        !           182:        cd -
1.2       misho     183: }
                    184: 
                    185: compile_files()
                    186: {
                    187:        cd files
1.8       misho     188:        ${CBUILD} DESTDIR=${WORLD} clean || exit 1
                    189:        ${CBUILD} DESTDIR=${WORLD} obj || exit 1
                    190:        ${CBUILD} DESTDIR=${WORLD} depend || exit 1
                    191:        ${CBUILD} DESTDIR=${WORLD} || exit 1
                    192:        ${CBUILD} DESTDIR=${WORLD} install || exit 1
1.2       misho     193:        cd -
                    194: }
                    195: 
                    196: compile_tools()
                    197: {
                    198:        echo "+++ Compile ELWIX Cross ..."
                    199: 
1.7       misho     200:        cd $CROSS_ELWIX
1.8       misho     201:        ${CEXEC} INSTALL="/usr/bin/install" ${ELWIX_CFG}
1.2       misho     202:        ${CBUILD} clean
                    203:        ${CBUILD}
                    204:        ${CBUILD} install
                    205:        cd -
                    206: 
1.7       misho     207:        cd $CROSS_AITSCHED
1.8       misho     208:        ${CEXEC} INSTALL="/usr/bin/install" ${AITSCHED_CFG}
1.2       misho     209:        ${CBUILD} clean
                    210:        ${CBUILD}
                    211:        ${CBUILD} install
                    212:        cd -
                    213: 
                    214:        cd $CROSS_AITIO
1.8       misho     215:        ${CEXEC} INSTALL="/usr/bin/install" ${AITIO_CFG}
1.2       misho     216:        ${CBUILD} clean
                    217:        ${CBUILD}
                    218:        ${CBUILD} install
                    219:        cd -
                    220: 
                    221:        cd $CROSS_AITCFG
1.8       misho     222:        ${CEXEC} INSTALL="/usr/bin/install" ${AITCFG_CFG}
1.2       misho     223:        ${CBUILD} clean
                    224:        ${CBUILD}
                    225:        ${CBUILD} install
                    226:        cd -
                    227: 
1.6       misho     228:        cd $CROSS_AITRPC
1.8       misho     229:        ${CEXEC} INSTALL="/usr/bin/install" ${AITRPC_CFG}
1.2       misho     230:        ${CBUILD} clean
                    231:        ${CBUILD}
                    232:        ${CBUILD} install
                    233:        cd -
                    234: 
                    235:        cd $CROSS_AITWWW
1.8       misho     236:        ${CEXEC} INSTALL="/usr/bin/install" ${AITWWW_CFG}
1.2       misho     237:        ${CBUILD} clean
                    238:        ${CBUILD}
                    239:        ${CBUILD} install
                    240:        cd -
                    241: 
                    242:        cd $CROSS_AITPELCO
1.8       misho     243:        ${CEXEC} INSTALL="/usr/bin/install" ${AITPELCO_CFG}
1.2       misho     244:        ${CBUILD} clean
                    245:        ${CBUILD}
                    246:        ${CBUILD} install
                    247:        cd -
                    248: 
                    249:        cd $CROSS_AITSYNC
1.8       misho     250:        ${CEXEC} INSTALL="/usr/bin/install" ${AITSYNC_CFG}
1.2       misho     251:        ${CBUILD} clean
                    252:        ${CBUILD}
                    253:        ${CBUILD} install
                    254:        cd -
                    255: 
                    256:        cd $CROSS_AITCLI
1.8       misho     257:        ${CEXEC} INSTALL="/usr/bin/install" ${AITCLI_CFG}
1.2       misho     258:        ${CBUILD} clean
                    259:        ${CBUILD}
                    260:        ${CBUILD} install
                    261:        cd -
                    262: 
                    263:        cd $CROSS_AITMQTT
1.8       misho     264:        ${CEXEC} INSTALL="/usr/bin/install" ${AITMQTT_CFG}
1.2       misho     265:        ${CBUILD} clean
                    266:        ${CBUILD}
                    267:        ${CBUILD} install
                    268:        cd -
                    269: 
                    270:        cd $CROSS_EMBEDTOOLS
1.8       misho     271:        ${CEXEC} INSTALL="/usr/bin/install" ${EMBEDTOOLS_CFG}
1.2       misho     272:        ${CBUILD} clean
                    273:        ${CBUILD}
                    274:        ${CBUILD} install
                    275:        cd -
                    276: 
                    277:        cd $CROSS_ANSH
1.8       misho     278:        ${CEXEC} INSTALL="/usr/bin/install" ${ANSH_CFG}
1.2       misho     279:        ${CBUILD} clean
                    280:        ${CBUILD}
                    281:        ${CBUILD} install
                    282:        cd -
                    283: 
                    284:        cd $CROSS_MQTT
1.8       misho     285:        ${CEXEC} INSTALL="/usr/bin/install" ${MQTT_CFG}
1.2       misho     286:        ${CBUILD} clean
                    287:        ${CBUILD}
                    288:        ${CBUILD} install
                    289:        cd -
                    290: 
1.6       misho     291:        cd $CROSS_WIFINATOR
1.8       misho     292:        ${CEXEC} INSTALL="/usr/bin/install" ${WIFINATOR_CFG}
1.6       misho     293:        ${CBUILD} clean
                    294:        ${CBUILD}
                    295:        ${CBUILD} install
                    296:        cd -
1.7       misho     297: 
                    298:        cd $CROSS_TFTPD
1.8       misho     299:        ${CEXEC} INSTALL="/usr/bin/install" ${TFTPD_CFG}
1.7       misho     300:        ${CBUILD} clean
                    301:        ${CBUILD}
                    302:        ${CBUILD} install
                    303:        cd -
1.6       misho     304: }
                    305: 
                    306: install_tools()
                    307: {
                    308:        LIBS="${ROMFS_USR2}/lib"
                    309:        LIBEXEC="${ROMFS_USR2}/libexec"
                    310:        BIN="${ROMFS_USR2}/bin"
                    311:        SBIN="${ROMFS_USR2}/sbin"
                    312:        ETC="${ROMFS_USR2}/etc"
                    313: 
1.8       misho     314:        echo "+++ Install ELWIX RomFS secondary firmware ... ${ROMFS_USR2}"
1.6       misho     315: 
                    316:        StripFiles \*.so\* ${PKG}/lib
                    317:        InstallFiles \*.so\* ${PKG}/lib $LIBS
                    318:        StripFiles \* ${PKG}/libexec
                    319:        InstallFiles \* ${PKG}/libexec $LIBEXEC
                    320:        StripFiles \* ${PKG}/bin
                    321:        InstallFiles \* ${PKG}/bin $BIN
                    322:        StripFiles \* ${PKG}/sbin
                    323:        InstallFiles \* ${PKG}/sbin $SBIN
                    324: 
                    325:        InstallFiles \* ${PKG}/etc $ETC
                    326: 
                    327:        chown -R root:wheel $SBIN $BIN $LIBDATA $LIBEXEC $LIBS
                    328: }
                    329: 
                    330: build_tools()
                    331: {
1.8       misho     332:        echo "+++ Build ELWIX core firmware image ... ${WORLD}/usr/local --> ${REL}/${LOCALFS_IMG}"
1.6       misho     333: 
                    334:        cd ${WORLD}/usr/local
1.8       misho     335:        find . -name ".debug" -exec rm -rf {} \;
1.6       misho     336:        pax -w -z -v -f${REL}/${LOCALFS_IMG} .
                    337:        cd -
1.8       misho     338: 
                    339:        echo "+++ Completed ELWIX core firmware image ... ${REL}/${LOCALFS_IMG}"
1.2       misho     340: }
                    341: 
                    342: ### main()
1.8       misho     343: if [ "${COMPILE_DEPTOOLS}" = "YES" ]; then
                    344:        compile_deps || exit 1
                    345: fi
1.6       misho     346: 
1.7       misho     347: #if ! SnitVer ${WORLD}/elwix/elwix.ver; then
                    348: #      clean_bootstrap
                    349: #      compile_bootstrap || exit 1
                    350: #
                    351: #      echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >${WORLD}/elwix/elwix.ver
                    352: #else
                    353: #      echo "Skipped ELWIX bootstrap pkgsrc tools build ..."
                    354: #fi
1.2       misho     355: 
                    356: if ! SnitVer ${WORLD}/usr/local/elwix.ver; then
1.7       misho     357:        clean_tools || exit 1
                    358: 
                    359:        compile_fbsdtools || exit 1
                    360:        compile_files || exit 1
                    361:        compile_tools || exit 1
                    362: 
                    363:        build_tools || exit 1
1.6       misho     364: 
                    365:        echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >${WORLD}/usr/local/elwix.ver
1.2       misho     366: else
                    367:        echo "Skipped ELWIX tools build ..."
                    368: fi
                    369: 
                    370: echo "+++ Complete build ELWIX tools"

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