WangNan0 / kbuild-standalone

Standalone kconfig and kbuild
GNU General Public License v2.0
54 stars 18 forks source link

how to cross build #5

Closed terefang closed 1 year ago

terefang commented 1 year ago

trying to (cross) build statically against musl and netbsd-curses

configure does not pickup properly

AndreiCherniaev commented 2 days ago

cross build is very interesting. Can you provide any step by step example?

terefang commented 1 hour ago

this is the important par of the build script that is use

T=$(path_static_toolchain)

export PATH=$PATH:$T/bin
SDIR=$(get_pkg_srcdir)
BDIR=$(get_pkg_builddir)
YDIR=$(get_sysdir)

# kconfig main
gzip -d < $SDIR/source.tar.gz | tar -xf - --strip 1 -C $BDIR

CC=x86_64-linux-musl-gcc 
CCOPTS="--static -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -D_GNU_SOURCE"

### standalone build
mkdir -p ${BDIR}/xbin
cd $BDIR && (
    flex -o kconfig/lexer.lex.c -L kconfig/lexer.l
    bison -o kconfig/parser.tab.c --defines=kconfig/parser.tab.h -t -l kconfig/parser.y
    for x in kconfig/*.c; do
        echo SED $x
        sed -i -e 's/ kernel/ project/' $x
    done
    for x in kconfig/lxdialog/*.c kconfig/*.c unifdef/*.c fixdep/*.c; do
        D=$(dirname $x)
        B=$(basename $x .c)
        echo CC $D/$B
        $CC $CCOPTS -I ./kconfig -c -o $D/$B.o $D/$B.c
    done
    OBJ="kconfig/confdata.o kconfig/expr.o kconfig/lexer.lex.o kconfig/menu.o kconfig/parser.tab.o kconfig/preprocess.o kconfig/symbol.o kconfig/util.o"
    $CC -static -o ${BDIR}/xbin/kconfig-conf kconfig/conf.o \
        $OBJ
    $CC -static -o ${BDIR}/xbin/kconfig-mconf kconfig/mconf.o \
        kconfig/lxdialog/*.o $OBJ \
        -lncursesw -lterminfo
    $CC -static -o ${BDIR}/xbin/kconfig-unifdef unifdef/*.o
    $CC -static -o ${BDIR}/xbin/kconfig-fixdep fixdep/*.o
    cp ${PDIR}/src/merge_config.sh cp ${BDIR}/xbin/kconfig-merge
)

mkdir -p ${YDIR}/system/xbin
cd $BDIR && cp ${BDIR}/xbin/kconfig-* ${YDIR}/system/xbin/