summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Olekhov <olekhov@gmail.com>2016-12-02 12:11:39 +0300
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-12-05 08:08:35 +0100
commit1bce4ce6dffa81532e065e60a6df5b91d037f68e (patch)
tree164f783e80bef9804d04257c7bb7ddf876506040
parentd8e5dd9454d89347efc1895f833bf459fa68a311 (diff)
downloadlibtasn1-1bce4ce6dffa81532e065e60a6df5b91d037f68e.tar.gz
MSVS 2013 and 2015 native builds
-rw-r--r--msvc/build_debug.bat11
-rw-r--r--msvc/build_release.bat9
-rw-r--r--msvc/libtasn1.mak42
-rw-r--r--msvc/msvc_exe.mk49
-rw-r--r--msvc/msvc_lib.mk46
-rw-r--r--msvc/snprintf.h33
-rw-r--r--msvc/test_parser.mak31
-rw-r--r--msvc/vcvars.mk138
8 files changed, 359 insertions, 0 deletions
diff --git a/msvc/build_debug.bat b/msvc/build_debug.bat
new file mode 100644
index 0000000..c1576ab
--- /dev/null
+++ b/msvc/build_debug.bat
@@ -0,0 +1,11 @@
+@echo off
+
+echo build 32 bit DEBUG
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Debug ARCH=32 clean >nul
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Debug ARCH=32
+gmake -f test_parser.mak VSTOOLSET=VS140 CONFIG=Debug ARCH=32
+echo build 64 bit DEBUG
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Debug ARCH=64 clean >nul
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Debug ARCH=64
+gmake -f test_parser.mak VSTOOLSET=VS140 CONFIG=Debug ARCH=64
+
diff --git a/msvc/build_release.bat b/msvc/build_release.bat
new file mode 100644
index 0000000..7bcae24
--- /dev/null
+++ b/msvc/build_release.bat
@@ -0,0 +1,9 @@
+@echo off
+
+echo build 32 bit RELEASE
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Release ARCH=32 clean
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Release ARCH=32
+echo build 64 bit RELEASE
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Release ARCH=64 clean
+gmake -f libtasn1.mak VSTOOLSET=VS140 CONFIG=Release ARCH=64
+
diff --git a/msvc/libtasn1.mak b/msvc/libtasn1.mak
new file mode 100644
index 0000000..ddc3209
--- /dev/null
+++ b/msvc/libtasn1.mak
@@ -0,0 +1,42 @@
+# This program 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/>.
+
+# Makefile to build libtasn1 as static library (libtasn1.lib)
+
+# Written by Vasiliy Olekhov November 2016.
+
+VPATH=../gl:../lib:../lib/gllib
+
+SRC= ASN1.c coding.c decoding.c element.c errors.c gstr.c
+SRC+= parser_aux.c structure.c version.c
+SRC+= strverscmp.c hash-pjw-bare.c
+
+TARGET=libtasn1.lib
+
+ifeq ($(ARCH), 64)
+ULSIZE=8
+else
+ULSIZE=4
+endif
+
+CFLAGS+=/D inline=__inline /D ASN1_STATIC /D _CRT_SECURE_NO_WARNINGS /D ASN1_API=
+CFLAGS+=/D SIZEOF_UNSIGNED_INT=4 /D SIZEOF_UNSIGNED_LONG_INT=$(ULSIZE)
+CFLAGS+=/D HAVE_CONFIG_H
+CFLAGS+=-I ../lib/gllib -I ../lib -I ../gl /I . -I ..
+
+# GLib stuff
+CFLAGS+=/D _GL_ATTRIBUTE_PURE=
+# snprintf workaround
+CFLAGS+=/FI ./snprintf.h
+
+include msvc_lib.mk
diff --git a/msvc/msvc_exe.mk b/msvc/msvc_exe.mk
new file mode 100644
index 0000000..0c42f24
--- /dev/null
+++ b/msvc/msvc_exe.mk
@@ -0,0 +1,49 @@
+# This program 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/>.
+
+# Makefile to build something to console executable (.exe)
+# requires gnu make 4.0, some posix tools (mkdir, rm)
+
+# set C sources to SRC var, extra libs to EXTRA_LIBS
+# set TARGET to executable (e.g. runtest.exe)
+
+# Written by Vasiliy Olekhov November 2016.
+
+
+include vcvars.mk
+
+#$(info Building $(ARCH) bits $(CONFIG))
+
+MKDIR_P=C:/gow/bin/mkdir.exe -p
+
+BUILD_PATH=build/$(ARCH)/$(CONFIG)
+BUILD_DIRS+=$(BUILD_PATH)
+
+LDFLAGS+=/libpath:'build/$(ARCH)/$(CONFIG)'
+
+OBJS=$(addprefix $(BUILD_PATH)/,$(SRC:.c=.obj))
+
+all: $(BUILD_DIRS) $(BUILD_PATH)/$(TARGET)
+
+$(BUILD_PATH)/$(TARGET): $(BUILD_DIRS) $(OBJS)
+ $(LD) $(LDFLAGS) $(OBJS) $(EXTRA_LIBS) /OUT:$@
+
+$(BUILD_PATH)/%.obj: %.c $(EXTRA_DEPS)
+ $(CC) $(CFLAGS) $(CDEBUG) $< /Fo$@
+
+$(BUILD_DIRS):
+ $(MKDIR_P) $@
+
+clean:
+ rm -f $(OBJS) $(BUILD_PATH)/$(TARGET)
+
diff --git a/msvc/msvc_lib.mk b/msvc/msvc_lib.mk
new file mode 100644
index 0000000..0289969
--- /dev/null
+++ b/msvc/msvc_lib.mk
@@ -0,0 +1,46 @@
+# This program 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/>.
+
+# Makefile to build something to static library (.lib)
+# requires gnu make 4.0, some posix tools (mkdir, rm)
+
+# set C sources to SRC var, extra libs to EXTRA_LIBS
+# set TARGET to library name (e.g. mylibrary.lib)
+
+# Written by Vasiliy Olekhov November 2016.
+
+
+include vcvars.mk
+
+#$(info Building $(ARCH) bits $(CONFIG))
+
+MKDIR_P=C:/gow/bin/mkdir.exe -p
+
+BUILD_PATH=build/$(ARCH)/$(CONFIG)
+BUILD_DIRS+=$(BUILD_PATH)
+
+OBJS=$(addprefix $(BUILD_PATH)/,$(SRC:.c=.obj))
+
+all: $(BUILD_DIRS) $(BUILD_PATH)/$(TARGET)
+
+$(BUILD_PATH)/$(TARGET): $(BUILD_DIRS) $(OBJS)
+ $(LIB) $(LIBFLAGS) $(OBJS) /OUT:$@
+
+$(BUILD_PATH)/%.obj: %.c $(EXTRA_DEPS)
+ $(CC) $(CFLAGS) $(CDEBUG) $< /Fo$@
+
+$(BUILD_DIRS):
+ $(MKDIR_P) $@
+
+clean:
+ rm -f $(OBJS) $(BUILD_PATH)/$(TARGET)
diff --git a/msvc/snprintf.h b/msvc/snprintf.h
new file mode 100644
index 0000000..a26247f
--- /dev/null
+++ b/msvc/snprintf.h
@@ -0,0 +1,33 @@
+#if defined(_MSC_VER) && _MSC_VER <= 1900
+#include <stdarg.h>
+#include <stdio.h>
+
+
+#define snprintf c99_snprintf
+#define vsnprintf c99_vsnprintf
+
+__inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
+{
+ int count = -1;
+
+ if (size != 0)
+ count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
+ if (count == -1)
+ count = _vscprintf(format, ap);
+
+ return count;
+}
+
+__inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
+{
+ int count;
+ va_list ap;
+
+ va_start(ap, format);
+ count = c99_vsnprintf(outBuf, size, format, ap);
+ va_end(ap);
+
+ return count;
+}
+
+#endif \ No newline at end of file
diff --git a/msvc/test_parser.mak b/msvc/test_parser.mak
new file mode 100644
index 0000000..3999d98
--- /dev/null
+++ b/msvc/test_parser.mak
@@ -0,0 +1,31 @@
+# This program 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/>.
+
+# Makefile to build test_parser.exe
+
+# Written by Vasiliy Olekhov November 2016.
+
+VPATH=../tests
+
+SRC= Test_parser.c
+
+TARGET=Test_parser.exe
+
+CFLAGS+=/D ASN1_STATIC
+CFLAGS+=/D _CRT_SECURE_NO_WARNINGS
+CFLAGS+=/D ASN1_API=
+CFLAGS+=-I ../lib
+
+EXTRA_LIBS=libtasn1.lib
+
+include msvc_exe.mk
diff --git a/msvc/vcvars.mk b/msvc/vcvars.mk
new file mode 100644
index 0000000..32a6b70
--- /dev/null
+++ b/msvc/vcvars.mk
@@ -0,0 +1,138 @@
+# This program 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/>.
+
+# This is a vcvarsall.bat replacement, makefile style
+# Needs gmake 4.0
+# You may encounter Windows builds of gnu make v.3.81. These are full of bugs.
+# You should get gnu make at least of version 4.0.
+# Better compile it yourself. Get sources from <https://www.gnu.org/software/make/>
+
+# This script tries to guess paths to compiler and SDK.
+
+# You need some posix tools in path: grep cut
+
+# Written by Vasiliy Olekhov November 2016.
+
+IS4MAKE=$(findstring z4, z$(MAKE_VERSION))
+
+ifneq ($(IS4MAKE),z4)
+$(error Need GNU MAKE 4.0 or higher)
+endif
+
+# Visual Studio Toolset. This is toolchain: compiler, linker, etc
+# VS120 = VisualStudio 2013
+# VS140 = VisualStudio 2015
+# Check your environment variable $(VS??COMNTOOLS).
+# See also <https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#History>
+# You may have different VS installed.
+VSTOOLSET?=VS120
+# Target platform: 32 or 64
+ARCH?=32
+# Target configuration: Debug or Release
+CONFIG?=Release
+
+# SDK Version. This is library set: standard C library etc.
+# You can compile with different Visual Studios and different SDKs
+# More info: <https://en.wikipedia.org/wiki/Microsoft_Windows_SDK>
+# You may have different SDKs installed. Set here what you need.
+
+#
+SDKVER=v8.1
+SDKSUBVER=winv6.3
+# Tested with VS2015 (VSTOOLSET=VS140) and VS2013 (VSTOOLSET=VS120):
+# SDKVER=v8.1 SDKSUBVER=winv6.3
+# SDKVER=v10.0 SDKSUBVER=10.0.14393.0
+
+# VS110 (VisualStudio 2012) and earlier do not support C99
+# (e.g. array initialization by index), don't bother
+
+# VSTOOLSET is commonly set in environment.
+# No matter whether you're running make from VS command prompt or not.
+TOOLS=$($(VSTOOLSET)COMNTOOLS)
+ifeq ($(TOOLS), )
+$(error Toolset not found. Check "$(VSTOOLSET)COMNTOOLS" environment variable)
+else
+#$(info Using toolset $(TOOLS))
+endif
+
+# Guess paths to SDKs
+SDKKEY=SOFTWARE\Microsoft\Microsoft SDKs\Windows
+SDK64KEY=SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows
+
+SDK!=reg query "HKLM\$(SDKKEY)\$(SDKVER)" 2>nul | grep InstallationFolder | cut -c 37-
+ifeq ($(SDK), )
+#$(info not found in HKLM 32bit)
+SDK!=reg query "HKLM\$(SDK64KEY)\$(SDKVER)" 2>nul | grep InstallationFolder | cut -c 37-
+endif
+ifeq ($(SDK), )
+#$(info not found in HKLM 64bit)
+SDK!=reg query "HKCU\$(SDKKEY)\$(SDKVER)" 2>nul | grep InstallationFolder | cut -c 37-
+endif
+ifeq ($(SDK), )
+#$(info not found in HKCU 32bit)
+SDK!=reg query "HKCU\$(SDK64KEY)\$(SDKVER)"2>nul | grep InstallationFolder | cut -c 37-
+endif
+ifeq ($(SDK), )
+$(error Can not find SDK installation.)
+endif
+#$(info SDK= [$(SDK)])
+
+SDK := $(subst \,/,$(SDK))
+
+VCROOT=$(subst \,/,$(TOOLS))../../vc
+VCINC=$(VCROOT)/Include
+#$(info VCROOT=$(VCROOT))
+
+ifeq ($(ARCH), 64)
+BIN=$(VCROOT)/bin/amd64
+VCLIB=$(VCROOT)/LIB/amd64
+SDKLIB=$(SDK)/lib/$(SDKSUBVER)/um/x64
+UCRTLIB=$(SDK)/lib/$(SDKSUBVER)/ucrt/x64
+else
+BIN=$(VCROOT)/bin
+VCLIB=$(VCROOT)/lib
+SDKLIB=$(SDK)/lib/$(SDKSUBVER)/um/x86
+UCRTLIB=$(SDK)/lib/$(SDKSUBVER)/ucrt/x86
+endif
+
+$(info Building $(ARCH) bits $(CONFIG))
+
+CC='$(BIN)/cl.exe'
+CFLAGS+=/nologo -c
+CFLAGS+=/EHsc
+CFLAGS+=/I '$(VCINC)' /I '$(SDK)Include/um'
+
+LD='$(BIN)/link.exe'
+LDFLAGS+=/nologo /libpath:'$(VCLIB)' /libpath:'$(SDKLIB)' /libpath:'$(UCRTLIB)'
+
+LIB='$(BIN)/lib.exe'
+LIBFLAGS+=/nologo
+
+# Please, check debug flags to meet your needs
+
+# MSVC runtime is compiled-in (static build)
+# Otherwise you need spare MSVCR???(D).dll lying
+# somewhere around at runtime.
+
+# Please note that it is strongly advised to match
+# runtime versions of library and user code.
+
+# If you need that dynamically linked, change /MTd to /MDd (debug)
+# and /MT to /MD (release)
+ifeq ($(CONFIG), Debug)
+CDEBUG=/DEBUG /Zi /W3 /WX- /sdl /Od /Oy- /D _DEBUG /RTC1 /MTd /GS /Gd /TC /analyze-
+LDEBUG=/DEBUG /MTd
+else
+CDEBUG=/MT
+LDEBUG=/MT
+endif