#! /bin/bash PROJECT=musl # Available sub-projects. AVAILABLE_PROJECTS=( musl ) # Enabled sub-projects. PROJECTS=( musl ) # Additional options (see functions sources below). # Options followed by a ':' require an argument, by '::' allow an optional argument. SHORT_OPTIONS= # Long options are not available with BSD getopt. LONG_OPTIONS= # Help for additional options usage() { # option h "help" "display this help and exit" return } # Find the directory containing this script. source="${BASH_SOURCE[0]}" while [ -h "${source}" ] ; do SCRIPTS="$(cd -P "$(dirname "${source}")" && pwd)" source="$(readlink "${source}")" [[ ${source} != /* ]] && source="$DIR/${source}" done SCRIPTS="$(cd -P "$(dirname "${source}")" && pwd)" # Get support functions and definitions. source ${SCRIPTS}/support # Projects. musl="${SRCTOP} git://git.musl-libc.org/musl musl git" # Check for needed libraries. check_libraries() { check_library libcompiler-rt.a "Run ${SCRIPTS}/build-compiler-rt." if [ $? -eq 1 ] ; then echo "Just installing musl headers." INSTALL_TARGET=install-headers else INSTALL_TARGET=install fi } local=${LOCAL}/musl/${TARGETTUPLE} configure() { # Configure checked out projects. run check_checkout run check_libraries run mkdir -p ${BUILDDIR} run cd ${BUILDDIR} run CC="${CC}" CFLAGS="${CFLAGS}" \ CROSS_COMPILE=$(dirname ${RANLIB})/$(basename ${RANLIB} ranlib) \ LDFLAGS=-L${LOCALLIB} LIBCC=-lcompiler-rt \ ${PROJECTDIR}/configure \ --target=${TARGETTUPLE} --enable-warnings --enable-debug --enable-depends \ --prefix=${local} --syslibdir=${local}/lib } tests() { # Run regression tests. run cd ${BUILDDIR} run ${MAKE} -j ${MAXJOBS} -C ${BUILDDIR} check } install() { run check_checkout run check_configure check_libraries run ${MAKE} -j ${MAXJOBS} -C ${BUILDDIR} ${INSTALL_TARGET} || exit 1 if [ "${INSTALL_TARGET}" = "install" ] ; then run mkdir -p ${LOCALLIB} run cp -pr ${local}/lib/* ${LOCALLIB} run echo ${LOCALLIB} | run tee ${LOCALLIB}/ld-musl.path fi run mkdir -p ${LOCALLIBECC}/include run cp -pr ${local}/include/* ${LOCALLIBECC}/include run mkdir -p ${LOCALLIBECC}/include/$(getincarch ${TARGETTUPLE})/bits run cp -pr ${LOCALLIBECC}/include/bits/* ${LOCALLIBECC}/include/$(getincarch ${TARGETTUPLE})/bits } if [ "${CHECKOUT}" == "y" ] ; then checkout || exit 1 fi if [ "${CONFIGURE}" == "y" ] ; then configure || exit 1 fi if [ "${UPDATE}" == "y" ] ; then update || exit 1 fi if [ "${PATCH}" == "y" ] ; then patch || exit 1 fi if [ "${CREATE_PATCH}" == "y" ] ; then create_patch || exit 1 fi if [ "${BUILD}" == "y" ] ; then build || exit 1 fi if [ "${TESTS}" == "y" ] ; then tests || exit 1 fi if [ "${INSTALL}" == "y" ] ; then install || exit 1 fi