From 935e76df9f1d38703179c869e50cf90b540705c0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 22 Aug 2014 14:48:29 -0600 Subject: [PATCH] Changes to try to get P112 to compile with laster SDCC (it still does not) --- configs/p112/ostest/Make.defs | 11 +++-- configs/p112/ostest/setenv.bat | 5 ++- tools/bdf-converter.c | 77 ++++++++++++++++++++++++++++++++++ tools/mkdeps.c | 11 +++-- 4 files changed, 95 insertions(+), 9 deletions(-) diff --git a/configs/p112/ostest/Make.defs b/configs/p112/ostest/Make.defs index e64c7b5dd3..4239f49951 100644 --- a/configs/p112/ostest/Make.defs +++ b/configs/p112/ostest/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/p112/ostest/Make.defs # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -81,7 +81,8 @@ AFLAGS = -x -a -l -o -s -g SDCCLIB = z180.lib ASMEXT = .asm -OBJEXT = .o +# OBJEXT = .o +OBJEXT = .rel LIBEXT = .lib EXEEXT = .hex @@ -122,7 +123,9 @@ endif # Windows native host tool definitions ifeq ($(CONFIG_WINDOWS_NATIVE),y) - HOSTCC = mingw32-gcc.exe +# You may need to customize the binary name: +# HOSTCC = mingw32-gcc.exe + HOSTCC = x86_64-w64-mingw32-gcc.exe HOSTINCLUDES = -I. HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe HOSTLDFLAGS = @@ -130,7 +133,7 @@ ifeq ($(CONFIG_WINDOWS_NATIVE),y) # Windows-native host tools - MKDEP = $(TOPDIR)\tools\mkdeps.exe --winnative + MKDEP = $(TOPDIR)\tools\mkdeps.exe --winnative # --dep-debug # Use NTFS links or directory copies diff --git a/configs/p112/ostest/setenv.bat b/configs/p112/ostest/setenv.bat index 19ca1ef57d..01eb774dd5 100644 --- a/configs/p112/ostest/setenv.bat +++ b/configs/p112/ostest/setenv.bat @@ -2,7 +2,7 @@ rem configs/p112/ostest/setenv.bat rem -rem Copyright (C) 2012 Gregory Nutt. All rights reserved. +rem Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. rem Author: Gregory Nutt rem rem Redistribution and use in source and binary forms, with or without @@ -41,7 +41,8 @@ set PATH=C:\MinGW\bin;%PATH% rem This is the location where I installed the SDCC toolchain for windows. -set PATH=C:\Program Files (x86)\SDCC/bin;%PATH% +rem set PATH=C:\Program Files (x86)\SDCC/bin;%PATH% +set PATH=C:\Program Files\SDCC/bin;%PATH% rem This is the location where I installed the GNUWin32 tools. See rem http://gnuwin32.sourceforge.net/. diff --git a/tools/bdf-converter.c b/tools/bdf-converter.c index 2c4efa1ec6..a93da0f2b1 100644 --- a/tools/bdf-converter.c +++ b/tools/bdf-converter.c @@ -115,6 +115,83 @@ typedef struct nx_fontmetric_s * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: MY_strtok_r + * + * Description: + * MinGW does not seem to provide strtok_r + * + ****************************************************************************/ + +#ifndef HAVE_STRTOK_R +static char *MY_strtok_r(char *str, const char *delim, char **saveptr) +{ + char *pbegin; + char *pend = NULL; + + /* Decide if we are starting a new string or continuing from + * the point we left off. + */ + + if (str) + { + pbegin = str; + } + else if (saveptr && *saveptr) + { + pbegin = *saveptr; + } + else + { + return NULL; + } + + /* Find the beginning of the next token */ + + for (; + *pbegin && strchr(delim, *pbegin) != NULL; + pbegin++); + + /* If we are at the end of the string with nothing + * but delimiters found, then return NULL. + */ + + if (!*pbegin) + { + return NULL; + } + + /* Find the end of the token */ + + for (pend = pbegin + 1; + *pend && strchr(delim, *pend) == NULL; + pend++); + + /* pend either points to the end of the string or to + * the first delimiter after the string. + */ + + if (*pend) + { + /* Turn the delimiter into a null terminator */ + + *pend++ = '\0'; + } + + /* Save the pointer where we left off and return the + * beginning of the token. + */ + + if (saveptr) + { + *saveptr = pend; + } + return pbegin; +} + +#define strtok_r MY_strtok_r +#endif + /**************************************************************************** * Name: trimLine * diff --git a/tools/mkdeps.c b/tools/mkdeps.c index a4bc68955a..c0b71e707b 100644 --- a/tools/mkdeps.c +++ b/tools/mkdeps.c @@ -473,7 +473,7 @@ static void do_dependency(const char *file, char separator) dotptr = strrchr(objname, '.'); if (dotptr) { - dotptr = '\0'; + *dotptr = '\0'; } snprintf(tmp, NAME_MAX+6, " -MT %s" DELIM "%s%s ", @@ -515,7 +515,7 @@ static void do_dependency(const char *file, char separator) g_command[cmdlen] = '\0'; /* Make a copy of g_altpath. We need to do this because at least the version - * of strtok_r above does modifie it. + * of strtok_r above does modify it. */ alloc = strdup(g_altpath); @@ -598,6 +598,11 @@ static void do_dependency(const char *file, char separator) * from the compiler is in WEXITSTATUS(ret). */ + if (g_debug) + { + fprintf(stderr, "Executing: %s\n", g_command); + } + ret = system(g_command); #ifdef WEXITSTATUS if (ret < 0 || WEXITSTATUS(ret) != 0) @@ -687,7 +692,7 @@ static char *cywin2windows(const char *str, const char *append, enum slashmode_e drive = toupper(*str); if (drive < 'A' || drive > 'Z') { - fprintf(stderr, "ERROR: Drive charager: \"%s\"\n", str); + fprintf(stderr, "ERROR: Drive character: \"%s\"\n", str); exit(EXIT_FAILURE); }