2019-08-10 17:57:26 +02:00
|
|
|
#!/usr/bin/env bash
|
2011-07-12 00:52:51 +02:00
|
|
|
# tools/mkexport.sh
|
|
|
|
#
|
2019-07-04 15:17:53 +02:00
|
|
|
# Copyright (C) 2011-2012, 2014, 2016, 2019 Gregory Nutt. All rights reserved.
|
2012-01-05 19:27:26 +01:00
|
|
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
2011-07-12 00:52:51 +02:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in
|
|
|
|
# the documentation and/or other materials provided with the
|
|
|
|
# distribution.
|
|
|
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
# used to endorse or promote products derived from this software
|
|
|
|
# without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
|
|
|
|
# Get the input parameter list
|
|
|
|
|
2019-08-30 15:19:15 +02:00
|
|
|
USAGE="USAGE: $0 [-d] [-z] [-u] [-w|wy|wn] -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
|
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
USRONLY=n
|
2012-01-05 19:27:26 +01:00
|
|
|
WINTOOL=n
|
2011-07-12 00:52:51 +02:00
|
|
|
LIBEXT=.a
|
|
|
|
|
|
|
|
while [ ! -z "$1" ]; do
|
|
|
|
case $1 in
|
2019-08-30 15:19:15 +02:00
|
|
|
-a )
|
|
|
|
shift
|
|
|
|
APPDIR="$1"
|
|
|
|
;;
|
2014-09-04 20:19:47 +02:00
|
|
|
-d )
|
2011-07-12 00:52:51 +02:00
|
|
|
set -x
|
|
|
|
;;
|
2014-09-04 20:19:47 +02:00
|
|
|
-l )
|
2011-07-12 00:52:51 +02:00
|
|
|
shift
|
|
|
|
LIBLIST=$1
|
|
|
|
;;
|
2019-08-30 15:19:15 +02:00
|
|
|
-m )
|
|
|
|
shift
|
|
|
|
MAKE="$1"
|
|
|
|
;;
|
2012-01-05 19:27:26 +01:00
|
|
|
-wy )
|
|
|
|
WINTOOL=y
|
|
|
|
;;
|
|
|
|
-w | -wn )
|
|
|
|
WINTOOL=n
|
|
|
|
;;
|
2011-07-12 00:52:51 +02:00
|
|
|
-t )
|
|
|
|
shift
|
|
|
|
TOPDIR=$1
|
|
|
|
;;
|
2014-09-04 20:19:47 +02:00
|
|
|
-u )
|
|
|
|
USRONLY=y
|
|
|
|
;;
|
|
|
|
-x )
|
2011-07-12 00:52:51 +02:00
|
|
|
shift
|
|
|
|
LIBEXT=$1
|
|
|
|
;;
|
2014-09-04 20:19:47 +02:00
|
|
|
-z )
|
2011-07-13 01:54:13 +02:00
|
|
|
TGZ=y
|
|
|
|
;;
|
2011-07-12 00:52:51 +02:00
|
|
|
-h )
|
|
|
|
echo $USAGE
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo "Unrecognized argument: $1"
|
|
|
|
echo $USAGE
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# Check arguments
|
|
|
|
|
2011-07-12 05:21:27 +02:00
|
|
|
if [ -z "${TOPDIR}" -o -z "${LIBLIST}" ]; then
|
2011-07-12 00:52:51 +02:00
|
|
|
echo "MK: Missing required arguments"
|
|
|
|
echo $USAGE
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "${TOPDIR}" ]; then
|
|
|
|
echo "MK: Directory ${TOPDIR} does not exist"
|
|
|
|
exit 1
|
|
|
|
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
|
|
|
|
echo "MK: Directory ${TOPDIR}/Make.defs does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "${TOPDIR}/.config" ]; then
|
|
|
|
echo "MK: Directory ${TOPDIR}/.config does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
|
|
|
|
if [ ! -f "${TOPDIR}/.version" ]; then
|
|
|
|
echo "MK: File ${TOPDIR}/.version does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-05-06 12:49:25 +02:00
|
|
|
# Check if the make environment variable has been defined
|
|
|
|
|
|
|
|
if [ -z "${MAKE}" ]; then
|
|
|
|
MAKE=`which make`
|
|
|
|
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
|
|
|
|
VERSION="-${CONFIG_VERSION_STRING}"
|
|
|
|
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
|
|
|
|
echo "MK: Removing old export directory"
|
|
|
|
rm -rf "${EXPORTDIR}"
|
|
|
|
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
|
|
|
|
|
|
|
# Copy the Make.defs files, but disable windows path conversions
|
|
|
|
|
|
|
|
grep -v "WINTOOL[ \t]*=[ \t]y" "${TOPDIR}/Make.defs" > "${EXPORTDIR}/Make.defs"
|
|
|
|
|
|
|
|
# Extract information from the Make.defs file. A Makefile can do this best
|
|
|
|
|
2016-05-05 11:40:16 +02:00
|
|
|
${MAKE} -C "${TOPDIR}/tools" -f Makefile.export 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
|
|
|
|
echo "MK: Directory ${ARCHDIR} does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-10-01 15:54:11 +02:00
|
|
|
# Copy the default linker script
|
|
|
|
|
|
|
|
cp -f "${TOPDIR}/binfmt/libelf/gnu-elf.ld" "${EXPORTDIR}/scripts/."
|
|
|
|
|
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
|
|
|
|
if [ ! -z "${LDPATH}" ]; then
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2014-09-04 20:35:47 +02:00
|
|
|
# Apparently so. Verify that the script exists
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2014-09-04 20:35:47 +02:00
|
|
|
if [ ! -f "${LDPATH}" ]; then
|
|
|
|
echo "MK: File ${LDPATH} does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2014-09-04 20:35:47 +02:00
|
|
|
# Copy the linker script
|
2011-07-13 01:54:13 +02:00
|
|
|
|
2019-10-01 15:54:11 +02:00
|
|
|
cp -p "${LDPATH}" "${EXPORTDIR}/scripts/." || \
|
2014-09-04 20:35:47 +02:00
|
|
|
{ echo "MK: cp ${LDPATH} failed"; exit 1; }
|
2019-08-28 15:49:57 +02:00
|
|
|
|
|
|
|
# Copy addtional ld scripts
|
|
|
|
|
|
|
|
LDDIR="$(dirname "${LDPATH}")"
|
|
|
|
for f in "${LDDIR}"/*.ld ; do
|
2019-10-01 15:54:11 +02:00
|
|
|
[ -f "${f}" ] && cp -f "${f}" "${EXPORTDIR}/scripts/."
|
2019-08-28 15:49:57 +02:00
|
|
|
done
|
2014-09-04 20:35:47 +02:00
|
|
|
fi
|
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"
|
|
|
|
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 "WINTOOL = ${WINTOOL}" >>"${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"
|
|
|
|
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"
|
|
|
|
echo "DIRLINK = ${DIRLINK}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "DIRUNLINK = ${DIRUNLINK}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "MKDEP = ${MKDEP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LDSCRIPT = ${LDSCRIPT}" >>"${EXPORTDIR}/scripts/Make.defs"
|
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
|
2019-10-01 15:54:11 +02:00
|
|
|
echo "LDFLAGS = ${LDFLAGS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "HEAD_OBJ = ${HEAD_OBJ}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "EXTRA_OBJS = ${EXTRA_OBJS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LDSTARTGROUP = ${LDSTARTGROUP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LDLIBS = ${LDLIBS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "EXTRA_LIBS = ${EXTRA_LIBS}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LIBGCC = ${LIBGCC}" >>"${EXPORTDIR}/scripts/Make.defs"
|
|
|
|
echo "LDENDGROUP = ${LDENDGROUP}" >>"${EXPORTDIR}/scripts/Make.defs"
|
2014-09-05 19:26:42 +02:00
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
|
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
|
|
|
|
cp -a "${TOPDIR}/System.map" "${EXPORTDIR}/."
|
|
|
|
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}/." || \
|
2011-07-12 00:52:51 +02:00
|
|
|
{ echo "MK: 'cp ${TOPDIR}/include' failed"; exit 1; }
|
|
|
|
|
|
|
|
# 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
|
|
|
|
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
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
# Does the directory (or symbolic link) exist?
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
if [ -d "${ARCHDIR}/${hdir}" -o -h "${ARCHDIR}/${hdir}" ]; then
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
# Yes.. create a export sub-directory of the same name
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
mkdir "${EXPORTDIR}/arch/${hdir}" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}' failed"; exit 1; }
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
# Then copy the header files (only) into the new directory
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
cp -f "${ARCHDIR}"/${hdir}/*.h "${EXPORTDIR}"/arch/${hdir}/. 2>/dev/null
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2019-07-04 15:17:53 +02:00
|
|
|
# Most architectures have low directory called "hardware" that
|
|
|
|
# holds the header files
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2019-07-04 15:17:53 +02:00
|
|
|
if [ -d "${ARCHDIR}/${hdir}/hardware" ]; then
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
# Yes.. create a export sub-directory of the same name
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2019-07-04 15:17:53 +02:00
|
|
|
mkdir "${EXPORTDIR}/arch/${hdir}/hardware" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}/hardware' failed"; exit 1; }
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
# Then copy the header files (only) into the new directory
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2019-07-04 15:17:53 +02:00
|
|
|
cp -f "${ARCHDIR}"/${hdir}/hardware/*.h "${EXPORTDIR}"/arch/${hdir}/hardware/. 2>/dev/null
|
2014-09-04 20:19:47 +02:00
|
|
|
fi
|
2011-08-25 19:55:32 +02:00
|
|
|
fi
|
2014-09-04 20:19:47 +02:00
|
|
|
done
|
2011-08-25 19:55:32 +02:00
|
|
|
|
2014-09-04 20:19:47 +02: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
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
mkdir "${EXPORTDIR}/arch/os" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/arch/os' failed"; exit 1; }
|
2014-09-04 19:43:25 +02:00
|
|
|
|
2014-09-04 20:19:47 +02: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
|
|
|
|
2014-09-04 20:19:47 +02: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
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
# Add the board library to the list of libraries
|
2011-07-12 00:52:51 +02:00
|
|
|
|
2014-09-04 20:19:47 +02:00
|
|
|
if [ -f "${ARCHDIR}/board/libboard${LIBEXT}" ]; then
|
|
|
|
LIBLIST="${LIBLIST} ${ARCHSUBDIR}/board/libboard${LIBEXT}"
|
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Then process each library
|
|
|
|
|
2011-12-27 13:44:39 +01:00
|
|
|
AR=${CROSSDEV}ar
|
2011-07-12 00:52:51 +02:00
|
|
|
for lib in ${LIBLIST}; do
|
|
|
|
if [ ! -f "${TOPDIR}/${lib}" ]; then
|
|
|
|
echo "MK: Library ${TOPDIR}/${lib} does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get some shorter names for the library
|
|
|
|
|
|
|
|
libname=`basename ${lib} ${LIBEXT}`
|
|
|
|
shortname=`echo ${libname} | sed -e "s/^lib//g"`
|
|
|
|
|
|
|
|
# Copy the application library unmodified
|
|
|
|
|
|
|
|
if [ "X${libname}" = "Xlibapps" ]; then
|
2011-12-27 13:44:39 +01:00
|
|
|
cp -p "${TOPDIR}/${lib}" "${EXPORTDIR}/libs/." || \
|
2011-07-12 05:21:27 +02:00
|
|
|
{ echo "MK: cp ${TOPDIR}/${lib} failed"; exit 1; }
|
2011-07-12 00:52:51 +02:00
|
|
|
else
|
|
|
|
|
|
|
|
# Create a temporary directory and extract all of the objects there
|
|
|
|
# Hmmm.. this probably won't work if the archiver is not 'ar'
|
|
|
|
|
|
|
|
mkdir "${EXPORTDIR}/tmp" || \
|
|
|
|
{ echo "MK: 'mkdir ${EXPORTDIR}/tmp' failed"; exit 1; }
|
|
|
|
cd "${EXPORTDIR}/tmp" || \
|
|
|
|
{ echo "MK: 'cd ${EXPORTDIR}/tmp' failed"; exit 1; }
|
2012-01-05 19:27:26 +01:00
|
|
|
if [ "X${WINTOOL}" = "Xy" ]; then
|
|
|
|
WLIB=`cygpath -w "${TOPDIR}/${lib}"`
|
|
|
|
${AR} x "${WLIB}"
|
|
|
|
else
|
|
|
|
${AR} x "${TOPDIR}/${lib}"
|
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
|
|
|
|
# Rename each object file (to avoid collision when they are combined)
|
|
|
|
# and add the file to libnuttx
|
|
|
|
|
|
|
|
for file in `ls`; do
|
|
|
|
mv "${file}" "${shortname}-${file}"
|
2012-01-05 19:27:26 +01:00
|
|
|
if [ "X${WINTOOL}" = "Xy" ]; then
|
|
|
|
WLIB=`cygpath -w "${EXPORTDIR}/libs/libnuttx${LIBEXT}"`
|
|
|
|
${AR} rcs "${WLIB}" "${shortname}-${file}"
|
|
|
|
else
|
|
|
|
${AR} rcs "${EXPORTDIR}/libs/libnuttx${LIBEXT}" "${shortname}-${file}"
|
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
cd "${TOPDIR}" || \
|
|
|
|
{ echo "MK: 'cd ${TOPDIR}' failed"; exit 1; }
|
|
|
|
rm -rf "${EXPORTDIR}/tmp"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2019-10-01 15:54:11 +02:00
|
|
|
# Copy the essential build script file(s)
|
|
|
|
|
|
|
|
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}" || \
|
|
|
|
{ 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
|
|
|
|
"${MAKE}" -C "${TOPDIR}/${APPDIR}" EXPORTDIR="$(cd "${EXPORTSUBDIR}" ; pwd )" TOPDIR="${TOPDIR}" export || \
|
|
|
|
{ echo "MK: call make export for APPDIR not supported"; }
|
|
|
|
fi
|
|
|
|
|
2011-07-13 01:54:13 +02:00
|
|
|
if [ "X${TGZ}" = "Xy" ]; then
|
|
|
|
tar cvf "${EXPORTSUBDIR}.tar" "${EXPORTSUBDIR}" 1>/dev/null 2>&1
|
|
|
|
gzip -f "${EXPORTSUBDIR}.tar"
|
|
|
|
else
|
|
|
|
zip -r "${EXPORTSUBDIR}.zip" "${EXPORTSUBDIR}" 1>/dev/null 2>&1
|
|
|
|
fi
|
2011-07-12 00:52:51 +02:00
|
|
|
|
|
|
|
# Clean up after ourselves
|
|
|
|
|
2014-04-14 00:22:22 +02:00
|
|
|
rm -rf "${EXPORTSUBDIR}"
|