2019-08-10 17:57:26 +02:00
|
|
|
#!/usr/bin/env bash
|
2011-07-12 00:52:51 +02:00
|
|
|
# tools/mkexport.sh
|
|
|
|
#
|
2024-09-10 14:15:58 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership. The
|
|
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance with the
|
|
|
|
# License. You may obtain a copy of the License at
|
2011-07-12 00:52:51 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2011-07-12 00:52:51 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2011-07-12 00:52:51 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
# Get the input parameter list
|
|
|
|
|
2020-08-31 08:40:02 +02:00
|
|
|
USAGE="USAGE: $0 [-d] [-z] [-u] [-t <top-dir> [-x <lib-ext>] [-a <apps-dir>] [-m <make-exe>] -l \"lib1 [lib2 [lib3 ...]]\""
|
2011-07-12 00:52:51 +02:00
|
|
|
unset TOPDIR
|
|
|
|
unset LIBLIST
|
2011-07-13 01:54:13 +02:00
|
|
|
unset TGZ
|
2019-08-30 15:19:15 +02:00
|
|
|
unset APPDIR
|
2020-06-28 14:02:32 +02:00
|
|
|
unset BOARDDIR
|
2019-08-30 15:19:15 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
USRONLY=n
|
2011-07-12 00:52:51 +02:00
|
|
|
LIBEXT=.a
|
|
|
|
|
|
|
|
while [ ! -z "$1" ]; do
|
2020-01-05 17:29:59 +01:00
|
|
|
case $1 in
|
|
|
|
-a )
|
|
|
|
shift
|
|
|
|
APPDIR="$1"
|
|
|
|
;;
|
2020-06-28 14:02:32 +02:00
|
|
|
-b )
|
|
|
|
shift
|
|
|
|
BOARDDIR="$1"
|
|
|
|
;;
|
2020-01-05 17:29:59 +01:00
|
|
|
-d )
|
|
|
|
set -x
|
|
|
|
;;
|
|
|
|
-l )
|
|
|
|
shift
|
|
|
|
LIBLIST=$1
|
|
|
|
;;
|
|
|
|
-m )
|
|
|
|
shift
|
|
|
|
MAKE="$1"
|
|
|
|
;;
|
|
|
|
-t )
|
|
|
|
shift
|
|
|
|
TOPDIR=$1
|
|
|
|
;;
|
|
|
|
-u )
|
|
|
|
USRONLY=y
|
|
|
|
;;
|
|
|
|
-x )
|
|
|
|
shift
|
|
|
|
LIBEXT=$1
|
|
|
|
;;
|
|
|
|
-z )
|
|
|
|
TGZ=y
|
|
|
|
;;
|
|
|
|
-h )
|
|
|
|
echo $USAGE
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "Unrecognized argument: $1"
|
|
|
|
echo $USAGE
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2011-07-12 00:52:51 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# Check arguments
|
|
|
|
|
2011-07-12 05:21:27 +02:00
|
|
|
if [ -z "${TOPDIR}" -o -z "${LIBLIST}" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "MK: Missing required arguments"
|
|
|
|
echo $USAGE
|
|
|
|
exit 1
|
2011-07-12 00:52:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "${TOPDIR}" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "MK: Directory ${TOPDIR} does not exist"
|
|
|
|
exit 1
|
2011-07-12 00:52:51 +02:00
|
|
|
fi
|
|
|
|
|
2014-09-05 15:37:44 +02:00
|
|
|
# Check configuration
|
|
|
|
# Verify that we have Make.defs, .config, and .version files.
|
|
|
|
|
|
|
|
if [ ! -f "${TOPDIR}/Make.defs" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "MK: Directory ${TOPDIR}/Make.defs does not exist"
|
|
|
|
exit 1
|
2014-09-05 15:37:44 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "${TOPDIR}/.config" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "MK: Directory ${TOPDIR}/.config does not exist"
|
|
|
|
exit 1
|
2014-09-05 15:37:44 +02:00
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
|
|
|
|
if [ ! -f "${TOPDIR}/.version" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "MK: File ${TOPDIR}/.version does not exist"
|
|
|
|
exit 1
|
2011-07-12 00:52:51 +02:00
|
|
|
fi
|
|
|
|
|
2016-05-06 12:49:25 +02:00
|
|
|
# Check if the make environment variable has been defined
|
|
|
|
|
|
|
|
if [ -z "${MAKE}" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
MAKE=`which make`
|
2016-05-06 12:49:25 +02:00
|
|
|
fi
|
|
|
|
|
2014-09-05 15:37:44 +02:00
|
|
|
# Get the version string
|
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
source "${TOPDIR}/.version"
|
|
|
|
if [ ! -z "${CONFIG_VERSION_STRING}" -a "${CONFIG_VERSION_STRING}" != "0.0" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
VERSION="-${CONFIG_VERSION_STRING}"
|
2011-07-12 00:52:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the export directory
|
|
|
|
|
|
|
|
EXPORTSUBDIR="nuttx-export${VERSION}"
|
|
|
|
EXPORTDIR="${TOPDIR}/${EXPORTSUBDIR}"
|
|
|
|
|
|
|
|
# If the export directory already exists, then remove it and create a new one
|
|
|
|
|
|
|
|
if [ -d "${EXPORTDIR}" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "MK: Removing old export directory"
|
|
|
|
rm -rf "${EXPORTDIR}"
|
2011-07-12 00:52:51 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-13 01:54:13 +02:00
|
|
|
# Remove any possible previous results
|
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
rm -f "${EXPORTDIR}.tar"
|
2011-07-13 01:54:13 +02:00
|
|
|
rm -f "${EXPORTDIR}.zip"
|
2011-07-12 00:52:51 +02:00
|
|
|
rm -f "${EXPORTDIR}.tar.gz"
|
|
|
|
|
2011-07-13 01:54:13 +02:00
|
|
|
# Create the export directory and some of its subdirectories
|
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
mkdir "${EXPORTDIR}" || { echo "MK: 'mkdir ${EXPORTDIR}' failed"; exit 1; }
|
|
|
|
mkdir "${EXPORTDIR}/startup" || { echo "MK: 'mkdir ${EXPORTDIR}/startup' failed"; exit 1; }
|
|
|
|
mkdir "${EXPORTDIR}/libs" || { echo "MK: 'mkdir ${EXPORTDIR}/libs' failed"; exit 1; }
|
2019-10-01 15:54:11 +02:00
|
|
|
mkdir "${EXPORTDIR}/scripts" || { echo "MK: 'mkdir ${EXPORTDIR}/scripts' failed"; exit 1; }
|
|
|
|
mkdir "${EXPORTDIR}/tools" || { echo "MK: 'mkdir ${EXPORTDIR}/tools' failed"; exit 1; }
|
2014-09-04 20:19:47 +02:00
|
|
|
|
|
|
|
if [ "X${USRONLY}" != "Xy" ]; then
|
|
|
|
mkdir "${EXPORTDIR}/arch" || { echo "MK: 'mkdir ${EXPORTDIR}/arch' failed"; exit 1; }
|
|
|
|
fi
|
2011-07-12 05:21:27 +02:00
|
|
|
|
2014-09-05 15:37:44 +02:00
|
|
|
# Copy the .config file
|
2011-07-12 05:21:27 +02:00
|
|
|
|
2014-09-05 15:37:44 +02:00
|
|
|
cp -a "${TOPDIR}/.config" "${EXPORTDIR}/.config" ||
|
|
|
|
{ echo "MK: Failed to copy ${TOPDIR}/.config to ${EXPORTDIR}/.config"; exit 1; }
|
2011-07-12 05:21:27 +02:00
|
|
|
|
2020-05-18 16:18:15 +02:00
|
|
|
# Copy the Make.defs files
|
2011-07-12 05:21:27 +02:00
|
|
|
|
2020-05-18 16:18:15 +02:00
|
|
|
cp -a "${TOPDIR}/Make.defs" "${EXPORTDIR}/Make.defs" ||
|
|
|
|
{ echo "MK: Failed to copy ${TOPDIR}/Make.defs to ${EXPORTDIR}/Make.defs"; exit 1; }
|
2011-07-12 05:21:27 +02:00
|
|
|
|
|
|
|
# Extract information from the Make.defs file. A Makefile can do this best
|
|
|
|
|
2022-01-04 22:06:58 +01:00
|
|
|
${MAKE} -C "${TOPDIR}/tools" -f Export.mk TOPDIR="${TOPDIR}" EXPORTDIR="${EXPORTDIR}"
|
2011-07-12 05:21:27 +02:00
|
|
|
source "${EXPORTDIR}/makeinfo.sh"
|
|
|
|
rm -f "${EXPORTDIR}/makeinfo.sh"
|
|
|
|
rm -f "${EXPORTDIR}/Make.defs"
|
|
|
|
|
2011-07-13 01:54:13 +02:00
|
|
|
# Verify the build info that we got from makeinfo.sh
|
2011-07-12 05:21:27 +02:00
|
|
|
|
|
|
|
if [ ! -d "${ARCHDIR}" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "MK: Directory ${ARCHDIR} does not exist"
|
|
|
|
exit 1
|
2011-07-12 05:21:27 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-24 04:14:09 +02:00
|
|
|
# Copy the depends script
|
|
|
|
|
|
|
|
cp "${TOPDIR}/tools/mkdeps.c" "${EXPORTDIR}/tools/."
|
2020-06-30 05:29:47 +02:00
|
|
|
cp "${TOPDIR}/tools/incdir.c" "${EXPORTDIR}/tools/."
|
2020-06-24 04:14:09 +02:00
|
|
|
|
2023-06-26 08:17:23 +02:00
|
|
|
# Copy the board specific linker if found, or use the default when not.
|
2019-10-01 15:54:11 +02:00
|
|
|
|
2024-04-22 06:38:38 +02:00
|
|
|
APPLD=gnu-elf.ld
|
|
|
|
if [ -f "${BOARDDIR}/scripts/${APPLD}" ]; then
|
|
|
|
cp -f "${BOARDDIR}/scripts/${APPLD}" "${EXPORTDIR}/scripts/."
|
2023-06-26 08:17:23 +02:00
|
|
|
else
|
2024-04-22 06:38:38 +02:00
|
|
|
cp -f "${TOPDIR}/binfmt/libelf/${APPLD}" "${EXPORTDIR}/scripts/."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${NUTTX_BUILD}" = "kernel" ]; then
|
|
|
|
LDNAME=${APPLD}
|
2023-06-26 08:17:23 +02:00
|
|
|
fi
|
2019-10-01 15:54:11 +02:00
|
|
|
|
2020-06-28 14:02:32 +02:00
|
|
|
# Copy the board config script
|
|
|
|
|
|
|
|
if [ -f "${BOARDDIR}/scripts/Config.mk" ]; then
|
|
|
|
cp -f "${BOARDDIR}/scripts/Config.mk" "${EXPORTDIR}/scripts/."
|
|
|
|
fi
|
|
|
|
|
2011-07-13 01:54:13 +02:00
|
|
|
# Is there a linker script in this configuration?
|
|
|
|
|
2014-09-04 20:35:47 +02:00
|
|
|
if [ "X${USRONLY}" != "Xy" ]; then
|
2020-03-03 05:59:12 +01:00
|
|
|
|
|
|
|
# LDPATH can contain multiple files.
|
|
|
|
# The "Copy additional ld scripts" step might copy a file multiple times.
|
|
|
|
|
|
|
|
for LDSCRIPT in ${LDPATH}; do
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Apparently so. Verify that the script exists
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2020-03-03 05:59:12 +01:00
|
|
|
if [ ! -f "${LDSCRIPT}" ]; then
|
|
|
|
echo "MK: File ${LDSCRIPT} does not exist"
|
2020-01-05 17:29:59 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Copy the linker script
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2020-03-03 05:59:12 +01:00
|
|
|
cp -p "${LDSCRIPT}" "${EXPORTDIR}/scripts/." || \
|
|
|
|
{ echo "MK: cp ${LDSCRIPT} failed"; exit 1; }
|
2019-08-28 15:49:57 +02:00
|
|
|
|
2020-02-22 19:31:14 +01:00
|
|
|
# Copy additional ld scripts
|
2019-08-28 15:49:57 +02:00
|
|
|
|
2020-03-03 05:59:12 +01:00
|
|
|
LDDIR="$(dirname "${LDSCRIPT}")"
|
2020-01-05 17:29:59 +01:00
|
|
|
for f in "${LDDIR}"/*.ld ; do
|
|
|
|
[ -f "${f}" ] && cp -f "${f}" "${EXPORTDIR}/scripts/."
|
|
|
|
done
|
2020-03-03 05:59:12 +01:00
|
|
|
done
|
2011-07-12 05:21:27 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-13 01:54:13 +02:00
|
|
|
# Save the compilation options
|
2011-07-12 05:21:27 +02:00
|
|
|
|
2019-10-01 15:54:11 +02:00
|
|
|
echo "ARCHCFLAGS = ${ARCHCFLAGS}" >"${EXPORTDIR}/scripts/Make.defs"
|
2020-06-24 04:31:06 +02:00
|
|
|
echo "ARCHCPUFLAGS = ${ARCHCPUFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2019-10-01 15:54:11 +02:00
|
|
|
echo "ARCHCXXFLAGS = ${ARCHCXXFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "ARCHPICFLAGS = ${ARCHPICFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "ARCHWARNINGS = ${ARCHWARNINGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "ARCHWARNINGSXX = ${ARCHWARNINGSXX}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "ARCHOPTIMIZATION = ${ARCHOPTIMIZATION}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "CROSSDEV = ${CROSSDEV}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "CC = ${CC}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "CXX = ${CXX}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "CPP = ${CPP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LD = ${LD}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "AR = ${AR}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "NM = ${NM}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "STRIP = ${STRIP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "OBJCOPY = ${OBJCOPY}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "OBJDUMP = ${OBJDUMP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2024-01-15 14:07:22 +01:00
|
|
|
echo "ZIG = ${ZIG}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "ZIGFLAGS = ${ZIGFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2024-06-05 19:04:34 +02:00
|
|
|
echo "DC = ${DC}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "DFLAGS = ${DFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2024-08-22 16:34:23 +02:00
|
|
|
echo "SWIFTC = ${SWIFTC}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "SWIFTFLAGS = ${SWIFTFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2019-10-01 15:54:11 +02:00
|
|
|
echo "NXFLATLDFLAGS1 = ${NXFLATLDFLAGS1}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "NXFLATLDFLAGS2 = ${NXFLATLDFLAGS2}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "OBJEXT = ${OBJEXT}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LIBEXT = ${LIBEXT}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "EXEEXT = ${EXEEXT}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "HOSTCC = ${HOSTCC}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "HOSTINCLUDES = ${HOSTINCLUDES}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "HOSTCFLAGS = ${HOSTCFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "HOSTLDFLAGS = ${HOSTLDFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "HOSTEXEEXT = ${HOSTEXEEXT}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2020-07-01 04:29:57 +02:00
|
|
|
echo "LDNAME = ${LDNAME}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2023-03-22 02:41:05 +01:00
|
|
|
echo "LDELFFLAGS = ${LDELFFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2024-03-13 10:51:15 +01:00
|
|
|
echo "NUTTX_ARCH = ${NUTTX_ARCH}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "NUTTX_ARCH_CHIP = ${NUTTX_ARCH_CHIP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "NUTTX_BOARD = ${NUTTX_BOARD}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2024-04-22 06:38:38 +02:00
|
|
|
echo "NUTTX_BUILD = ${NUTTX_BUILD}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2024-04-24 17:01:11 +02:00
|
|
|
echo "NUTTX_CXX = ${NUTTX_CXX}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2019-08-28 15:35:44 +02:00
|
|
|
|
2023-08-24 17:15:02 +02:00
|
|
|
echo "set(ARCHCFLAGS \"${ARCHCFLAGS}\")" > "${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(ARCHCPUFLAGS \"${ARCHCPUFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(ARCHCXXFLAGS \"${ARCHCXXFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(ARCHPICFLAGS \"${ARCHPICFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(ARCHWARNINGS \"${ARCHWARNINGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(ARCHWARNINGSXX \"${ARCHWARNINGSXX}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(ARCHOPTIMIZATION \"${ARCHOPTIMIZATION}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(CROSSDEV \"${CROSSDEV}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(CMAKE_C_COMPILER \"${CC}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(CMAKE_CXX_COMPILER \"${CXX}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(CMAKE_LINKER \"${LD}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(CMAKE_OBJCOPY \"${OBJCOPY}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(CMAKE_OBJDUMP \"${OBJDUMP}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(NXFLATLDFLAGS1 \"${NXFLATLDFLAGS1}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(NXFLATLDFLAGS2 \"${NXFLATLDFLAGS2}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(OBJEXT \"${OBJEXT}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(LIBEXT \"${LIBEXT}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(EXEEXT \"${EXEEXT}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(HOSTCC \"${HOSTCC}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(HOSTINCLUDES \"${HOSTINCLUDES}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(HOSTCFLAGS \"${HOSTCFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(HOSTLDFLAGS \"${HOSTLDFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(HOSTEXEEXT \"${HOSTEXEEXT}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(LDNAME \"${LDNAME}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(LDELFFLAGS \"${LDELFFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
2024-03-13 10:51:15 +01:00
|
|
|
echo "set(NUTTX_ARCH \"${NUTTX_ARCH}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(NUTTX_ARCH_CHIP \"${NUTTX_ARCH_CHIP}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(NUTTX_BOARD \"${NUTTX_BOARD}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
2024-04-22 06:38:38 +02:00
|
|
|
echo "set(NUTTX_BUILD \"${NUTTX_BUILD}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
2024-04-24 17:01:11 +02:00
|
|
|
echo "set(NUTTX_CXX \"${NUTTX_CXX}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
2023-08-24 17:15:02 +02:00
|
|
|
|
|
|
|
|
2019-08-28 15:35:44 +02:00
|
|
|
# Additional compilation options when the kernel is built
|
|
|
|
|
2019-08-30 15:19:15 +02:00
|
|
|
if [ "X${USRONLY}" != "Xy" ]; then
|
2020-06-24 04:31:06 +02:00
|
|
|
echo "EXTRA_LIBS = ${EXTRA_LIBS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "EXTRA_OBJS = ${EXTRA_OBJS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "HEAD_OBJ = ${HEAD_OBJ}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LDENDGROUP = ${LDENDGROUP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LDFLAGS = ${LDFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LDSTARTGROUP = ${LDSTARTGROUP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2023-08-24 17:15:02 +02:00
|
|
|
|
|
|
|
echo "set(EXTRA_LIBS \"${EXTRA_LIBS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(EXTRA_OBJS \"${EXTRA_OBJS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(HEAD_OBJ \"${HEAD_OBJ}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(LDENDGROUP \"${LDENDGROUP}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(LDFLAGS \"${LDFLAGS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
|
|
|
echo "set(LDSTARTGROUP \"${LDSTARTGROUP}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
2014-09-05 19:26:42 +02:00
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
|
2023-08-24 17:15:02 +02:00
|
|
|
# Copy the CMake toolchain file
|
|
|
|
|
|
|
|
cp "${TOPDIR}/tools/toolchain.cmake.export" "${EXPORTDIR}/scripts/toolchain.cmake"
|
|
|
|
|
2018-07-09 13:42:42 +02:00
|
|
|
# Copy the system map file(s)
|
2018-07-08 20:18:05 +02:00
|
|
|
|
|
|
|
if [ -r ${TOPDIR}/System.map ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
cp -a "${TOPDIR}/System.map" "${EXPORTDIR}/."
|
2018-07-08 20:18:05 +02:00
|
|
|
fi
|
|
|
|
|
2018-07-09 13:42:42 +02:00
|
|
|
if [ -r ${TOPDIR}/User.map ]; then
|
|
|
|
cp -a "${TOPDIR}/User.map" "${EXPORTDIR}/."
|
|
|
|
fi
|
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
# Copy the NuttX include directory (retaining attributes and following symbolic links)
|
|
|
|
|
2011-12-27 13:44:39 +01:00
|
|
|
cp -LR -p "${TOPDIR}/include" "${EXPORTDIR}/." || \
|
2020-01-05 17:29:59 +01:00
|
|
|
{ echo "MK: 'cp ${TOPDIR}/include' failed"; exit 1; }
|
2011-07-12 00:52:51 +02:00
|
|
|
|
|
|
|
# Copy the startup object file(s)
|
|
|
|
|
2016-05-05 11:40:16 +02:00
|
|
|
${MAKE} -C ${ARCHDIR} export_startup TOPDIR=${TOPDIR} EXPORT_DIR="${EXPORTDIR}"
|
2011-07-12 00:52:51 +02:00
|
|
|
|
2011-08-25 19:55:32 +02:00
|
|
|
# Copy architecture-specific header files into the arch export sub-directory.
|
|
|
|
# This is tricky because each architecture does things in a little different
|
|
|
|
# way.
|
|
|
|
#
|
|
|
|
# First copy any header files in the architecture src/ sub-directory (some
|
|
|
|
# architectures keep all of the header files there, some a few, and others
|
|
|
|
# none
|
|
|
|
|
|
|
|
cp -f "${ARCHDIR}"/*.h "${EXPORTDIR}"/arch/. 2>/dev/null
|
|
|
|
|
|
|
|
# Then look a list of possible places where other architecture-specific
|
|
|
|
# header files might be found. If those places exist (as directories or
|
2014-04-14 00:22:22 +02:00
|
|
|
# as symbolic links to directories, then copy the header files from
|
2011-08-25 19:55:32 +02:00
|
|
|
# those directories into the EXPORTDIR
|
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
if [ "X${USRONLY}" != "Xy" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
ARCH_HDRDIRS="arm armv7-m avr avr32 board common chip mips32"
|
|
|
|
for hdir in $ARCH_HDRDIRS; do
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Does the directory (or symbolic link) exist?
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ -d "${ARCHDIR}/${hdir}" -o -h "${ARCHDIR}/${hdir}" ]; then
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Yes.. create a export sub-directory of the same name
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
mkdir "${EXPORTDIR}/arch/${hdir}" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}' failed"; exit 1; }
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Then copy the header files (only) into the new directory
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
cp -f "${ARCHDIR}"/${hdir}/*.h "${EXPORTDIR}"/arch/${hdir}/. 2>/dev/null
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Most architectures have low directory called "hardware" that
|
|
|
|
# holds the header files
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ -d "${ARCHDIR}/${hdir}/hardware" ]; then
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Yes.. create a export sub-directory of the same name
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
mkdir "${EXPORTDIR}/arch/${hdir}/hardware" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}/hardware' failed"; exit 1; }
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Then copy the header files (only) into the new directory
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
cp -f "${ARCHDIR}"/${hdir}/hardware/*.h "${EXPORTDIR}"/arch/${hdir}/hardware/. 2>/dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Copy OS internal header files as well. They are used by some architecture-
|
|
|
|
# specific header files.
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
mkdir "${EXPORTDIR}/arch/os" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/os' failed"; exit 1; }
|
2014-09-04 19:43:25 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
OSDIRS="clock environ errno group init irq mqueue paging pthread sched semaphore signal task timer wdog"
|
2014-09-04 19:43:25 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
for dir in ${OSDIRS}; do
|
|
|
|
mkdir "${EXPORTDIR}/arch/os/${dir}" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/os/${dir}' failed"; exit 1; }
|
|
|
|
cp -f "${TOPDIR}"/sched/${dir}/*.h "${EXPORTDIR}"/arch/os/${dir}/. 2>/dev/null
|
|
|
|
done
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
# Add the board library to the list of libraries
|
2011-07-12 00:52:51 +02:00
|
|
|
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ -f "${ARCHDIR}/board/libboard${LIBEXT}" ]; then
|
|
|
|
LIBLIST="${LIBLIST} ${ARCHSUBDIR}/board/libboard${LIBEXT}"
|
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-24 04:26:56 +02:00
|
|
|
LDLIBS=`basename -a ${LIBLIST} | sed -e "s/lib/-l/g" -e "s/\.${LIBEXT:1}//g" | tr "\n" " "`
|
|
|
|
|
|
|
|
if [ "X${USRONLY}" != "Xy" ]; then
|
2023-08-24 17:15:02 +02:00
|
|
|
echo "LDLIBS = ${LDLIBS}" >> "${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
|
|
|
|
echo "set(LDLIBS \"${LDLIBS}\")" >>"${EXPORTDIR}/scripts/target.cmake"
|
2020-06-24 04:26:56 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
# Then process each library
|
|
|
|
|
|
|
|
for lib in ${LIBLIST}; do
|
2020-01-05 17:29:59 +01:00
|
|
|
if [ ! -f "${TOPDIR}/${lib}" ]; then
|
|
|
|
echo "MK: Library ${TOPDIR}/${lib} does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-06-24 04:26:56 +02:00
|
|
|
cp ${TOPDIR}/${lib} ${EXPORTDIR}/libs
|
2011-07-12 00:52:51 +02:00
|
|
|
done
|
|
|
|
|
2020-06-24 04:31:06 +02:00
|
|
|
# Process extra librarys
|
|
|
|
|
|
|
|
for lib in ${EXTRA_LIBS}; do
|
|
|
|
|
|
|
|
# Convert library name
|
|
|
|
|
|
|
|
if [ ${lib:0:2} = "-l" ]; then
|
|
|
|
lib=`echo "${lib}" | sed -e "s/-l/lib/" -e "s/$/${LIBEXT}/"`
|
|
|
|
fi
|
|
|
|
|
2023-03-17 09:47:45 +01:00
|
|
|
if [ -f "${lib}" ]; then
|
|
|
|
cp -a ${lib} ${EXPORTDIR}/libs
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2020-06-24 04:31:06 +02:00
|
|
|
for path in ${EXTRA_LIBPATHS}; do
|
|
|
|
|
|
|
|
# Skip the library path options
|
|
|
|
|
|
|
|
if [ ${#path} == 2 ]; then continue; fi
|
|
|
|
|
|
|
|
if [ ${path:0:2} = "-l" ] || [ ${path:0:2} = "-L" ]; then
|
|
|
|
path=${path:2}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Export the extra librarys
|
|
|
|
|
|
|
|
if [ -f "${path}/${lib}" ]; then
|
|
|
|
cp -a ${path}/${lib} ${EXPORTDIR}/libs
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2019-10-01 15:54:11 +02:00
|
|
|
# Copy the essential build script file(s)
|
|
|
|
|
2020-05-18 22:20:39 +02:00
|
|
|
cp -f "${TOPDIR}/tools/Config.mk" "${EXPORTDIR}/tools/"
|
2019-10-01 15:54:11 +02:00
|
|
|
cp -f "${TOPDIR}/tools/copydir.bat" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/copydir.sh" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/define.bat" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/define.sh" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/incdir.bat" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/incdir.sh" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/link.bat" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/link.sh" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/unlink.bat" "${EXPORTDIR}/tools/"
|
|
|
|
cp -f "${TOPDIR}/tools/unlink.sh" "${EXPORTDIR}/tools/"
|
|
|
|
|
2011-07-12 00:52:51 +02:00
|
|
|
# Now tar up the whole export directory
|
|
|
|
|
|
|
|
cd "${TOPDIR}" || \
|
2020-01-05 17:29:59 +01:00
|
|
|
{ echo "MK: 'cd ${TOPDIR}' failed"; exit 1; }
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2019-08-30 15:19:15 +02:00
|
|
|
if [ -e "${APPDIR}/Makefile" ]; then
|
2023-01-31 11:26:42 +01:00
|
|
|
${MAKE} -C "${APPDIR}" EXPORTDIR="$(cd "${EXPORTSUBDIR}" ; pwd )" TOPDIR="${TOPDIR}" export || \
|
2020-01-05 17:29:59 +01:00
|
|
|
{ echo "MK: call make export for APPDIR not supported"; }
|
2019-08-30 15:19:15 +02:00
|
|
|
fi
|
|
|
|
|
2011-07-13 01:54:13 +02:00
|
|
|
if [ "X${TGZ}" = "Xy" ]; then
|
2020-08-13 15:06:47 +02:00
|
|
|
tar cvf "${EXPORTSUBDIR}.tar" "${EXPORTSUBDIR}" 1>/dev/null
|
2020-01-05 17:29:59 +01:00
|
|
|
gzip -f "${EXPORTSUBDIR}.tar"
|
2011-07-13 01:54:13 +02:00
|
|
|
else
|
2020-08-13 15:06:47 +02:00
|
|
|
zip -r "${EXPORTSUBDIR}.zip" "${EXPORTSUBDIR}" 1>/dev/null
|
2011-07-13 01:54:13 +02:00
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
|
|
|
|
# Clean up after ourselves
|
|
|
|
|
2014-04-14 00:22:22 +02:00
|
|
|
rm -rf "${EXPORTSUBDIR}"
|