Mercurial > hg > index.cgi
changeset 361:4130ffdeb5c8
Add contributed support for building with Microsoft's compiler
Thanks to Erik G <erik@6809.org> 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.
author | William Astle <lost@l-w.ca> |
---|---|
date | Tue, 26 May 2015 17:53:51 -0600 |
parents | ade217fd76a5 |
children | d149e2b56981 |
files | 00README.txt Makefile lwar/main.c lwasm/lwasm.h lwlib/lw_expr.h lwlib/lw_version.h lwlib/lw_win.c lwlib/lw_win.h lwlink/main.c win/lwasm.vcxproj win/lwlib.vcxproj win/lwtools.sln |
diffstat | 12 files changed, 393 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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) \
--- 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 <unistd.h> #include <lw_cmdline.h> +#include <lw_version.h> #include "lwar.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 <lw_expr.h> #include <lw_stringlist.h> #include <lw_stack.h> - +#include <lw_version.h> // these are allowed chars BELOW 0x80 for symbols // first is symbol start chars, second is anywhere in symbol
--- 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 <stdio.h> +#ifdef _MSC_VER +#include "lw_win.h" // windows build +#endif + enum { lw_expr_type_oper, // operator term
--- /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 <http://www.gnu.org/licenses/>. +*/ + +#ifndef ___lw_version_h_seen___ +#define ___lw_version_h_seen___ + +#define PACKAGE_STRING "lwtools 4.11+" + +#endif /* ___lw_version_h_seen___ */
--- /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 <http://www.gnu.org/licenses/>. +*/ + +#include "lw_win.h" + +#include <stdio.h> +#include <stdarg.h> + +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; +}
--- /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 <http://www.gnu.org/licenses/>. +*/ + +#ifndef ___lw_win_h_seen___ +#define ___lw_win_h_seen___ + +#include "lw_string.h" +#include <string.h> + +#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___ */
--- 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 <string.h> #include <lw_cmdline.h> +#include <lw_version.h> #include "lwlink.h"
--- /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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\lwasm\debug.c" /> + <ClCompile Include="..\lwasm\input.c" /> + <ClCompile Include="..\lwasm\insn_bitbit.c" /> + <ClCompile Include="..\lwasm\insn_gen.c" /> + <ClCompile Include="..\lwasm\insn_indexed.c" /> + <ClCompile Include="..\lwasm\insn_inh.c" /> + <ClCompile Include="..\lwasm\insn_logicmem.c" /> + <ClCompile Include="..\lwasm\insn_rel.c" /> + <ClCompile Include="..\lwasm\insn_rlist.c" /> + <ClCompile Include="..\lwasm\insn_rtor.c" /> + <ClCompile Include="..\lwasm\insn_tfm.c" /> + <ClCompile Include="..\lwasm\instab.c" /> + <ClCompile Include="..\lwasm\list.c" /> + <ClCompile Include="..\lwasm\lwasm.c" /> + <ClCompile Include="..\lwasm\macro.c" /> + <ClCompile Include="..\lwasm\main.c" /> + <ClCompile Include="..\lwasm\os9.c" /> + <ClCompile Include="..\lwasm\output.c" /> + <ClCompile Include="..\lwasm\pass1.c" /> + <ClCompile Include="..\lwasm\pass2.c" /> + <ClCompile Include="..\lwasm\pass3.c" /> + <ClCompile Include="..\lwasm\pass4.c" /> + <ClCompile Include="..\lwasm\pass5.c" /> + <ClCompile Include="..\lwasm\pass6.c" /> + <ClCompile Include="..\lwasm\pass7.c" /> + <ClCompile Include="..\lwasm\pragma.c" /> + <ClCompile Include="..\lwasm\pseudo.c" /> + <ClCompile Include="..\lwasm\section.c" /> + <ClCompile Include="..\lwasm\struct.c" /> + <ClCompile Include="..\lwasm\symbol.c" /> + <ClCompile Include="..\lwasm\unicorns.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\lwasm\input.h" /> + <ClInclude Include="..\lwasm\instab.h" /> + <ClInclude Include="..\lwasm\lwasm.h" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="lwlib.vcxproj"> + <Project>{93a52e3f-d19d-4a1a-8b8f-15270bd3d0e2}</Project> + </ProjectReference> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{52309F4D-C1D8-43FC-BC02-C71B69D01E3B}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>lwasm</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir> + <IntDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir> + <IntDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>../lwlib</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>../lwlib</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file
--- /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 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\lwlib\lw_alloc.c" /> + <ClCompile Include="..\lwlib\lw_cmdline.c" /> + <ClCompile Include="..\lwlib\lw_error.c" /> + <ClCompile Include="..\lwlib\lw_expr.c" /> + <ClCompile Include="..\lwlib\lw_free.c" /> + <ClCompile Include="..\lwlib\lw_realloc.c" /> + <ClCompile Include="..\lwlib\lw_stack.c" /> + <ClCompile Include="..\lwlib\lw_string.c" /> + <ClCompile Include="..\lwlib\lw_stringlist.c" /> + <ClCompile Include="..\lwlib\lw_win.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\lwlib\lw_alloc.h" /> + <ClInclude Include="..\lwlib\lw_cmdline.h" /> + <ClInclude Include="..\lwlib\lw_error.h" /> + <ClInclude Include="..\lwlib\lw_expr.h" /> + <ClInclude Include="..\lwlib\lw_stack.h" /> + <ClInclude Include="..\lwlib\lw_string.h" /> + <ClInclude Include="..\lwlib\lw_stringlist.h" /> + <ClInclude Include="..\lwlib\lw_version.h" /> + <ClInclude Include="..\lwlib\lw_win.h" /> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{93A52E3F-D19D-4A1A-8B8F-15270BD3D0E2}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>lwlib</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir> + <IntDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir> + <IntDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file
--- /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