blob: 203438a59721a2902a5ef8047cd4a74aae5009be [file] [log] [blame]
Bram Moolenaar4f7e8212014-11-05 13:53:32 +01001# Makefile for VIM on Win32 (Cygwin and MinGW)
2#
3# This file contains common part for Cygwin and MinGW and it is included
4# from Make_cyg.mak and Make_ming.mak.
5#
6# Info at http://www.mingw.org
7# Alternative x86 and 64-builds: http://mingw-w64.sourceforge.net
8# Also requires GNU make, which you can download from the same sites.
9# Get missing libraries from http://gnuwin32.sf.net.
10#
11# Tested on Win32 NT 4 and Win95.
12#
13# To make everything, just 'make -f Make_ming.mak'.
14# To make just e.g. gvim.exe, 'make -f Make_ming.mak gvim.exe'.
15# After a run, you can 'make -f Make_ming.mak clean' to clean up.
16#
17# NOTE: Sometimes 'GNU Make' will stop after building vimrun.exe -- I think
18# it's just run out of memory or something. Run again, and it will continue
19# with 'xxd'.
20#
21# "make upx" makes *compressed* versions of the 32 bit GUI and console EXEs,
22# using the excellent UPX compressor:
23# http://upx.sourceforge.net/
24# "make mpress" uses the MPRESS compressor for 32- and 64-bit EXEs:
25# http://www.matcode.com/mpress.htm
26#
27# Maintained by Ron Aaron <ronaharon@yahoo.com> et al.
28# Updated 2014 Oct 13.
29
30#>>>>> choose options:
31# set to yes for a debug build
32DEBUG=no
33# set to SIZE for size, SPEED for speed, MAXSPEED for maximum optimization
34OPTIMIZE=MAXSPEED
35# set to yes to make gvim, no for vim
36GUI=yes
37# set to yes if you want to use DirectWrite (DirectX)
38# MinGW-w64 is needed, and ARCH should be set to i686 or x86-64.
39DIRECTX=no
40# FEATURES=[TINY | SMALL | NORMAL | BIG | HUGE]
41# Set to TINY to make minimal version (few features).
Bram Moolenaare5f2be62016-01-21 20:24:34 +010042FEATURES=HUGE
Bram Moolenaar4f7e8212014-11-05 13:53:32 +010043# Set to one of i386, i486, i586, i686 as the minimum target processor.
44# For amd64/x64 architecture set ARCH=x86-64 .
45ARCH=i386
46# Set to yes to cross-compile from unix; no=native Windows (and Cygwin).
47CROSS=no
48# Set to path to iconv.h and libiconv.a to enable using 'iconv.dll'.
49#ICONV="."
50ICONV=yes
51GETTEXT=yes
52# Set to yes to include multibyte support.
53MBYTE=yes
54# Set to yes to include IME support.
55IME=yes
56DYNAMIC_IME=yes
57# Set to yes to enable writing a postscript file with :hardcopy.
58POSTSCRIPT=no
59# Set to yes to enable OLE support.
60OLE=no
61# Set the default $(WINVER) to make it work with pre-Win2k.
62ifndef WINVER
63WINVER = 0x0500
64endif
65# Set to yes to enable Cscope support.
66CSCOPE=yes
67# Set to yes to enable Netbeans support.
68NETBEANS=$(GUI)
69
70
71# Link against the shared version of libstdc++ by default. Set
72# STATIC_STDCPLUS to "yes" to link against static version instead.
73ifndef STATIC_STDCPLUS
74STATIC_STDCPLUS=no
75endif
76
77# If the user doesn't want gettext, undefine it.
78ifeq (no, $(GETTEXT))
79GETTEXT=
80endif
81# Added by E.F. Amatria <eferna1@platea.ptic.mec.es> 2001 Feb 23
82# Uncomment the first line and one of the following three if you want Native Language
83# Support. You'll need gnu_gettext.win32, a MINGW32 Windows PORT of gettext by
84# Franco Bez <franco.bez@gmx.de>. It may be found at
85# http://home.a-city.de/franco.bez/gettext/gettext_win32_en.html
86# Tested with mingw32 with GCC-2.95.2 on Win98
87# Updated 2001 Jun 9
88#GETTEXT=c:/gettext.win32.msvcrt
89#STATIC_GETTEXT=USE_STATIC_GETTEXT
90#DYNAMIC_GETTEXT=USE_GETTEXT_DLL
91#DYNAMIC_GETTEXT=USE_SAFE_GETTEXT_DLL
92SAFE_GETTEXT_DLL_OBJ = $(GETTEXT)/src/safe_gettext_dll/safe_gettext_dll.o
93# Alternatively, if you uncomment the two following lines, you get a "safe" version
94# without linking the safe_gettext_dll.o object file.
95#DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
96#GETTEXT_DYNAMIC=gnu_gettext.dll
97INTLPATH=$(GETTEXT)/lib/mingw32
98INTLLIB=gnu_gettext
99
100# If you are using gettext-0.10.35 from http://sourceforge.net/projects/gettext
101# or gettext-0.10.37 from http://sourceforge.net/projects/mingwrep/
102# uncomment the following, but I can't build a static version with them, ?-(|
103#GETTEXT=c:/gettext-0.10.37-20010430
104#STATIC_GETTEXT=USE_STATIC_GETTEXT
105#DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
106#INTLPATH=$(GETTEXT)/lib
107#INTLLIB=intl
108
109# Perl interface:
110# PERL=[Path to Perl directory] (Set inside Make_cyg.mak or Make_ming.mak)
111# DYNAMIC_PERL=yes (to load the Perl DLL dynamically)
112# PERL_VER=[Perl version, eg 56, 58, 510] (default is 56)
113ifdef PERL
114ifndef PERL_VER
115PERL_VER=56
116endif
117ifndef DYNAMIC_PERL
118DYNAMIC_PERL=yes
119endif
120# on Linux, for cross-compile, it's here:
121#PERLLIB=/home/ron/ActivePerl/lib
122# on NT, it's here:
123PERLEXE=$(PERL)/bin/perl
124PERLLIB=$(PERL)/lib
125PERLLIBS=$(PERLLIB)/Core
126ifeq ($(UNDER_CYGWIN),yes)
127PERLTYPEMAP:=$(shell cygpath -m $(PERLLIB)/ExtUtils/typemap)
128XSUBPPTRY:=$(shell cygpath -m $(PERLLIB)/ExtUtils/xsubpp)
129else
130PERLTYPEMAP=$(PERLLIB)/ExtUtils/typemap
131XSUBPPTRY=$(PERLLIB)/ExtUtils/xsubpp
132endif
133XSUBPP_EXISTS=$(shell $(PERLEXE) -e "print 1 unless -e '$(XSUBPPTRY)'")
134ifeq "$(XSUBPP_EXISTS)" ""
Bram Moolenaar345326a2014-11-06 10:03:01 +0100135XSUBPP=$(PERLEXE) $(XSUBPPTRY)
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100136else
137XSUBPP=xsubpp
138endif
139endif
140
141# Lua interface:
142# LUA=[Path to Lua directory] (Set inside Make_cyg.mak or Make_ming.mak)
143# DYNAMIC_LUA=yes (to load the Lua DLL dynamically)
144# LUA_VER=[Lua version, eg 51, 52] (default is 51)
145ifdef LUA
146ifndef DYNAMIC_LUA
147DYNAMIC_LUA=yes
148endif
149
150ifndef LUA_VER
151LUA_VER=51
152endif
153
154ifeq (no,$(DYNAMIC_LUA))
155LUA_LIB = -L$(LUA)/lib -llua
156endif
157
158endif
159
160# MzScheme interface:
161# MZSCHEME=[Path to MzScheme directory] (Set inside Make_cyg.mak or Make_ming.mak)
162# DYNAMIC_MZSCHEME=yes (to load the MzScheme DLL dynamically)
163# MZSCHEME_VER=[MzScheme version] (default is 205_000)
164# MZSCHEME_DEBUG=no
165ifdef MZSCHEME
166ifndef DYNAMIC_MZSCHEME
167DYNAMIC_MZSCHEME=yes
168endif
169
170ifndef MZSCHEME_VER
171MZSCHEME_VER=205_000
172endif
173
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100174# for version 4.x we need to generate byte-code for Scheme base
175ifndef MZSCHEME_GENERATE_BASE
176MZSCHEME_GENERATE_BASE=no
177endif
178
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100179ifneq ($(wildcard $(MZSCHEME)/lib/msvc/libmzsch$(MZSCHEME_VER).lib),)
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100180MZSCHEME_MAIN_LIB=mzsch
181else
182MZSCHEME_MAIN_LIB=racket
183endif
184
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100185ifndef MZSCHEME_PRECISE_GC
186MZSCHEME_PRECISE_GC=no
187ifneq ($(wildcard $(MZSCHEME)\lib\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll),)
188ifeq ($(wildcard $(MZSCHEME)\lib\libmzgc$(MZSCHEME_VER).dll),)
189MZSCHEME_PRECISE_GC=yes
190endif
191else
192ifneq ($(wildcard $(MZSCHEME)\lib\msvc\lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).lib),)
193ifeq ($(wildcard $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib),)
194MZSCHEME_PRECISE_GC=yes
195endif
196endif
197endif
198endif
199
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100200ifeq (no,$(DYNAMIC_MZSCHEME))
201ifeq (yes,$(MZSCHEME_PRECISE_GC))
202MZSCHEME_LIB=-l$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER)
203else
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100204MZSCHEME_LIB=-l$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER)
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100205endif
206# the modern MinGW can dynamically link to dlls directly.
207# point MZSCHEME_DLLS to where you put libmzschXXXXXXX.dll and libgcXXXXXXX.dll
208ifndef MZSCHEME_DLLS
209MZSCHEME_DLLS=$(MZSCHEME)
210endif
211MZSCHEME_LIBDIR=-L$(MZSCHEME_DLLS) -L$(MZSCHEME_DLLS)\lib
212endif
213
214endif
215
216# Python interface:
217# PYTHON=[Path to Python directory] (Set inside Make_cyg.mak or Make_ming.mak)
218# DYNAMIC_PYTHON=yes (to load the Python DLL dynamically)
219# PYTHON_VER=[Python version, eg 22, 23, ..., 27] (default is 22)
220ifdef PYTHON
221ifndef DYNAMIC_PYTHON
222DYNAMIC_PYTHON=yes
223endif
224
225ifndef PYTHON_VER
Bram Moolenaar3c6f92e2016-01-02 20:26:36 +0100226PYTHON_VER=27
227endif
228ifndef DYNAMIC_PYTHON_DLL
229DYNAMIC_PYTHON_DLL=python$(PYTHON_VER).dll
230endif
231ifdef PYTHON_HOME
232PYTHON_HOME_DEF=-DPYTHON_HOME=\"$(PYTHON_HOME)\"
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100233endif
234
235ifeq (no,$(DYNAMIC_PYTHON))
236PYTHONLIB=-L$(PYTHON)/libs -lpython$(PYTHON_VER)
237endif
238# my include files are in 'win32inc' on Linux, and 'include' in the standard
239# NT distro (ActiveState)
Bram Moolenaar3c6f92e2016-01-02 20:26:36 +0100240ifndef PYTHONINC
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100241ifeq ($(CROSS),no)
242PYTHONINC=-I $(PYTHON)/include
243else
244PYTHONINC=-I $(PYTHON)/win32inc
245endif
246endif
Bram Moolenaar3c6f92e2016-01-02 20:26:36 +0100247endif
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100248
249# Python3 interface:
250# PYTHON3=[Path to Python3 directory] (Set inside Make_cyg.mak or Make_ming.mak)
251# DYNAMIC_PYTHON3=yes (to load the Python3 DLL dynamically)
252# PYTHON3_VER=[Python3 version, eg 31, 32] (default is 31)
253ifdef PYTHON3
254ifndef DYNAMIC_PYTHON3
255DYNAMIC_PYTHON3=yes
256endif
257
258ifndef PYTHON3_VER
259PYTHON3_VER=31
260endif
Bram Moolenaara7c37952016-01-20 22:23:15 +0100261ifndef DYNAMIC_PYTHON3_DLL
262DYNAMIC_PYTHON3_DLL=python$(PYTHON3_VER).dll
263endif
264ifdef PYTHON3_HOME
265PYTHON3_HOME_DEF=-DPYTHON3_HOME=\"$(PYTHON3_HOME)\"
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100266endif
267
Bram Moolenaara7c37952016-01-20 22:23:15 +0100268ifeq (no,$(DYNAMIC_PYTHON3))
269PYTHON3LIB=-L$(PYTHON3)/libs -lpython$(PYTHON3_VER)
270endif
271
272ifndef PYTHON3INC
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100273ifeq ($(CROSS),no)
274PYTHON3INC=-I $(PYTHON3)/include
275else
276PYTHON3INC=-I $(PYTHON3)/win32inc
277endif
278endif
Bram Moolenaara7c37952016-01-20 22:23:15 +0100279endif
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100280
281# TCL interface:
282# TCL=[Path to TCL directory] (Set inside Make_cyg.mak or Make_ming.mak)
283# DYNAMIC_TCL=yes (to load the TCL DLL dynamically)
284# TCL_VER=[TCL version, eg 83, 84] (default is 83)
Bram Moolenaareca99bd2016-01-07 22:50:05 +0100285# TCL_VER_LONG=[Tcl version, eg 8.3] (default is 8.3)
286# You must set TCL_VER_LONG when you set TCL_VER.
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100287ifdef TCL
288ifndef DYNAMIC_TCL
289DYNAMIC_TCL=yes
290endif
291ifndef TCL_VER
292TCL_VER = 83
293endif
Bram Moolenaareca99bd2016-01-07 22:50:05 +0100294ifndef TCL_VER_LONG
295TCL_VER_LONG = 8.3
296endif
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100297TCLINC += -I$(TCL)/include
298endif
299
300
301# Ruby interface:
302# RUBY=[Path to Ruby directory] (Set inside Make_cyg.mak or Make_ming.mak)
303# DYNAMIC_RUBY=yes (to load the Ruby DLL dynamically)
304# RUBY_VER=[Ruby version, eg 18, 19, 20] (default is 18)
305# RUBY_VER_LONG=[Ruby version, eg 1.8, 1.9.1, 2.0.0] (default is 1.8)
306# You must set RUBY_VER_LONG when changing RUBY_VER.
307# RUBY_API_VER is derived from RUBY_VER_LONG.
308# Note: If you use Ruby 1.9.3, set as follows:
309# RUBY_VER=19
310# RUBY_VER_LONG=1.9.1 (not 1.9.3, because the API version is 1.9.1.)
311ifdef RUBY
312ifndef DYNAMIC_RUBY
313DYNAMIC_RUBY=yes
314endif
315# Set default value
316ifndef RUBY_VER
317RUBY_VER = 18
318endif
319ifndef RUBY_VER_LONG
320RUBY_VER_LONG = 1.8
321endif
322ifndef RUBY_API_VER
323RUBY_API_VER = $(subst .,,$(RUBY_VER_LONG))
324endif
325
326ifndef RUBY_PLATFORM
327ifeq ($(RUBY_VER), 16)
328RUBY_PLATFORM = i586-mswin32
329else
330ifneq ($(wildcard $(RUBY)/lib/ruby/$(RUBY_VER_LONG)/i386-mingw32),)
331RUBY_PLATFORM = i386-mingw32
332else
333ifneq ($(wildcard $(RUBY)/lib/ruby/$(RUBY_VER_LONG)/x64-mingw32),)
334RUBY_PLATFORM = x64-mingw32
335else
336RUBY_PLATFORM = i386-mswin32
337endif
338endif
339endif
340endif
341
342ifndef RUBY_INSTALL_NAME
343ifeq ($(RUBY_VER), 16)
344RUBY_INSTALL_NAME = mswin32-ruby$(RUBY_API_VER)
345else
Bram Moolenaar0bee2fe2016-01-07 22:45:09 +0100346ifndef RUBY_MSVCRT_NAME
347# Base name of msvcrXX.dll which is used by ruby's dll.
348RUBY_MSVCRT_NAME = msvcrt
349endif
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100350ifeq ($(ARCH),x86-64)
Bram Moolenaar0bee2fe2016-01-07 22:45:09 +0100351RUBY_INSTALL_NAME = x64-$(RUBY_MSVCRT_NAME)-ruby$(RUBY_API_VER)
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100352else
Bram Moolenaar0bee2fe2016-01-07 22:45:09 +0100353RUBY_INSTALL_NAME = $(RUBY_MSVCRT_NAME)-ruby$(RUBY_API_VER)
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100354endif
355endif
356endif
357
358ifeq (19, $(word 1,$(sort 19 $(RUBY_VER))))
359RUBY_19_OR_LATER = 1
360endif
361
362RUBYINC = -I $(RUBY)/lib/ruby/$(RUBY_VER_LONG)/$(RUBY_PLATFORM)
363ifdef RUBY_19_OR_LATER
364RUBYINC += -I $(RUBY)/include/ruby-$(RUBY_VER_LONG) -I $(RUBY)/include/ruby-$(RUBY_VER_LONG)/$(RUBY_PLATFORM)
365endif
366ifeq (no, $(DYNAMIC_RUBY))
367RUBYLIB = -L$(RUBY)/lib -l$(RUBY_INSTALL_NAME)
368endif
369
370endif # RUBY
371
372# See feature.h for a list of options.
373# Any other defines can be included here.
374DEF_GUI=-DFEAT_GUI_W32 -DFEAT_CLIPBOARD
375DEFINES=-DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) \
376 -DHAVE_PATHDEF -DFEAT_$(FEATURES)
377ifeq ($(ARCH),x86-64)
378DEFINES+=-DMS_WIN64
379endif
380ifeq ($(CROSS),yes)
381# cross-compiler prefix:
382ifndef CROSS_COMPILE
383CROSS_COMPILE = i586-pc-mingw32msvc-
384endif
385DEL = rm
386MKDIR = mkdir -p
387DIRSLASH = /
388else
389# normal (Windows) compilation:
390ifndef CROSS_COMPILE
391CROSS_COMPILE =
392endif
393ifneq (sh.exe, $(SHELL))
394DEL = rm
395MKDIR = mkdir -p
396DIRSLASH = /
397else
398DEL = del
399MKDIR = mkdir
400DIRSLASH = \\
401endif
402endif
403CC := $(CROSS_COMPILE)gcc
404CXX := $(CROSS_COMPILE)g++
Bram Moolenaar2d78cd72014-12-13 20:50:09 +0100405ifeq ($(UNDER_CYGWIN),yes)
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100406WINDRES := $(CROSS_COMPILE)windres
Bram Moolenaar2d78cd72014-12-13 20:50:09 +0100407else
408WINDRES := windres
409endif
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100410WINDRES_CC = $(CC)
411
412#>>>>> end of choices
413###########################################################################
414
415CFLAGS = -Iproto $(DEFINES) -pipe -w -march=$(ARCH) -Wall
416WINDRES_FLAGS = --preprocessor="$(WINDRES_CC) -E -xc" -DRC_INVOKED
417EXTRA_LIBS =
418
419ifdef GETTEXT
420DEFINES += -DHAVE_GETTEXT -DHAVE_LOCALE_H
421GETTEXTINCLUDE = $(GETTEXT)/include
422GETTEXTLIB = $(INTLPATH)
423ifeq (yes, $(GETTEXT))
424DEFINES += -DDYNAMIC_GETTEXT
425else
426ifdef DYNAMIC_GETTEXT
427DEFINES += -D$(DYNAMIC_GETTEXT)
428ifdef GETTEXT_DYNAMIC
429DEFINES += -DGETTEXT_DYNAMIC -DGETTEXT_DLL=\"$(GETTEXT_DYNAMIC)\"
430endif
431endif
432endif
433endif
434
435ifdef PERL
Bram Moolenaar367fbf12015-06-25 16:13:46 +0200436CFLAGS += -I$(PERLLIBS) -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100437ifeq (yes, $(DYNAMIC_PERL))
438CFLAGS += -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl$(PERL_VER).dll\"
439EXTRA_LIBS += -L$(PERLLIBS) -lperl$(PERL_VER)
440endif
441endif
442
443ifdef LUA
444CFLAGS += -I$(LUA)/include -I$(LUA) -DFEAT_LUA
445ifeq (yes, $(DYNAMIC_LUA))
446CFLAGS += -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua$(LUA_VER).dll\"
447endif
448endif
449
450ifdef MZSCHEME
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100451ifndef MZSCHEME_COLLECTS
452MZSCHEME_COLLECTS=$(MZSCHEME)/collects
453ifeq (yes, $(UNDER_CYGWIN))
454MZSCHEME_COLLECTS:=$(shell cygpath -m $(MZSCHEME_COLLECTS) | sed -e 's/ /\\ /g')
455endif
456endif
457CFLAGS += -I$(MZSCHEME)/include -DFEAT_MZSCHEME -DMZSCHEME_COLLECTS=\"$(MZSCHEME_COLLECTS)\"
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100458ifeq (yes, $(DYNAMIC_MZSCHEME))
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100459ifeq (yes, $(MZSCHEME_PRECISE_GC))
460# Precise GC does not use separate dll
461CFLAGS += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\"
462else
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100463CFLAGS += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"lib$(MZSCHEME_MAIN_LIB)$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\"
464endif
Bram Moolenaar4e640bd2016-01-16 16:20:38 +0100465endif
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100466ifeq (yes, "$(MZSCHEME_DEBUG)")
467CFLAGS += -DMZSCHEME_FORCE_GC
468endif
469endif
470
471ifdef RUBY
472CFLAGS += -DFEAT_RUBY $(RUBYINC)
473ifeq (yes, $(DYNAMIC_RUBY))
474CFLAGS += -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"$(RUBY_INSTALL_NAME).dll\"
475CFLAGS += -DDYNAMIC_RUBY_VER=$(RUBY_VER)
476endif
477ifneq ($(findstring w64-mingw32,$(CC)),)
478# A workaround for MinGW-w64
479CFLAGS += -DHAVE_STRUCT_TIMESPEC -DHAVE_STRUCT_TIMEZONE
480endif
481endif
482
483ifdef PYTHON
484CFLAGS += -DFEAT_PYTHON
485ifeq (yes, $(DYNAMIC_PYTHON))
Bram Moolenaar449538c2016-01-09 17:49:15 +0100486CFLAGS += -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"$(DYNAMIC_PYTHON_DLL)\"
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100487endif
488endif
489
490ifdef PYTHON3
491CFLAGS += -DFEAT_PYTHON3
492ifeq (yes, $(DYNAMIC_PYTHON3))
Bram Moolenaara7c37952016-01-20 22:23:15 +0100493CFLAGS += -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"$(DYNAMIC_PYTHON3_DLL)\"
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100494endif
495endif
496
497ifdef TCL
498CFLAGS += -DFEAT_TCL $(TCLINC)
499ifeq (yes, $(DYNAMIC_TCL))
Bram Moolenaareca99bd2016-01-07 22:50:05 +0100500CFLAGS += -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl$(TCL_VER).dll\" -DDYNAMIC_TCL_VER=\"$(TCL_VER_LONG)\"
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100501endif
502endif
503
504ifeq ($(POSTSCRIPT),yes)
505DEFINES += -DMSWINPS
506endif
507
508ifeq (yes, $(OLE))
509DEFINES += -DFEAT_OLE
510endif
511
512ifeq ($(CSCOPE),yes)
513DEFINES += -DFEAT_CSCOPE
514endif
515
516ifeq ($(NETBEANS),yes)
517# Only allow NETBEANS for a GUI build.
518ifeq (yes, $(GUI))
519DEFINES += -DFEAT_NETBEANS_INTG
520
521ifeq ($(NBDEBUG), yes)
522DEFINES += -DNBDEBUG
523NBDEBUG_INCL = nbdebug.h
524NBDEBUG_SRC = nbdebug.c
525endif
526endif
527endif
528
529# DirectWrite (DirectX)
530ifeq ($(DIRECTX),yes)
531# Only allow DirectWrite for a GUI build.
532ifeq (yes, $(GUI))
533DEFINES += -DFEAT_DIRECTX -DDYNAMIC_DIRECTX
534endif
535endif
536
537# Only allow XPM for a GUI build.
538ifeq (yes, $(GUI))
539
540ifndef XPM
541ifeq ($(ARCH),i386)
542XPM = xpm/x86
543endif
544ifeq ($(ARCH),i486)
545XPM = xpm/x86
546endif
547ifeq ($(ARCH),i586)
548XPM = xpm/x86
549endif
550ifeq ($(ARCH),i686)
551XPM = xpm/x86
552endif
553ifeq ($(ARCH),x86-64)
554XPM = xpm/x64
555endif
556endif
557ifdef XPM
558ifneq ($(XPM),no)
559CFLAGS += -DFEAT_XPM_W32 -I $(XPM)/include -I $(XPM)/../include
560endif
561endif
562
563endif
564
565ifeq ($(DEBUG),yes)
566CFLAGS += -g -fstack-check
567DEBUG_SUFFIX=d
568else
569ifeq ($(OPTIMIZE), SIZE)
570CFLAGS += -Os
571else
572ifeq ($(OPTIMIZE), MAXSPEED)
573CFLAGS += -O3
574CFLAGS += -fomit-frame-pointer -freg-struct-return
575else # SPEED
576CFLAGS += -O2
577endif
578endif
579CFLAGS += -s
580endif
581
582LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lversion
583GUIOBJ = $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/gui_beval.o $(OUTDIR)/os_w32exe.o
584OBJ = \
585 $(OUTDIR)/blowfish.o \
586 $(OUTDIR)/buffer.o \
587 $(OUTDIR)/charset.o \
588 $(OUTDIR)/crypt.o \
589 $(OUTDIR)/crypt_zip.o \
590 $(OUTDIR)/diff.o \
591 $(OUTDIR)/digraph.o \
592 $(OUTDIR)/edit.o \
593 $(OUTDIR)/eval.o \
594 $(OUTDIR)/ex_cmds.o \
595 $(OUTDIR)/ex_cmds2.o \
596 $(OUTDIR)/ex_docmd.o \
597 $(OUTDIR)/ex_eval.o \
598 $(OUTDIR)/ex_getln.o \
599 $(OUTDIR)/fileio.o \
600 $(OUTDIR)/fold.o \
601 $(OUTDIR)/getchar.o \
602 $(OUTDIR)/hardcopy.o \
603 $(OUTDIR)/hashtab.o \
604 $(OUTDIR)/main.o \
605 $(OUTDIR)/mark.o \
606 $(OUTDIR)/memfile.o \
607 $(OUTDIR)/memline.o \
608 $(OUTDIR)/menu.o \
609 $(OUTDIR)/message.o \
610 $(OUTDIR)/misc1.o \
611 $(OUTDIR)/misc2.o \
612 $(OUTDIR)/move.o \
613 $(OUTDIR)/mbyte.o \
614 $(OUTDIR)/normal.o \
615 $(OUTDIR)/ops.o \
616 $(OUTDIR)/option.o \
617 $(OUTDIR)/os_win32.o \
618 $(OUTDIR)/os_mswin.o \
619 $(OUTDIR)/winclip.o \
620 $(OUTDIR)/pathdef.o \
621 $(OUTDIR)/popupmnu.o \
622 $(OUTDIR)/quickfix.o \
623 $(OUTDIR)/regexp.o \
624 $(OUTDIR)/screen.o \
625 $(OUTDIR)/search.o \
626 $(OUTDIR)/sha256.o \
627 $(OUTDIR)/spell.o \
628 $(OUTDIR)/syntax.o \
629 $(OUTDIR)/tag.o \
630 $(OUTDIR)/term.o \
631 $(OUTDIR)/ui.o \
632 $(OUTDIR)/undo.o \
633 $(OUTDIR)/version.o \
634 $(OUTDIR)/vimrc.o \
635 $(OUTDIR)/window.o
636
637ifdef PERL
638OBJ += $(OUTDIR)/if_perl.o
639endif
640ifdef LUA
641OBJ += $(OUTDIR)/if_lua.o
642endif
643ifdef MZSCHEME
644OBJ += $(OUTDIR)/if_mzsch.o
645MZSCHEME_INCL = if_mzsch.h
646ifeq (yes,$(MZSCHEME_GENERATE_BASE))
647CFLAGS += -DINCLUDE_MZSCHEME_BASE
648MZ_EXTRA_DEP += mzscheme_base.c
649endif
650ifeq (yes,$(MZSCHEME_PRECISE_GC))
651CFLAGS += -DMZ_PRECISE_GC
652endif
653endif
654ifdef PYTHON
655OBJ += $(OUTDIR)/if_python.o
656endif
657ifdef PYTHON3
658OBJ += $(OUTDIR)/if_python3.o
659endif
660ifdef RUBY
661OBJ += $(OUTDIR)/if_ruby.o
662endif
663ifdef TCL
664OBJ += $(OUTDIR)/if_tcl.o
665endif
666ifeq ($(CSCOPE),yes)
667OBJ += $(OUTDIR)/if_cscope.o
668endif
669ifeq ($(NETBEANS),yes)
670# Only allow NETBEANS for a GUI build.
671ifeq (yes, $(GUI))
672OBJ += $(OUTDIR)/netbeans.o
673LIB += -lwsock32
674endif
675endif
676ifeq ($(DIRECTX),yes)
677# Only allow DIRECTX for a GUI build.
678ifeq (yes, $(GUI))
679OBJ += $(OUTDIR)/gui_dwrite.o
680LIB += -ld2d1 -ldwrite
681USE_STDCPLUS = yes
682endif
683endif
684ifneq ($(XPM),no)
685# Only allow XPM for a GUI build.
686ifeq (yes, $(GUI))
687OBJ += $(OUTDIR)/xpm_w32.o
688# You'll need libXpm.a from http://gnuwin32.sf.net
689LIB += -L$(XPM)/lib -lXpm
690endif
691endif
692
693
694ifdef MZSCHEME
695MZSCHEME_SUFFIX = Z
696endif
697
698ifeq ($(GUI),yes)
699TARGET := gvim$(DEBUG_SUFFIX).exe
700DEFINES += $(DEF_GUI)
701OBJ += $(GUIOBJ)
702LFLAGS += -mwindows
703OUTDIR = gobj$(DEBUG_SUFFIX)$(MZSCHEME_SUFFIX)$(ARCH)
704else
705TARGET := vim$(DEBUG_SUFFIX).exe
706OUTDIR = obj$(DEBUG_SUFFIX)$(MZSCHEME_SUFFIX)$(ARCH)
707endif
708
709ifdef GETTEXT
710ifneq (yes, $(GETTEXT))
711CFLAGS += -I$(GETTEXTINCLUDE)
712ifndef STATIC_GETTEXT
713LIB += -L$(GETTEXTLIB) -l$(INTLLIB)
714ifeq (USE_SAFE_GETTEXT_DLL, $(DYNAMIC_GETTEXT))
715OBJ+=$(SAFE_GETTEXT_DLL_OBJ)
716endif
717else
718LIB += -L$(GETTEXTLIB) -lintl
719endif
720endif
721endif
722
723ifdef PERL
724ifeq (no, $(DYNAMIC_PERL))
725LIB += -L$(PERLLIBS) -lperl$(PERL_VER)
726endif
727endif
728
729ifdef TCL
730LIB += -L$(TCL)/lib
731ifeq (yes, $(DYNAMIC_TCL))
732LIB += -ltclstub$(TCL_VER)
733else
734LIB += -ltcl$(TCL_VER)
735endif
736endif
737
738ifeq (yes, $(OLE))
739LIB += -loleaut32
740OBJ += $(OUTDIR)/if_ole.o
741USE_STDCPLUS = yes
742endif
743
744ifeq (yes, $(MBYTE))
745DEFINES += -DFEAT_MBYTE
746endif
747
748ifeq (yes, $(IME))
749DEFINES += -DFEAT_MBYTE_IME
750ifeq (yes, $(DYNAMIC_IME))
751DEFINES += -DDYNAMIC_IME
752else
753LIB += -limm32
754endif
755endif
756
757ifdef ICONV
758ifneq (yes, $(ICONV))
759LIB += -L$(ICONV)
760CFLAGS += -I$(ICONV)
761endif
762DEFINES+=-DDYNAMIC_ICONV
763endif
764
765ifeq (yes, $(USE_STDCPLUS))
766ifeq (yes, $(STATIC_STDCPLUS))
767LIB += -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic
768else
769LIB += -lstdc++
770endif
771endif
772
773all: $(TARGET) vimrun.exe xxd/xxd.exe install.exe uninstal.exe GvimExt/gvimext.dll
774
775vimrun.exe: vimrun.c
776 $(CC) $(CFLAGS) -o vimrun.exe vimrun.c $(LIB)
777
778install.exe: dosinst.c
779 $(CC) $(CFLAGS) -o install.exe dosinst.c $(LIB) -lole32 -luuid
780
781uninstal.exe: uninstal.c
782 $(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIB)
783
784$(TARGET): $(OUTDIR) $(OBJ)
785 $(CC) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)
786
787upx: exes
788 upx gvim.exe
789 upx vim.exe
790
791mpress: exes
792 mpress gvim.exe
793 mpress vim.exe
794
795xxd/xxd.exe: xxd/xxd.c
796 $(MAKE) -C xxd -f Make_ming.mak CC='$(CC)'
797
798GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
799 $(MAKE) -C GvimExt -f Make_ming.mak CROSS=$(CROSS) CROSS_COMPILE=$(CROSS_COMPILE) CXX='$(CXX)' STATIC_STDCPLUS=$(STATIC_STDCPLUS)
800
801clean:
802 -$(DEL) $(OUTDIR)$(DIRSLASH)*.o
803 -$(DEL) $(OUTDIR)$(DIRSLASH)*.res
804 -rmdir $(OUTDIR)
805 -$(DEL) *.exe
806 -$(DEL) pathdef.c
807ifdef PERL
808 -$(DEL) if_perl.c
809endif
810ifdef MZSCHEME
811 -$(DEL) mzscheme_base.c
812endif
813 $(MAKE) -C GvimExt -f Make_ming.mak clean
814 $(MAKE) -C xxd -f Make_ming.mak clean
815
816###########################################################################
817INCL = vim.h feature.h os_win32.h os_dos.h ascii.h keymap.h term.h macros.h \
818 structs.h regexp.h option.h ex_cmds.h proto.h globals.h farsi.h \
819 gui.h
820
821$(OUTDIR)/if_python.o : if_python.c if_py_both.h $(INCL)
Bram Moolenaar449538c2016-01-09 17:49:15 +0100822 $(CC) -c $(CFLAGS) $(PYTHONINC) $(PYTHON_HOME_DEF) $< -o $@
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100823
824$(OUTDIR)/if_python3.o : if_python3.c if_py_both.h $(INCL)
Bram Moolenaara7c37952016-01-20 22:23:15 +0100825 $(CC) -c $(CFLAGS) $(PYTHON3INC) $(PYTHON3_HOME_DEF) $< -o $@
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100826
827$(OUTDIR)/%.o : %.c $(INCL)
828 $(CC) -c $(CFLAGS) $< -o $@
829
830$(OUTDIR)/vimrc.o: vim.rc version.h gui_w32_rc.h
831 $(WINDRES) $(WINDRES_FLAGS) $(DEFINES) \
832 --input-format=rc --output-format=coff -i vim.rc -o $@
833
834$(OUTDIR):
835 $(MKDIR) $(OUTDIR)
836
837$(OUTDIR)/ex_docmd.o: ex_docmd.c $(INCL) ex_cmds.h
838 $(CC) -c $(CFLAGS) ex_docmd.c -o $(OUTDIR)/ex_docmd.o
839
840$(OUTDIR)/ex_eval.o: ex_eval.c $(INCL) ex_cmds.h
841 $(CC) -c $(CFLAGS) ex_eval.c -o $(OUTDIR)/ex_eval.o
842
843$(OUTDIR)/gui_w32.o: gui_w32.c gui_w48.c $(INCL)
844 $(CC) -c $(CFLAGS) gui_w32.c -o $(OUTDIR)/gui_w32.o
845
846$(OUTDIR)/gui_dwrite.o: gui_dwrite.cpp $(INCL) gui_dwrite.h
847 $(CC) -c $(CFLAGS) gui_dwrite.cpp -o $(OUTDIR)/gui_dwrite.o
848
849$(OUTDIR)/if_cscope.o: if_cscope.c $(INCL) if_cscope.h
850 $(CC) -c $(CFLAGS) if_cscope.c -o $(OUTDIR)/if_cscope.o
851
852# Remove -D__IID_DEFINED__ for newer versions of the w32api
853$(OUTDIR)/if_ole.o: if_ole.cpp $(INCL)
854 $(CC) $(CFLAGS) -c -o $(OUTDIR)/if_ole.o if_ole.cpp
855
856$(OUTDIR)/if_ruby.o: if_ruby.c $(INCL)
857ifeq (16, $(RUBY))
858 $(CC) $(CFLAGS) -U_WIN32 -c -o $(OUTDIR)/if_ruby.o if_ruby.c
859endif
860
861if_perl.c: if_perl.xs typemap
862 $(XSUBPP) -prototypes -typemap \
Bram Moolenaar345326a2014-11-06 10:03:01 +0100863 $(PERLTYPEMAP) if_perl.xs > $@
Bram Moolenaar4f7e8212014-11-05 13:53:32 +0100864
865$(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
866 $(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
867
868$(OUTDIR)/regexp.o: regexp.c regexp_nfa.c $(INCL)
869 $(CC) -c $(CFLAGS) regexp.c -o $(OUTDIR)/regexp.o
870
871$(OUTDIR)/if_mzsch.o: if_mzsch.c $(INCL) if_mzsch.h $(MZ_EXTRA_DEP)
872 $(CC) -c $(CFLAGS) if_mzsch.c -o $(OUTDIR)/if_mzsch.o
873
874mzscheme_base.c:
875 $(MZSCHEME)/mzc --c-mods mzscheme_base.c ++lib scheme/base
876
877pathdef.c: $(INCL)
878ifneq (sh.exe, $(SHELL))
879 @echo creating pathdef.c
880 @echo '/* pathdef.c */' > pathdef.c
881 @echo '#include "vim.h"' >> pathdef.c
882 @echo 'char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)";' >> pathdef.c
883 @echo 'char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)";' >> pathdef.c
884 @echo 'char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)";' >> pathdef.c
885 @echo 'char_u *all_lflags = (char_u *)"$(CC) $(CFLAGS) $(LFLAGS) -o $(TARGET) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)";' >> pathdef.c
886 @echo 'char_u *compiled_user = (char_u *)"$(USERNAME)";' >> pathdef.c
887 @echo 'char_u *compiled_sys = (char_u *)"$(USERDOMAIN)";' >> pathdef.c
888else
889 @echo creating pathdef.c
890 @echo /* pathdef.c */ > pathdef.c
891 @echo #include "vim.h" >> pathdef.c
892 @echo char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)"; >> pathdef.c
893 @echo char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)"; >> pathdef.c
894 @echo char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)"; >> pathdef.c
895 @echo char_u *all_lflags = (char_u *)"$(CC) $(CFLAGS) $(LFLAGS) -o $(TARGET) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)"; >> pathdef.c
896 @echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> pathdef.c
897 @echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> pathdef.c
898endif