Skip to content

Commit

Permalink
Merge pull request #300 from k-takata/update-win32-buildsys
Browse files Browse the repository at this point in the history
win32: Update build system
  • Loading branch information
Shougo committed Jan 20, 2020
2 parents eb10ca4 + a7dba44 commit 51f4664
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 321 deletions.
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
*.bat text eol=crlf
16 changes: 4 additions & 12 deletions README.mkd
Expand Up @@ -149,22 +149,14 @@ Windows using MinGW (64bit Vim):

Windows using Visual Studio (32bit/64bit Vim):

$ nmake -f make_msvc.mak nodebug=1

Note: To build with Visual Studio, you must install Windows SDK and run from
VS command prompt.
https://github.com/Shougo/vimproc.vim/issues/58

If you use MSVC 11 or later, you need to specify where the Win32.mak file is,
e.g.:

$ nmake -f make_msvc.mak nodebug=1 "SDK_INCLUDE_DIR=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include"
$ nmake -f make_msvc.mak

You should run this from VS command prompt.
The architecture will be automatically detected, but you can also specify the
architecture explicitly. E.g.:

32bit: nmake -f make_msvc.mak nodebug=1 CPU=i386
64bit: nmake -f make_msvc.mak nodebug=1 CPU=AMD64
32bit: nmake -f make_msvc.mak CPU=i386
64bit: nmake -f make_msvc.mak CPU=AMD64

Cygwin:

Expand Down
16 changes: 4 additions & 12 deletions doc/vimproc.txt
Expand Up @@ -128,22 +128,14 @@ Windows using MinGW (64bit Vim):
<
Windows using Visual Studio (32bit/64bit Vim):
>
$ nmake -f make_msvc.mak nodebug=1
<
Note: To build with Visual Studio, you must install Windows SDK and run from
VS command prompt.
https://github.com/Shougo/vimproc.vim/issues/58

If you use MSVC 11 or later, you need to specify where the Win32.mak file is,
e.g.:
>
$ nmake -f make_msvc.mak nodebug=1 "SDK_INCLUDE_DIR=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include"
$ nmake -f make_msvc.mak
<
You should run this from VS command prompt.
The architecture will be automatically detected, but you can also specify the
architecture explicitly. E.g.:
>
32bit: nmake -f make_msvc.mak nodebug=1 CPU=i386
64bit: nmake -f make_msvc.mak nodebug=1 CPU=AMD64
32bit: nmake -f make_msvc.mak CPU=i386
64bit: nmake -f make_msvc.mak CPU=AMD64
<
* Cygwin: *vimproc-cygwin*
>
Expand Down
154 changes: 74 additions & 80 deletions make_msvc.mak
@@ -1,80 +1,74 @@
# WINDOWS BUILD SETTINGS.
# For MSVC 11 you need to specify where the Win32.mak file is, e.g.:
# SDK_INCLUDE_DIR=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include
# for build win64 version:
# nmake -f make_msvc.mak CPU=AMD64

WINVER = 0x0500
APPVER = 5.0
TARGET = WINNT
_WIN32_IE = 0x0500
# CPU = AMD64

# Win32.mak requires that CPU be set appropriately.
# To cross-compile for Win64, set CPU=AMD64 or CPU=IA64.
!ifndef CPU
CPU = $(PROCESSOR_ARCHITECTURE)
! if ("$(CPU)" == "x86") || ("$(CPU)" == "X86")
CPU = i386
! endif
!endif

# Get all sorts of useful, standard macros from the Platform SDK.
!ifdef SDK_INCLUDE_DIR
!include $(SDK_INCLUDE_DIR)\Win32.mak
!else
!include <Win32.mak>
!endif

# CONTROL BUILD MODE

!IFDEF DEBUG
CFLAGS = $(CFLAGS) -D_DEBUG
!ELSE
CFLAGS = $(CFLAGS) -D_NDEBUG
!ENDIF

# VIMPROC SPECIFICS

!if "$(CPU)" == "AMD64"
VIMPROC=vimproc_win64
!else
VIMPROC=vimproc_win32
!endif

SRCDIR = src
LIBDIR = lib
OUTDIR = $(SRCDIR)\obj$(CPU)

OBJS = $(OUTDIR)/proc_w32.obj

