From bcfbb7a3974dbd00ffb99d146e69eb3e3dc99d57 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 29 Sep 2013 11:46:10 -0600 Subject: Dependency generation fix for directories that keep object files in a sub-directory --- nuttx/ChangeLog | 5 +- nuttx/arch/arm/src/sam34/chip/sam4s_pio.h | 1 + nuttx/libc/.gitignore | 4 +- nuttx/libc/Makefile | 15 +++- nuttx/mm/.gitignore | 4 +- nuttx/mm/Makefile | 15 +++- nuttx/net/Kconfig | 2 +- nuttx/tools/mkdeps.bat | 29 +++++++- nuttx/tools/mkdeps.c | 117 ++++++++++++++++++++++++++---- nuttx/tools/mkdeps.sh | 28 ++++++- 10 files changed, 190 insertions(+), 30 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index c8cf633a4..7a6c770cc 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -5666,4 +5666,7 @@ * nuttx/fs/fs_sendfile.c, nuttx/net/net_sendfile.c, and other file: Integrate an optimized sendfile() operation from Max Holtzberg (2013-9-28). - + * tools/mkdeps.*, nuttx/mm/Makefile, nuttx/libc/Makefile: Dependency + generation generation was broken for directories that keep objects in + a sub-directory. Fixed by adding a object path to the mkdeps.c, + mkdeps.bat, mkdeps.sh tools (2013-0-29). diff --git a/nuttx/arch/arm/src/sam34/chip/sam4s_pio.h b/nuttx/arch/arm/src/sam34/chip/sam4s_pio.h index 93111dddb..b208b7756 100644 --- a/nuttx/arch/arm/src/sam34/chip/sam4s_pio.h +++ b/nuttx/arch/arm/src/sam34/chip/sam4s_pio.h @@ -359,6 +359,7 @@ #define PIO_WPMR_WPEN (1 << 0) /* Bit 0: Write Protect Enable */ #define PIO_WPMR_WPKEY_SHIFT (8) /* Bits 8-31: Write Protect KEY */ #define PIO_WPMR_WPKEY_MASK (0xffffff << PIO_WPMR_WPKEY_SHIFT) +# define PIO_WPMR_WPKEY (0x50494f << PIO_WPMR_WPKEY_SHIFT) /* PIO Write Protect Status Register */ diff --git a/nuttx/libc/.gitignore b/nuttx/libc/.gitignore index 4b32ec6a3..882c76e88 100644 --- a/nuttx/libc/.gitignore +++ b/nuttx/libc/.gitignore @@ -1,4 +1,6 @@ -/Make.dep +/Make_bin.dep +/Make_ubin.dep +/Make_kbin.dep /.depend /*.asm /*.obj diff --git a/nuttx/libc/Makefile b/nuttx/libc/Makefile index c79c5e7d7..72c12863b 100644 --- a/nuttx/libc/Makefile +++ b/nuttx/libc/Makefile @@ -105,7 +105,12 @@ endif # Dependencies .depend: Makefile $(SRCS) - $(Q) $(MKDEP) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep +ifeq ($(CONFIG_NUTTX_KERNEL),y) + $(Q) $(MKDEP) --obj-path ubin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_ubin.dep + $(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_kbin.dep +else + $(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_bin.dep +endif $(Q) touch $@ depend: .depend @@ -127,7 +132,11 @@ distclean: clean $(Q) $(MAKE) -C bin distclean TOPDIR=$(TOPDIR) $(Q) $(MAKE) -C ubin distclean TOPDIR=$(TOPDIR) $(Q) $(MAKE) -C kbin distclean TOPDIR=$(TOPDIR) - $(call DELFILE, Make.dep) + $(call DELFILE, Make_bin.dep) + $(call DELFILE, Make_ubin.dep) + $(call DELFILE, Make_kbin.dep) $(call DELFILE, .depend) --include Make.dep +-include Make_bin.dep +-include Make_ubin.dep +-include Make_kbin.dep diff --git a/nuttx/mm/.gitignore b/nuttx/mm/.gitignore index 4b32ec6a3..882c76e88 100644 --- a/nuttx/mm/.gitignore +++ b/nuttx/mm/.gitignore @@ -1,4 +1,6 @@ -/Make.dep +/Make_bin.dep +/Make_ubin.dep +/Make_kbin.dep /.depend /*.asm /*.obj diff --git a/nuttx/mm/Makefile b/nuttx/mm/Makefile index 182664338..e47ac183f 100644 --- a/nuttx/mm/Makefile +++ b/nuttx/mm/Makefile @@ -100,7 +100,12 @@ endif # Dependencies .depend: Makefile $(SRCS) - $(Q) $(MKDEP) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep +ifeq ($(CONFIG_NUTTX_KERNEL),y) + $(Q) $(MKDEP) --obj-path ubin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_ubin.dep + $(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_kbin.dep +else + $(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_bin.dep +endif $(Q) touch $@ depend: .depend @@ -122,7 +127,11 @@ distclean: clean $(Q) $(MAKE) -C bin distclean TOPDIR=$(TOPDIR) $(Q) $(MAKE) -C ubin distclean TOPDIR=$(TOPDIR) $(Q) $(MAKE) -C kbin distclean TOPDIR=$(TOPDIR) - $(call DELFILE, Make.dep) + $(call DELFILE, Make_bin.dep) + $(call DELFILE, Make_ubin.dep) + $(call DELFILE, Make_kbin.dep) $(call DELFILE, .depend) --include Make.dep +-include Make_bin.dep +-include Make_ubin.dep +-include Make_kbin.dep diff --git a/nuttx/net/Kconfig b/nuttx/net/Kconfig index c16bbafaf..c581e32a3 100644 --- a/nuttx/net/Kconfig +++ b/nuttx/net/Kconfig @@ -180,7 +180,7 @@ config NET_SENDFILE bool "Optimized network sendfile()" default n ---help--- - Support larger, high performance sendfile() from transferring + Support larger, higher performance sendfile() for transferring files out a TCP connection. endif # NET_TCP diff --git a/nuttx/tools/mkdeps.bat b/nuttx/tools/mkdeps.bat index 23aab0b71..2b9ea3ce5 100644 --- a/nuttx/tools/mkdeps.bat +++ b/nuttx/tools/mkdeps.bat @@ -39,6 +39,8 @@ set cflags= set altpath= set files= set args= +set objpath= +set suffix=.o set debug=n :Loop @@ -61,6 +63,18 @@ if "%1"=="--dep-path" ( goto NextParm ) +if "%1"=="--obj-path" ( + set objpath=%2 + shift + goto NextParm +) + +if "%1"=="--obj-suffix" ( + set suffix=%2 + shift + goto NextParm +) + if "%1"=="--dep-debug" ( rem @echo on set debug=y @@ -111,8 +125,15 @@ for %%G in (%files%) do ( call :Checkpaths if "%debug%"=="y" echo %file%: fullpath=%fullpath% if "%fullpath%"=="" goto :NoFile + + mtarg="" + if "%objpath%"=="" ( + set objname=%~n1 + set mtarg="-MT %objpath%\%objname%%suffix% + ) + if "%debug%"=="y" echo CMD: %cc% -M %cflags% %fullpath% - %cc% -M %cflags% %fullpath% || goto DepFail + %cc% -M %mtarg% %cflags% %fullpath% || goto DepFail ) goto :End @@ -167,6 +188,12 @@ echo --dep-path ^ echo Do not look in the current directory for the file. Instead, look in to see echo if the file resides there. --dep-path may be used multiple times to specify echo multiple alternative location +echo --obj-path ^ +echo The final objects will not reside in this path but, rather, at the path provided by +echo ^. if provided multiple time, only the last --obj-path will be used. +echo --obj-suffix ^ +echo If and object path is provided, then the extension will be assumed to be .o. This +echo default suffix can be overrided with this command line option. echo --help echo Shows this message and exits diff --git a/nuttx/tools/mkdeps.c b/nuttx/tools/mkdeps.c index b8dfbeb8f..31398c49b 100644 --- a/nuttx/tools/mkdeps.c +++ b/nuttx/tools/mkdeps.c @@ -1,7 +1,7 @@ /**************************************************************************** * tools/mkdeps.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ #include #include #include +#include #include /**************************************************************************** @@ -68,15 +69,20 @@ enum slashmode_e * Private Data ****************************************************************************/ -static char *g_cc = NULL; -static char *g_cflags = NULL; -static char *g_files = NULL; -static char *g_altpath = NULL; -static int g_debug = 0; +static char *g_cc = NULL; +static char *g_cflags = NULL; +static char *g_files = NULL; +static char *g_altpath = NULL; +static char *g_objpath = NULL; +static char *g_suffix = ".o"; +static int g_debug = 0; static bool g_winnative = false; #ifdef HAVE_WINPATH -static bool g_winpath = false; -static char *g_topdir = NULL; +static bool g_winpath = false; +static char *g_topdir = NULL; +#define DELIM "\\" +#else +#define DELIM "/" #endif static char g_command[MAX_BUFFER]; @@ -217,6 +223,12 @@ static void show_usage(const char *progname, const char *msg, int exitcode) fprintf(stderr, " Do not look in the current directory for the file. Instead, look in to see\n"); fprintf(stderr, " if the file resides there. --dep-path may be used multiple times to specify\n"); fprintf(stderr, " multiple alternative location\n"); + fprintf(stderr, " --obj-path \n"); + fprintf(stderr, " The final objects will not reside in this path but, rather, at the path provided by\n"); + fprintf(stderr, " . if provided multiple time, only the last --obj-path will be used.\n"); + fprintf(stderr, " --obj-suffix \n"); + fprintf(stderr, " If and object path is provided, then the extension will be assumed to be .o. This\n"); + fprintf(stderr, " default suffix can be overrided with this command line option.\n"); fprintf(stderr, " --winnative\n"); fprintf(stderr, " By default, a POSIX-style environment is assumed (e.g., Linux, Cygwin, etc.) This option is\n"); fprintf(stderr, " inform the tool that is working in a pure Windows native environment.\n"); @@ -268,6 +280,26 @@ static void parse_args(int argc, char **argv) append(&g_altpath, argv[argidx]); } } + else if (strcmp(argv[argidx], "--obj-path") == 0) + { + argidx++; + if (argidx >= argc) + { + show_usage(argv[0], "ERROR: Missing argument to --obj-path", EXIT_FAILURE); + } + + g_objpath = argv[argidx]; + } + else if (strcmp(argv[argidx], "--obj-suffix") == 0) + { + argidx++; + if (argidx >= argc) + { + show_usage(argv[0], "ERROR: Missing argument to --obj-suffix", EXIT_FAILURE); + } + + g_suffix = argv[argidx]; + } else if (strcmp(argv[argidx], "--winnative") == 0) { g_winnative = true; @@ -318,6 +350,16 @@ static void parse_args(int argc, char **argv) fprintf(stderr, " CFLAGS : [%s]\n", g_cflags ? g_cflags : "(None)"); fprintf(stderr, " FILES : [%s]\n", g_files ? g_files : "(None)"); fprintf(stderr, " PATHS : [%s]\n", g_altpath ? g_altpath : "(None)"); + if (g_objpath) + { + fprintf(stderr, " OBJDIR : [%s]\n", g_objpath); + fprintf(stderr, " SUFFIX : [%s]\n", g_suffix); + } + else + { + fprintf(stderr, " OBJDIR : (None)\n"); + } + #ifdef HAVE_WINPATH fprintf(stderr, " Windows Paths : [%s]\n", g_winpath ? "TRUE" : "FALSE"); if (g_winpath) @@ -389,17 +431,60 @@ static void do_dependency(const char *file, char separator) strcat(g_command, moption); - /* Copy the CFLAGS into the command buffer */ + /* Copy " -MT " */ - cmdlen += strlen(g_cflags); - if (cmdlen >= MAX_BUFFER) + if (g_objpath) { - fprintf(stderr, "ERROR: CFLAG string is too long [%d/%d]: %s\n", - cmdlen, MAX_BUFFER, g_cflags); - exit(EXIT_FAILURE); + char tmp[NAME_MAX+6]; + char *dupname; + char *objname; + char *dotptr; + + dupname = strdup(file); + if (!dupname) + { + fprintf(stderr, "ERROR: Failed to dup: %s\n", file); + exit(EXIT_FAILURE); + } + + objname = basename(dupname); + dotptr = strrchr(objname, '.'); + if (dotptr) + { + dotptr = '\0'; + } + + snprintf(tmp, NAME_MAX+6, " -MT %s" DELIM "%s%s ", + g_objpath, objname, g_suffix); + + cmdlen += strlen(tmp); + if (cmdlen >= MAX_BUFFER) + { + fprintf(stderr, "ERROR: Option string is too long [%d/%d]: %s\n", + cmdlen, MAX_BUFFER, moption); + exit(EXIT_FAILURE); + } + + strcat(g_command, tmp); + free(dupname); } - strcat(g_command, g_cflags); + strcat(g_command, moption); + + /* Copy the CFLAGS into the command buffer */ + + if (g_cflags) + { + cmdlen += strlen(g_cflags); + if (cmdlen >= MAX_BUFFER) + { + fprintf(stderr, "ERROR: CFLAG string is too long [%d/%d]: %s\n", + cmdlen, MAX_BUFFER, g_cflags); + exit(EXIT_FAILURE); + } + + strcat(g_command, g_cflags); + } /* Add a space */ @@ -699,7 +784,7 @@ int main(int argc, char **argv, char **envp) files = g_files; while ((file = strtok_r(files, " ", &lasts)) != NULL) { - /* Check if we need to do path conversions for a Windows-natvie tool + /* Check if we need to do path conversions for a Windows-natvive tool * being using in a POSIX/Cygwin environment. */ diff --git a/nuttx/tools/mkdeps.sh b/nuttx/tools/mkdeps.sh index 028fd1d9f..14ac6080e 100755 --- a/nuttx/tools/mkdeps.sh +++ b/nuttx/tools/mkdeps.sh @@ -2,7 +2,7 @@ ############################################################################ # tools/mkdeps.sh # -# Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -33,7 +33,6 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - # # Usage: @@ -58,6 +57,12 @@ show_usage () echo " Do not look in the current directory for the file. Instead, look in to see" echo " if the file resides there. --dep-path may be used multiple times to specify" echo " multiple alternative location" + echo " --obj-path " + echo " The final objects will not reside in this path but, rather, at the path provided by" + echo " . if provided multiple time, only the last --obj-path will be used." + echo " --obj-suffix " + echo " If and object path is provided, then the extension will be assumed to be .o. This" + echo " default suffix can be overrided with this command line option." echo " --winpaths " echo " CC generates dependency lists using Windows paths (e.g., C:\blablah\blabla). This" echo " switch instructs the script to use 'cygpath' to convert the Windows paths to Cygwin" @@ -91,7 +96,14 @@ dodep () fi fi - $cc -M $cflags $fullpath || \ + unset mtarg + if [ ! -z "$objpath" ]; then + srcname=`basename $1` + objname="${srcname%.*}" + mtarg="-MT ${objpath}/${objname}${suffix}" + fi + + $cc -M $mtarg $cflags $fullpath || \ ( echo "# ERROR: $cc -M $cflags $fullpath FAILED"; exit 4; ) } @@ -100,6 +112,8 @@ unset cflags unset files unset args unset altpath +unset objpath +suffix=.o winpaths=n unset topdir @@ -127,6 +141,14 @@ while [ ! -z "$1" ]; do args="$args $1" fi ;; + --obj-path ) + shift + objpath="$1" + ;; + --obj-suffix ) + shift + suffix="$1" + ;; --winpaths ) if [ -z "$args" ]; then shift -- cgit v1.2.3