9
0
Fork 0

Extend 'make export' logic to bundle up CFLAGS and linker scripts as well

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3772 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-07-12 03:21:27 +00:00
parent 8c6706a0ae
commit 92406b12de
4 changed files with 117 additions and 33 deletions

View File

@ -35,7 +35,6 @@
TOPDIR := ${shell pwd | sed -e 's/ /\\ /g'}
-include ${TOPDIR}/.config
-include ${TOPDIR}/.version
-include ${TOPDIR}/Make.defs
# Default tools
@ -57,14 +56,6 @@ ARCH_SRC = $(ARCH_DIR)/src
ARCH_INC = $(ARCH_DIR)/include
BOARD_DIR = configs/$(CONFIG_ARCH_BOARD)
# Version string (only if a non-zero version is specified)
ifdef CONFIG_VERSION_STRING
ifneq ($(CONFIG_VERSION_MAJOR),0)
VERSION = -$(CONFIG_VERSION_STRING)
endif
endif
# Add-on directories. These may or may not be in place in the
# NuttX source tree (they must be specifically installed)
#
@ -467,11 +458,13 @@ pass2dep: context
done
# The export target will package the NuttX libraries and header files into
# an exportable package (These needs some extension for the KERNEL build;
# it needs to receive USERLIBS and create a libuser.a).
# an exportable package. Caveats: (1) These needs some extension for the KERNEL
# build; it needs to receive USERLIBS and create a libuser.a). (2) The logic
# in tools/mkexport.sh only supports GCC and, for example, explicitly assumes
# that the archiver is 'ar'
export: pass2deps
@tools/mkexport.sh -t "$(TOPDIR)" -a "$(CONFIG_ARCH)" -l "$(NUTTXLIBS)"
@tools/mkexport.sh -t "$(TOPDIR)" -l "$(NUTTXLIBS)"
# Housekeeping targets: dependencies, cleaning, etc.

View File

@ -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

View File

@ -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

View File

@ -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