From 86aa8f38133d6572784498d16d575ff5ed5882d9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 4 Sep 2014 12:19:47 -0600 Subject: [PATCH] In 'make export', do not copy internal header files if this is a kernel build --- Makefile.unix | 19 ++++++++- Makefile.win | 15 ++++++- tools/mkexport.sh | 103 +++++++++++++++++++++++++--------------------- 3 files changed, 88 insertions(+), 49 deletions(-) diff --git a/Makefile.unix b/Makefile.unix index 959cabfd19..2d7bb4fca2 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -148,6 +148,23 @@ endif LINKLIBS = $(patsubst lib/%,%,$(NUTTXLIBS)) +# Export tool definitions + +MKEXPORT= tools/mkexport.sh +MKEXPORT_ARGS = -w$(WINTOOL) -t "$(TOPDIR)" + +ifeq ($(CONFIG_BUILD_PROTECTED),y) +MKEXPORT_ARGS += -u +else +ifeq ($(CONFIG_BUILD_KERNEL),y) +MKEXPORT_ARGS += -u +endif +endif + +ifeq ($(V),1) +MKEXPORT_ARGS += -d +endif + # This is the name of the final target (relative to the top level directorty) BIN = nuttx$(EXEEXT) @@ -625,7 +642,7 @@ gconfig: # that the archiver is 'ar' export: pass2deps - $(Q) tools/mkexport.sh -w$(WINTOOL) -t "$(TOPDIR)" -l "$(EXPORTLIBS)" + $(Q) $(MKEXPORT) $(MKEXPORT_ARGS) -l "$(EXPORTLIBS)" # General housekeeping targets: dependencies, cleaning, etc. # diff --git a/Makefile.win b/Makefile.win index 0efec094fc..bb90d77e49 100644 --- a/Makefile.win +++ b/Makefile.win @@ -141,6 +141,19 @@ endif LINKLIBS = $(patsubst lib\\%,%,$(NUTTXLIBS)) +# Export tool definitions + +MKEXPORT = tools\mkexport.bat +MKEXPORT_ARGS = -w$(WINTOOL) -t "$(TOPDIR)" + +ifeq ($(CONFIG_BUILD_PROTECTED),y) +MKEXPORT_ARGS = -u +else +ifeq ($(CONFIG_BUILD_KERNEL),y) +MKEXPORT_ARGS = -u +endif +endif + # This is the name of the final target (relative to the top level directorty) BIN = nuttx$(EXEEXT) @@ -622,7 +635,7 @@ menuconfig: configenv # that the archiver is 'ar' export: pass2deps - $(Q) tools\mkexport.sh -w$(WINTOOL) -t "$(TOPDIR)" -l "$(EXPORTLIBS)" + $(Q) $(MKEXPORT) $(MKEXPORT_ARGS) -w$(WINTOOL) -t "$(TOPDIR)" -l "$(EXPORTLIBS)" # General housekeeping targets: dependencies, cleaning, etc. # diff --git a/tools/mkexport.sh b/tools/mkexport.sh index 6d0259cf0f..562121bed6 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -34,19 +34,20 @@ # Get the input parameter list -USAGE="USAGE: $0 [-d] [-z] [-w|wy|wn] -t [-x ] -l \"lib1 [lib2 [lib3 ...]]\"" +USAGE="USAGE: $0 [-d] [-z] [-u] [-w|wy|wn] -t [-x ] -l \"lib1 [lib2 [lib3 ...]]\"" unset TOPDIR unset LIBLIST unset TGZ +USRONLY=n WINTOOL=n LIBEXT=.a while [ ! -z "$1" ]; do case $1 in - -d ) + -d ) set -x ;; - -l ) + -l ) shift LIBLIST=$1 ;; @@ -60,11 +61,14 @@ while [ ! -z "$1" ]; do shift TOPDIR=$1 ;; - -x ) + -u ) + USRONLY=y + ;; + -x ) shift LIBEXT=$1 ;; - -z ) + -z ) TGZ=y ;; -h ) @@ -129,7 +133,10 @@ 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; } -mkdir "${EXPORTDIR}/arch" || { echo "MK: 'mkdir ${EXPORTDIR}/arch' failed"; exit 1; } + +if [ "X${USRONLY}" != "Xy" ]; then + mkdir "${EXPORTDIR}/arch" || { echo "MK: 'mkdir ${EXPORTDIR}/arch' failed"; exit 1; } +fi # Verify that we have a Make.defs file. @@ -202,57 +209,59 @@ cp -f "${ARCHDIR}"/*.h "${EXPORTDIR}"/arch/. 2>/dev/null # as symbolic links to directories, then copy the header files from # those directories into the EXPORTDIR -ARCH_HDRDIRS="arm armv7-m avr avr32 board common chip mips32" -for hdir in $ARCH_HDRDIRS; do +if [ "X${USRONLY}" != "Xy" ]; then + ARCH_HDRDIRS="arm armv7-m avr avr32 board common chip mips32" + for hdir in $ARCH_HDRDIRS; do - # Does the directory (or symbolic link) exist? + # Does the directory (or symbolic link) exist? - if [ -d "${ARCHDIR}/${hdir}" -o -h "${ARCHDIR}/${hdir}" ]; then - - # Yes.. create a export sub-directory of the same name - - mkdir "${EXPORTDIR}/arch/${hdir}" || \ - { echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}' failed"; exit 1; } - - # Then copy the header files (only) into the new directory - - cp -f "${ARCHDIR}"/${hdir}/*.h "${EXPORTDIR}"/arch/${hdir}/. 2>/dev/null - - # One architecture has low directory called "chip" that holds the - # header files - - if [ -d "${ARCHDIR}/${hdir}/chip" ]; then + if [ -d "${ARCHDIR}/${hdir}" -o -h "${ARCHDIR}/${hdir}" ]; then # Yes.. create a export sub-directory of the same name - mkdir "${EXPORTDIR}/arch/${hdir}/chip" || \ - { echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}/chip' failed"; exit 1; } + mkdir "${EXPORTDIR}/arch/${hdir}" || \ + { echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}' failed"; exit 1; } # Then copy the header files (only) into the new directory - cp -f "${ARCHDIR}"/${hdir}/chip/*.h "${EXPORTDIR}"/arch/${hdir}/chip/. 2>/dev/null + cp -f "${ARCHDIR}"/${hdir}/*.h "${EXPORTDIR}"/arch/${hdir}/. 2>/dev/null + + # One architecture has low directory called "chip" that holds the + # header files + + if [ -d "${ARCHDIR}/${hdir}/chip" ]; then + + # Yes.. create a export sub-directory of the same name + + mkdir "${EXPORTDIR}/arch/${hdir}/chip" || \ + { echo "MK: 'mkdir ${EXPORTDIR}/arch/${hdir}/chip' failed"; exit 1; } + + # Then copy the header files (only) into the new directory + + cp -f "${ARCHDIR}"/${hdir}/chip/*.h "${EXPORTDIR}"/arch/${hdir}/chip/. 2>/dev/null + fi fi + done + + # Copy OS internal header files as well. They are used by some architecture- + # specific header files. + + mkdir "${EXPORTDIR}/arch/os" || \ + { echo "MK: 'mkdir ${EXPORTDIR}/arch/os' failed"; exit 1; } + + OSDIRS="clock environ errno group init irq mqueue paging pthread sched semaphore signal task timer wdog" + + 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 + + # Add the board library to the list of libraries + + if [ -f "${ARCHDIR}/board/libboard${LIBEXT}" ]; then + LIBLIST="${LIBLIST} ${ARCHSUBDIR}/board/libboard${LIBEXT}" fi -done - -# Copy OS internal header files as well. They are used by some architecture- -# specific header files. - -mkdir "${EXPORTDIR}/arch/os" || \ - { echo "MK: 'mkdir ${EXPORTDIR}/arch/os' failed"; exit 1; } - -OSDIRS="clock environ errno group init irq mqueue paging pthread sched semaphore signal task timer wdog" - -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 - -# Add the board library to the list of libraries - -if [ -f "${ARCHDIR}/board/libboard${LIBEXT}" ]; then - LIBLIST="${LIBLIST} ${ARCHSUBDIR}/board/libboard${LIBEXT}" fi # Then process each library