mirror of
https://github.com/richfelker/musl-cross-make.git
synced 2025-04-19 07:24:59 +02:00
53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
HERE=$(dirname $(readlink -f ${0}))
|
|
|
|
LOGS=${HERE}/../logs
|
|
BINS=${HERE}/../output
|
|
OBJS=${HERE}/../build
|
|
|
|
CSUF=cross
|
|
NSUF=native
|
|
|
|
KALE="${PATH}"
|
|
MCMT=;
|
|
|
|
##
|
|
# Check whether target triple is specified.
|
|
#
|
|
test ${#} != 1 && printf "No target triple specified!\n" && exit 1;
|
|
|
|
##
|
|
# When 'MCMTOOLS' is specified, ensure it is valid (at first glance).
|
|
#
|
|
if ! test -z ${MCMTOOLS}; then
|
|
MCMT="${MCMTOOLS%/}";
|
|
fail=0;
|
|
test -d "${MCMT}/sys/bin" || fail=1;
|
|
test -d "${MCMT}/host/bin" || fail=1;
|
|
test -d "${MCMT}/musl/bin" || fail=1;
|
|
test $fail -eq 1 && printf "Using 'MCMTOOLS=%s' is not valid.\n" "${MCMTOOLS}" && exit 1;
|
|
fi
|
|
|
|
mkdir -p ${LOGS} ${BINS}
|
|
|
|
# CROSS BUILD INSTALL
|
|
if ! test -z ${MCMT}; then
|
|
export PATH="${MCMT}/sys/bin:${MCMT}/musl/bin";
|
|
else
|
|
export PATH="${KALE}";
|
|
fi
|
|
[ -d ${BINS}/${1}-${CSUF} ] || make install \
|
|
TARGET=${1} OUTPUT=${BINS}/${1}-${CSUF} \
|
|
2>&1 | tee ${LOGS}/${1}-${CSUF}.log
|
|
|
|
# CROSS SCRATCH CLEANUP
|
|
rm -fr ${OBJS}/local/${1}
|
|
|
|
# CROSS PACKAGE
|
|
[ -h ${BINS}/${1}-${CSUF}/usr ] || (cd ${BINS}/${1}-${CSUF} && ln -s . usr)
|
|
[ -e ${BINS}/${1}-${CSUF}.tgz ] || (cd ${BINS} && tar pczf ${1}-${CSUF}.tgz ${1}-${CSUF})
|
|
|
|
# CROSS DIRECTORY CLEANUP (if native fails, this remains)
|
|
rm -fr ${BINS}/${1}-${CSUF};
|