# HG changeset patch # User William Astle # Date 1432684431 21600 # Node ID 4130ffdeb5c86962443fe311db3e4913fc9eaec7 # Parent ade217fd76a51519fb968f00ad87d0a5e0f9eb3c Add contributed support for building with Microsoft's compiler Thanks to Erik G for various updates to allow building with Microsoft's compiler. These changes, in addition to some other generally good fixups from other commits, include: * move the version define to its own source file instead of as an option in Makefile. This is better anyway. * add some compatibilty stuff to lwlib This support is minimally invasive so it should continue to work. However, this is contributed code which I have no way to test. diff -r ade217fd76a5 -r 4130ffdeb5c8 00README.txt --- a/00README.txt Tue May 26 17:51:00 2015 -0600 +++ b/00README.txt Tue May 26 17:53:51 2015 -0600 @@ -10,6 +10,10 @@ have problems building, make sure you are using GNU make. Other make programs may work but GNU make is known to work. +There is some source code support for building with Microsoft's compiler on +Windows. However, this has been contributed by interested users and is not +well tested. Indeed, the primary maintainer has no access to such a system. + To see if a quick build will work, just type "make". If it works, you're ready to go ahead with "make install". This will install in /usr/local/bin. diff -r ade217fd76a5 -r 4130ffdeb5c8 Makefile --- a/Makefile Tue May 26 17:51:00 2015 -0600 +++ b/Makefile Tue May 26 17:53:51 2015 -0600 @@ -27,10 +27,10 @@ RANLIB := $(BUILDTPREFIX)$(RANLIB) endif -CPPFLAGS += -I lwlib -DPACKAGE_STRING='"lwtools 4.11+"' +CPPFLAGS += -I lwlib LDFLAGS += -Llwlib -llw -CFLAGS ?= -O3 -Wall +CFLAGS ?= -O3 -Wall -Wno-char-subscripts MAIN_TARGETS := lwasm/lwasm$(PROGSUFFIX) \ lwlink/lwlink$(PROGSUFFIX) \ diff -r ade217fd76a5 -r 4130ffdeb5c8 lwar/main.c --- a/lwar/main.c Tue May 26 17:51:00 2015 -0600 +++ b/lwar/main.c Tue May 26 17:53:51 2015 -0600 @@ -30,6 +30,7 @@ #include #include +#include #include "lwar.h" diff -r ade217fd76a5 -r 4130ffdeb5c8 lwasm/lwasm.h --- a/lwasm/lwasm.h Tue May 26 17:51:00 2015 -0600 +++ b/lwasm/lwasm.h Tue May 26 17:53:51 2015 -0600 @@ -22,10 +22,14 @@ #ifndef ___lwasm_h_seen___ #define ___lwasm_h_seen___ +#ifdef _MSC_VER +#include "lw_win.h" // windows build +#endif + #include #include #include - +#include // these are allowed chars BELOW 0x80 for symbols // first is symbol start chars, second is anywhere in symbol diff -r ade217fd76a5 -r 4130ffdeb5c8 lwlib/lw_expr.h --- a/lwlib/lw_expr.h Tue May 26 17:51:00 2015 -0600 +++ b/lwlib/lw_expr.h Tue May 26 17:53:51 2015 -0600 @@ -24,6 +24,10 @@ #include +#ifdef _MSC_VER +#include "lw_win.h" // windows build +#endif + enum { lw_expr_type_oper, // operator term diff -r ade217fd76a5 -r 4130ffdeb5c8 lwlib/lw_version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/lw_version.h Tue May 26 17:53:51 2015 -0600 @@ -0,0 +1,27 @@ +/* +lw_version.h + +Copyright © 2015 William Astle + +This file is part of LWTOOLS. + +LWTOOLS is free software: you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +#ifndef ___lw_version_h_seen___ +#define ___lw_version_h_seen___ + +#define PACKAGE_STRING "lwtools 4.11+" + +#endif /* ___lw_version_h_seen___ */ diff -r ade217fd76a5 -r 4130ffdeb5c8 lwlib/lw_win.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/lw_win.c Tue May 26 17:53:51 2015 -0600 @@ -0,0 +1,49 @@ +/* +lw_win.c + +Copyright © 2015 William Astle + +This file is part of LWTOOLS. + +LWTOOLS is free software: you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +#include "lw_win.h" + +#include +#include + +int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) +{ + int count = -1; + + if (size != 0) + count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} + +int c99_snprintf(char* str, size_t size, const char* format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + count = c99_vsnprintf(str, size, format, ap); + va_end(ap); + + return count; +} diff -r ade217fd76a5 -r 4130ffdeb5c8 lwlib/lw_win.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lwlib/lw_win.h Tue May 26 17:53:51 2015 -0600 @@ -0,0 +1,36 @@ +/* +lw_win.h + +Copyright © 2015 William Astle + +This file is part of LWTOOLS. + +LWTOOLS is free software: you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +#ifndef ___lw_win_h_seen___ +#define ___lw_win_h_seen___ + +#include "lw_string.h" +#include + +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#define unlink _unlink + +int c99_snprintf(char* str, size_t size, const char* format, ...); + +#define snprintf c99_snprintf + +#endif /* ___lw_win_h_seen___ */ diff -r ade217fd76a5 -r 4130ffdeb5c8 lwlink/main.c --- a/lwlink/main.c Tue May 26 17:51:00 2015 -0600 +++ b/lwlink/main.c Tue May 26 17:53:51 2015 -0600 @@ -29,6 +29,7 @@ #include #include +#include #include "lwlink.h" diff -r ade217fd76a5 -r 4130ffdeb5c8 win/lwasm.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/win/lwasm.vcxproj Tue May 26 17:53:51 2015 -0600 @@ -0,0 +1,130 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {93a52e3f-d19d-4a1a-8b8f-15270bd3d0e2} + + + + {52309F4D-C1D8-43FC-BC02-C71B69D01E3B} + Win32Proj + lwasm + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + $(SolutionDir)$(ProjectName)\$(Configuration)\ + $(SolutionDir)$(ProjectName)\$(Configuration)\ + + + false + $(SolutionDir)$(ProjectName)\$(Configuration)\ + $(SolutionDir)$(ProjectName)\$(Configuration)\ + + + + + + Level3 + Disabled + WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + ../lwlib + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + ../lwlib + + + Console + true + true + true + + + + + + \ No newline at end of file diff -r ade217fd76a5 -r 4130ffdeb5c8 win/lwlib.vcxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/win/lwlib.vcxproj Tue May 26 17:53:51 2015 -0600 @@ -0,0 +1,106 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + {93A52E3F-D19D-4A1A-8B8F-15270BD3D0E2} + Win32Proj + lwlib + + + + StaticLibrary + true + v120 + Unicode + + + StaticLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + $(SolutionDir)$(ProjectName)\$(Configuration)\ + $(SolutionDir)$(ProjectName)\$(Configuration)\ + + + $(SolutionDir)$(ProjectName)\$(Configuration)\ + $(SolutionDir)$(ProjectName)\$(Configuration)\ + + + + + + Level3 + Disabled + WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + Windows + true + true + true + + + + + + \ No newline at end of file diff -r ade217fd76a5 -r 4130ffdeb5c8 win/lwtools.sln --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/win/lwtools.sln Tue May 26 17:53:51 2015 -0600 @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lwlib", "lwlib.vcxproj", "{93A52E3F-D19D-4A1A-8B8F-15270BD3D0E2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lwasm", "lwasm.vcxproj", "{52309F4D-C1D8-43FC-BC02-C71B69D01E3B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {93A52E3F-D19D-4A1A-8B8F-15270BD3D0E2}.Debug|Win32.ActiveCfg = Debug|Win32 + {93A52E3F-D19D-4A1A-8B8F-15270BD3D0E2}.Debug|Win32.Build.0 = Debug|Win32 + {93A52E3F-D19D-4A1A-8B8F-15270BD3D0E2}.Release|Win32.ActiveCfg = Release|Win32 + {93A52E3F-D19D-4A1A-8B8F-15270BD3D0E2}.Release|Win32.Build.0 = Release|Win32 + {52309F4D-C1D8-43FC-BC02-C71B69D01E3B}.Debug|Win32.ActiveCfg = Debug|Win32 + {52309F4D-C1D8-43FC-BC02-C71B69D01E3B}.Debug|Win32.Build.0 = Debug|Win32 + {52309F4D-C1D8-43FC-BC02-C71B69D01E3B}.Release|Win32.ActiveCfg = Release|Win32 + {52309F4D-C1D8-43FC-BC02-C71B69D01E3B}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal