From c2325703f1ba2889eff8ad2ef43fb38c958931d7 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 13 Nov 2012 17:18:42 +0000 Subject: Oops.. nested strtok in mkdeps.c, need to use strtok_r git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5345 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/configs/stm32f4discovery/README.txt | 8 +++++++- nuttx/configs/stm32f4discovery/ostest/Make.defs | 16 +++++++++++----- nuttx/configs/stm32f4discovery/winbuild/Make.defs | 5 ++++- nuttx/tools/mkdeps.c | 8 +++++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/nuttx/configs/stm32f4discovery/README.txt b/nuttx/configs/stm32f4discovery/README.txt index eb43cad27..d824668ce 100644 --- a/nuttx/configs/stm32f4discovery/README.txt +++ b/nuttx/configs/stm32f4discovery/README.txt @@ -1084,8 +1084,10 @@ Where is one of the following: b. Execute 'make menuconfig' in nuttx/ in order to start the reconfiguration process. - 2. Default toolchain: + 2. Default platform/toolchain: + CONFIG_HOST_WINDOWS=y : Windows + CONFIG_WINDOWS_CYGWIN=y : Cygwin environment on Windows CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows 3. By default, this project assumes that you are *NOT* using the DFU @@ -1460,6 +1462,10 @@ Where is one of the following: standard issue, CMD shell: ConEmu which can be downloaded from: http://code.google.com/p/conemu-maximus5/ + CONFIG_HOST_WINDOWS=y : Windows + CONFIG_WINDOWS_NATIVE=y : Native Windows environment + CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows + Build Tools. The build still relies on some Unix-like commands. I use the GNUWin32 tools that can be downloaded from http://gnuwin32.sourceforge.net/. The MSYS tools are probably also a option but are likely lower performance diff --git a/nuttx/configs/stm32f4discovery/ostest/Make.defs b/nuttx/configs/stm32f4discovery/ostest/Make.defs index 614e0c456..3106143d6 100644 --- a/nuttx/configs/stm32f4discovery/ostest/Make.defs +++ b/nuttx/configs/stm32f4discovery/ostest/Make.defs @@ -105,16 +105,12 @@ LDSCRIPT = ld.script ifeq ($(WINTOOL),y) # Windows-native toolchains - DIRLINK = $(TOPDIR)/tools/winlink.sh - DIRUNLINK = $(TOPDIR)/tools/unlink.sh - MKDEP = $(TOPDIR)/tools/mknulldeps.sh ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" MAXOPTIMIZATION = -O2 else - # Linux/Cygwin-native toolchain - MKDEP = $(TOPDIR)/tools/mkdeps.sh + # Linux/Cygwin-native toolchain ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) @@ -178,3 +174,13 @@ else HOSTEXEEXT = endif +ifeq ($(WINTOOL),y) + # Windows-native host tools + DIRLINK = $(TOPDIR)/tools/winlink.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mknulldeps.sh +else + # Linux/Cygwin-native host tools + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) +endif + diff --git a/nuttx/configs/stm32f4discovery/winbuild/Make.defs b/nuttx/configs/stm32f4discovery/winbuild/Make.defs index bb78f35aa..75051da51 100644 --- a/nuttx/configs/stm32f4discovery/winbuild/Make.defs +++ b/nuttx/configs/stm32f4discovery/winbuild/Make.defs @@ -81,7 +81,6 @@ LDSCRIPT = ld.script # Windows-native toolchains -MKDEP = $(TOPDIR)/tools/mkdeps.bat ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) @@ -137,3 +136,7 @@ HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe HOSTLDFLAGS = HOSTEXEEXT = .exe +# Windows-native host tools + +MKDEP = $(TOPDIR)/tools/mkdeps.exe + diff --git a/nuttx/tools/mkdeps.c b/nuttx/tools/mkdeps.c index f2a196387..a90595c98 100644 --- a/nuttx/tools/mkdeps.c +++ b/nuttx/tools/mkdeps.c @@ -288,6 +288,7 @@ static void do_dependency(const char *file, char separator) struct stat buf; char *altpath; char *path; + char *lasts; int cmdlen; int pathlen; int filelen; @@ -330,15 +331,15 @@ static void do_dependency(const char *file, char separator) /* Add a space */ command[cmdlen] = ' '; - command[cmdlen+1] = '\0'; cmdlen++; + command[cmdlen] = '\0'; /* Try each path. This loop will continue until each path has been tried * (failure) or until stat() finds the file */ altpath = g_altpath; - while ((path = strtok(altpath, " ")) != NULL) + while ((path = strtok_r(altpath, " ", &lasts)) != NULL) { /* Create a full path to the file */ @@ -565,6 +566,7 @@ static void do_winpath(char *file) int main(int argc, char **argv, char **envp) { + char *lasts; char *files; char *file; @@ -575,7 +577,7 @@ int main(int argc, char **argv, char **envp) /* Then generate dependencies for each path on the command line */ files = g_files; - while ((file = strtok(files, " ")) != NULL) + while ((file = strtok_r(files, " ", &lasts)) != NULL) { /* Check if we need to do path conversions for a Windows-natvie tool * being using in a POSIX/Cygwin environment. -- cgit v1.2.3