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

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