summaryrefslogtreecommitdiff
path: root/nuttx/tools
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-12 03:21:27 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-12 03:21:27 +0000
commit8536067568baaaf22921d527d54d1edf9921f75a (patch)
tree35049eb30e19cd4487f4b5c02d2385bfd0bbaf1a /nuttx/tools
parent80f7724816d1b1f07719185fa7fa5f04b9ecb952 (diff)
downloadpx4-nuttx-8536067568baaaf22921d527d54d1edf9921f75a.tar.gz
px4-nuttx-8536067568baaaf22921d527d54d1edf9921f75a.tar.bz2
px4-nuttx-8536067568baaaf22921d527d54d1edf9921f75a.zip
Extend 'make export' logic to bundle up CFLAGS and linker scripts as well
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3772 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/tools')
-rw-r--r--nuttx/tools/Makefile.export62
-rwxr-xr-xnuttx/tools/README.txt8
-rwxr-xr-xnuttx/tools/mkexport.sh63
3 files changed, 112 insertions, 21 deletions
diff --git a/nuttx/tools/Makefile.export b/nuttx/tools/Makefile.export
new file mode 100644
index 000000000..6d2f13481
--- /dev/null
+++ b/nuttx/tools/Makefile.export
@@ -0,0 +1,62 @@
+############################################################################
+# Makefile.export
+#
+# Copyright (C) 2011 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+#
+# 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.
+#
+############################################################################
+
+include $(TOPDIR)/.config
+include $(EXPORTDIR)/Make.defs
+
+LDPATH = ${shell echo "$(ARCHSCRIPT)" | sed -e "s/^-T[ ]*//g"}
+LDNAME = ${shell basename ${LDPATH}}
+LDDIR = ${shell dirname ${LDPATH}}
+ARCHSUBDIR = "arch/$(CONFIG_ARCH)/src"
+ARCHDIR ="$(TOPDIR)/$(ARCHSUBDIR)"
+
+all: $(EXPORTDIR)/makeinfo.sh
+default: all
+.PHONY: clean
+
+$(EXPORTDIR)/makeinfo.sh: $(TOPDIR)/.config $(EXPORTDIR)/Make.defs
+ @echo "#!/bin/bash" > $(EXPORTDIR)/makeinfo.sh
+ @echo "" >> $(EXPORTDIR)/makeinfo.sh
+ @echo "ARCHSUBDIR=\"$(ARCHSUBDIR)\"" >> $(EXPORTDIR)/makeinfo.sh
+ @echo "ARCHDIR=\"$(ARCHDIR)\"" >> $(EXPORTDIR)/makeinfo.sh
+ @echo "LDNAME=\"$(LDNAME)\"" >> $(EXPORTDIR)/makeinfo.sh
+ @echo "LDDIR=\"$(LDDIR)\"" >> $(EXPORTDIR)/makeinfo.sh
+ @echo "LDPATH=\"$(LDPATH)\"" >> $(EXPORTDIR)/makeinfo.sh
+ @echo "ARCHCFLAGS=\"$(ARCHCFLAGS) $(ARCHCPUFLAGS)\"" >> $(EXPORTDIR)/makeinfo.sh
+ @echo "ARCHCXXFLAGS=\"$(ARCHCXXFLAGS) $(ARCHCPUFLAGS)\"" >> $(EXPORTDIR)/makeinfo.sh
+ @chmod 755 $(EXPORTDIR)/makeinfo.sh
+
+clean:
+ @rm -f $(EXPORTDIR)/makeinfo.sh
diff --git a/nuttx/tools/README.txt b/nuttx/tools/README.txt
index 14783ae56..259822378 100755
--- a/nuttx/tools/README.txt
+++ b/nuttx/tools/README.txt
@@ -31,6 +31,14 @@ mkconfig.c, cfgparser.c, and cfgparser.h
into include/nuttx/config.h. config.h is a another version of the
NuttX configuration that can be included by C files.
+mkexport.sh and Makefile.export
+
+ These implement part of the top-level Makefile's 'export' target. That
+ target will bundle up all of the NuttX libraries, header files, and the
+ startup object into an export-able, binary NuttX distribution. The
+ Makefile.export is used only by the mkexport.sh script to parse out
+ options from the top-level Make.defs file.
+
mkversion.c, cfgparser.c, and cfgparser.h
This is C file that is used to build mkversion program. The mkversion
diff --git a/nuttx/tools/mkexport.sh b/nuttx/tools/mkexport.sh
index d7fede43f..41e429cd2 100755
--- a/nuttx/tools/mkexport.sh
+++ b/nuttx/tools/mkexport.sh
@@ -41,18 +41,13 @@
# Get the input parameter list
-USAGE="USAGE: $0 [-d] -t <top-dir> -a <arch-dir> [-x <lib-ext>] -l \"lib1 [lib2 [lib3 ...]]\""
+USAGE="USAGE: $0 [-d] -t <top-dir> [-x <lib-ext>] -l \"lib1 [lib2 [lib3 ...]]\""
unset TOPDIR
-unset ARCH
unset LIBLIST
LIBEXT=.a
while [ ! -z "$1" ]; do
case $1 in
- -a )
- shift
- ARCH=$1
- ;;
-d )
set -x
;;
@@ -83,7 +78,7 @@ done
# Check arguments
-if [ -z "${TOPDIR}" -o -z "${ARCH}" -o -z "${LIBLIST}" ]; then
+if [ -z "${TOPDIR}" -o -z "${LIBLIST}" ]; then
echo "MK: Missing required arguments"
echo $USAGE
exit 1
@@ -94,19 +89,6 @@ if [ ! -d "${TOPDIR}" ]; then
exit 1
fi
-if [ ! -f "${TOPDIR}/Make.defs" ]; then
- echo "MK: File ${TOPDIR}/Make.defs does not exist"
- exit 1
-fi
-
-ARCHSUBDIR="arch/${ARCH}/src"
-ARCHDIR="${TOPDIR}/${ARCHSUBDIR}"
-
-if [ ! -d "${ARCHDIR}" ]; then
- echo "MK: Directory ${ARCHDIR} does not exist"
- exit 1
-fi
-
# Get the version string
if [ ! -f "${TOPDIR}/.version" ]; then
@@ -137,6 +119,44 @@ rm -f "${EXPORTDIR}.tar.gz"
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; }
+mkdir "${EXPORTDIR}/build" || { echo "MK: 'mkdir ${EXPORTDIR}/build' failed"; exit 1; }
+
+# Verify that we have a Make.defs file.
+
+if [ ! -f "${TOPDIR}/Make.defs" ]; then
+ echo "MK: Directory ${TOPDIR}/Make.defs does not exist"
+ exit 1
+fi
+
+# 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
+
+make -C "${TOPDIR}/tools" -f Makefile.export TOPDIR="${TOPDIR}" EXPORTDIR="${EXPORTDIR}"
+source "${EXPORTDIR}/makeinfo.sh"
+rm -f "${EXPORTDIR}/makeinfo.sh"
+rm -f "${EXPORTDIR}/Make.defs"
+
+# Verifty the build info that we got from makeinfo.sh
+
+if [ ! -d "${ARCHDIR}" ]; then
+ echo "MK: Directory ${ARCHDIR} does not exist"
+ exit 1
+fi
+
+if [ ! -f "${LDPATH}" ]; then
+ echo "MK: File ${LDPATH} does not exist"
+ exit 1
+fi
+
+# Copy the build info that we got from makeinfo.sh
+
+cp --preserve=all "${LDPATH}" "${EXPORTDIR}/build/." || \
+ { echo "MK: cp ${LDPATH} failed"; exit 1; }
+echo "ARCHCFLAGS = ${ARCHCFLAGS}" >"${EXPORTDIR}/build/Make.defs"
+echo "ARCHCXXFLAGS = ${ARCHCXXFLAGS}" >>"${EXPORTDIR}/build/Make.defs"
# Copy the NuttX include directory (retaining attributes and following symbolic links)
@@ -170,7 +190,8 @@ for lib in ${LIBLIST}; do
# Copy the application library unmodified
if [ "X${libname}" = "Xlibapps" ]; then
- cp --preserve=all "${TOPDIR}/${lib}" "${EXPORTDIR}/libs/."
+ cp --preserve=all "${TOPDIR}/${lib}" "${EXPORTDIR}/libs/." || \
+ { echo "MK: cp ${TOPDIR}/${lib} failed"; exit 1; }
else
# Create a temporary directory and extract all of the objects there