DEFINES = -D_CRT_SECURE_NO_WARNINGS=1 -D_BIND_TO_CURRENT_VCLIBS_VERSION=1
CFLAGS = $(CFLAGS) $(DEFINES) /wd4100 /wd4127 /O2

# RULES

build: $(LIBDIR)\$(VIMPROC).dll

clean:
-IF EXIST $(OUTDIR)/nul RMDIR /s /q $(OUTDIR)
-DEL /F /Q $(LIBDIR)\vimproc_win32.*
-DEL /F /Q $(LIBDIR)\vimproc_win64.*
-DEL /F /Q $(SRCDIR)\*.obj
-DEL /F /Q $(SRCDIR)\*.pdb

$(LIBDIR)\$(VIMPROC).dll: $(OBJS)
$(link) /NOLOGO $(ldebug) $(dlllflags) $(conlibsdll) $(LFLAGS) \
/OUT:$@ $(OBJS) shell32.lib
IF EXIST $@.manifest \
mt -nologo -manifest $@.manifest -outputresource:$@;2

{$(SRCDIR)}.c{$(OUTDIR)}.obj::
$(cc) $(cdebug) $(cflags) $(cvarsdll) $(CFLAGS) -Fd$(SRCDIR)\ \
-Fo$(OUTDIR)\ $<

$(OUTDIR):
IF NOT EXIST $(OUTDIR)/nul MKDIR $(OUTDIR)

$(OUTDIR)/proc_w32.obj: $(OUTDIR) $(SRCDIR)/proc_w32.c $(SRCDIR)/vimstack.c

.PHONY: build clean
# WINDOWS BUILD SETTINGS.

WINVER = 0x0500
APPVER = 5.0
TARGET = WINNT
_WIN32_IE = 0x0500

!ifdef CPU
! if "$(CPU)" == "I386"
CPU = i386
! endif
!else # !CPU
CPU = i386
! if !defined(PLATFORM) && defined(TARGET_CPU)
PLATFORM = $(TARGET_CPU)
! endif
! ifdef PLATFORM
! if ("$(PLATFORM)" == "x64") || ("$(PLATFORM)" == "X64")
CPU = AMD64
! elseif ("$(PLATFORM)" != "x86") && ("$(PLATFORM)" != "X86")
! error *** ERROR Unknown target platform "$(PLATFORM)". Make aborted.
! endif
! endif
!endif

# CONTROL BUILD MODE

!IFDEF DEBUG
CFLAGS = $(CFLAGS) -D_DEBUG
!ELSE
CFLAGS = $(CFLAGS) -D_NDEBUG
!ENDIF

# VIMPROC SPECIFICS

!if "$(CPU)" == "AMD64"
VIMPROC=vimproc_win64
!else
VIMPROC=vimproc_win32
!endif

SRCDIR = src
LIBDIR = lib
OUTDIR = $(SRCDIR)\obj$(CPU)

OBJS = $(OUTDIR)/proc_w32.obj

LINK = link
LFLAGS = /nologo /dll
DEFINES = -D_CRT_SECURE_NO_WARNINGS=1 -D_BIND_TO_CURRENT_VCLIBS_VERSION=1
CFLAGS = /nologo $(CFLAGS) $(DEFINES) /wd4100 /wd4127 /O2 /LD /c

# RULES

build: $(LIBDIR)\$(VIMPROC).dll

clean:
-IF EXIST $(OUTDIR)/nul RMDIR /s /q $(OUTDIR)
-DEL /F /Q $(LIBDIR)\$(VIMPROC).*

$(LIBDIR)\$(VIMPROC).dll: $(OBJS)
$(LINK) $(LFLAGS) /OUT:$@ $(OBJS) shell32.lib ws2_32.lib
IF EXIST $@.manifest \
mt -nologo -manifest $@.manifest -outputresource:$@;2

{$(SRCDIR)}.c{$(OUTDIR)}.obj::
$(CC) $(CFLAGS) -Fo$(OUTDIR)\ $<

$(OUTDIR):
IF NOT EXIST $(OUTDIR)/nul MKDIR $(OUTDIR)

$(OUTDIR)/proc_w32.obj: $(OUTDIR) $(SRCDIR)/proc_w32.c $(SRCDIR)/vimstack.c

.PHONY: build clean

0 comments on commit 51f4664

Please sign in to comment.