blob: e58e3d14c5722cbbb338b3c6ce59e2d74a966f4a [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001#
2# Makefile for VIM on Win32, using Cygnus gcc
3# Last updated by Dan Sharp. Last Change: 2004 Apr 23
4#
5# This compiles Vim as a Windows application. If you want Vim to run as a
6# Cygwin application use the Makefile (just like on Unix).
7#
8# GUI no or yes: set to yes if you want the GUI version (yes)
9# PERL define to path to Perl dir to get Perl support (not defined)
10# PERL_VER define to version of Perl being used (56)
11# DYNAMIC_PERL no or yes: set to yes to load the Perl DLL dynamically (yes)
12# PYTHON define to path to Python dir to get PYTHON support (not defined)
13# PYTHON_VER define to version of Python being used (22)
14# DYNAMIC_PYTHON no or yes: use yes to load the Python DLL dynamically (yes)
15# TCL define to path to TCL dir to get TCL support (not defined)
16# TCL_VER define to version of TCL being used (83)
17# DYNAMIC_TCL no or yes: use yes to load the TCL DLL dynamically (yes)
18# RUBY define to path to Ruby dir to get Ruby support (not defined)
19# RUBY_VER define to version of Ruby being used (16)
20# DYNAMIC_RUBY no or yes: use yes to load the Ruby DLL dynamically (yes)
21# GETTEXT no or yes: set to yes for dynamic gettext support (yes)
22# ICONV no or yes: set to yes for dynamic iconv support (yes)
23# MBYTE no or yes: set to yes to include multibyte support (yes)
24# IME no or yes: set to yes to include IME support (yes)
25# DYNAMIC_IME no or yes: set to yes to load imm32.dll dynamically (yes)
26# OLE no or yes: set to yes to make OLE gvim (no)
27# DEBUG no or yes: set to yes if you wish a DEBUGging build (no)
28# CPUNR i386 through pentium4: select -mcpu argument to compile with (i386)
29# ARCH i386 through pentium4: select -march argument to compile with (i386)
30# USEDLL no or yes: set to yes to use the Runtime library DLL (no)
31# For USEDLL=yes the cygwin1.dll is required to run Vim.
32# POSTSCRIPT no or yes: set to yes for PostScript printing (no)
33# FEATURES TINY, SMALL, NORMAL, BIG or HUGE (BIG)
34# WINVER Lowest Win32 version to support. (0x0400)
35# CSCOPE no or yes: to include cscope interface support (yes)
36# OPTIMIZE SPACE, SPEED, or MAXSPEED: set optimization level (MAXSPEED)
37# NETBEANS no or yes: to include netbeans interface support (yes when GUI
38# is yes)
39# XPM define to path to XPM dir to get XPM image support (not defined)
40#>>>>> choose options:
41ifndef GUI
42GUI=yes
43endif
44
45ifndef FEATURES
46FEATURES = BIG
47endif
48
49ifndef GETTEXT
50GETTEXT = yes
51endif
52
53ifndef ICONV
54ICONV = yes
55endif
56
57ifndef MBYTE
58MBYTE = yes
59endif
60
61ifndef IME
62IME = yes
63endif
64
65ifndef CPUNR
66CPUNR = i386
67endif
68
69ifndef ARCH
70ARCH = i386
71endif
72
73ifndef WINVER
74WINVER = 0x0400
75endif
76
77ifndef CSCOPE
78CSCOPE = yes
79endif
80
81ifndef NETBEANS
82ifeq ($(GUI),yes)
83NETBEANS = yes
84endif
85endif
86
87ifndef OPTIMIZE
88OPTIMIZE = MAXSPEED
89endif
90
91### See feature.h for a list of optionals.
92### Any other defines can be included here.
93
94DEFINES = -DWIN32 -DHAVE_PATHDEF -DFEAT_$(FEATURES) \
95 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER)
96INCLUDES = -mcpu=$(CPUNR) -march=$(ARCH) -Iproto
97
98#>>>>> name of the compiler and linker, name of lib directory
99CC = gcc
100RC = windres
101
102##############################
103# DYNAMIC_PERL=yes and no both work
104##############################
105ifdef PERL
106DEFINES += -DFEAT_PERL
107INCLUDES += -I$(PERL)/lib/CORE
108EXTRA_OBJS += $(OUTDIR)/if_perl.o
109
110ifndef DYNAMIC_PERL
111DYNAMIC_PERL = yes
112endif
113
114ifndef PERL_VER
115PERL_VER = 56
116endif
117
118ifeq (yes, $(DYNAMIC_PERL))
119DEFINES += -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl$(PERL_VER).dll\"
120else
121EXTRA_LIBS += $(PERL)/lib/CORE/perl$(PERL_VER).lib
122endif
123endif
124
125##############################
126# DYNAMIC_PYTHON=yes works.
127# DYNAMIC_PYTHON=no does not (unresolved externals on link).
128##############################
129ifdef PYTHON
130DEFINES += -DFEAT_PYTHON
131INCLUDES += -I$(PYTHON)/include
132EXTRA_OBJS += $(OUTDIR)/if_python.o
133
134ifndef DYNAMIC_PYTHON
135DYNAMIC_PYTHON = yes
136endif
137
138ifndef PYTHON_VER
139PYTHON_VER = 22
140endif
141
142ifeq (yes, $(DYNAMIC_PYTHON))
143DEFINES += -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python$(PYTHON_VER).dll\"
144else
145EXTRA_LIBS += $(PYTHON)/libs/python$(PYTHON_VER).lib
146endif
147endif
148
149##############################
150# DYNAMIC_RUBY=yes works.
151# DYNAMIC_RUBY=no does not (process exits).
152##############################
153ifdef RUBY
154
155ifndef RUBY_VER
156RUBY_VER=16
157endif
158
159ifndef RUBY_VER_LONG
160RUBY_VER_LONG=1.6
161endif
162
163ifndef DYNAMIC_RUBY
164DYNAMIC_RUBY = yes
165endif
166
167ifeq ($(RUBY_VER), 16)
168ifndef RUBY_PLATFORM
169RUBY_PLATFORM = i586-mswin32
170endif
171ifndef RUBY_INSTALL_NAME
172RUBY_INSTALL_NAME = mswin32-ruby$(RUBY_VER)
173endif
174else
175ifndef RUBY_PLATFORM
176RUBY_PLATFORM = i386-mswin32
177endif
178ifndef RUBY_INSTALL_NAME
179RUBY_INSTALL_NAME = msvcrt-ruby$(RUBY_VER)
180endif
181endif
182
183DEFINES += -DFEAT_RUBY
184INCLUDES += -I$(RUBY)/lib/ruby/$(RUBY_VER_LONG)/$(RUBY_PLATFORM)
185EXTRA_OBJS += $(OUTDIR)/if_ruby.o
186
187ifeq (yes, $(DYNAMIC_RUBY))
188DEFINES += -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"$(RUBY_INSTALL_NAME).dll\"
189DEFINES += -DDYNAMIC_RUBY_VER=$(RUBY_VER)
190else
191EXTRA_LIBS += $(RUBY)/lib/$(RUBY_INSTALL_NAME).lib
192endif
193endif
194
195##############################
196# DYNAMIC_TCL=yes and no both work.
197##############################
198ifdef TCL
199DEFINES += -DFEAT_TCL
200INCLUDES += -I$(TCL)/include
201EXTRA_OBJS += $(OUTDIR)/if_tcl.o
202
203ifndef DYNAMIC_TCL
204DYNAMIC_TCL = yes
205endif
206
207ifndef TCL_VER
208TCL_VER = 83
209endif
210
211ifeq (yes, $(DYNAMIC_TCL))
212DEFINES += -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl$(TCL_VER).dll\"
213EXTRA_LIBS += $(TCL)/lib/tclstub$(TCL_VER).lib
214else
215EXTRA_LIBS += $(TCL)/lib/tcl$(TCL_VER).lib
216endif
217endif
218
219##############################
220ifeq (yes, $(GETTEXT))
221DEFINES += -DDYNAMIC_GETTEXT
222endif
223
224##############################
225ifeq (yes, $(ICONV))
226DEFINES += -DDYNAMIC_ICONV
227endif
228
229##############################
230ifeq (yes, $(MBYTE))
231DEFINES += -DFEAT_MBYTE
232endif
233
234##############################
235ifeq (yes, $(IME))
236DEFINES += -DFEAT_MBYTE_IME
237
238ifndef DYNAMIC_IME
239DYNAMIC_IME = yes
240endif
241
242ifeq (yes, $(DYNAMIC_IME))
243DEFINES += -DDYNAMIC_IME
244else
245EXTRA_LIBS += -limm32
246endif
247endif
248
249##############################
250ifeq (yes, $(DEBUG))
251DEFINES += -DDEBUG
252INCLUDES += -g -fstack-check
253DEBUG_SUFFIX = d
254else
255
256ifeq ($(OPTIMIZE), SIZE)
257OPTFLAG = -Os
258else
259ifeq ($(OPTIMIZE), MAXSPEED)
260OPTFLAG = -O3 -fomit-frame-pointer -freg-struct-return -malign-double
261else
262OPTFLAG = -O2
263endif
264endif
265
266# A bug in the GCC <= 3.2 optimizer can cause a crash. The
267# following option removes the problem optimization.
268OPTFLAG += -fno-strength-reduce
269
270INCLUDES += -s
271
272endif
273
274##############################
275# USEDLL=yes will build a Cygwin32 executable that relies on cygwin1.dll.
276# USEDLL=no will build a Mingw32 executable with no extra dll dependencies.
277##############################
278ifeq (yes, $(USEDLL))
279DEFINES += -D_MAX_PATH=256 -D__CYGWIN__
280else
281INCLUDES += -mno-cygwin
282endif
283
284##############################
285ifeq (yes, $(POSTSCRIPT))
286DEFINES += -DMSWINPS
287endif
288
289##############################
290ifeq (yes, $(CSCOPE))
291DEFINES += -DFEAT_CSCOPE
292EXTRA_OBJS += $(OUTDIR)/if_cscope.o
293endif
294
295##############################
296ifeq (yes, $(NETBEANS))
297DEFINES += -DFEAT_NETBEANS_INTG
298EXTRA_OBJS += $(OUTDIR)/netbeans.o $(OUTDIR)/gui_beval.o
299EXTRA_LIBS += -lwsock32
300
301ifeq (yes, $(DEBUG))
302DEFINES += -DNBDEBUG
303NBDEBUG_DEP = nbdebug.h nbdebug.c
304endif
305
306endif
307
308##############################
309ifdef XPM
310DEFINES += -DFEAT_XPM_W32
311INCLUDES += -I$(XPM)/include
312EXTRA_OBJS += $(OUTDIR)/xpm_w32.o
313EXTRA_LIBS += -L$(XPM)/lib -lXpm
314endif
315
316##############################
317ifeq (yes, $(OLE))
318DEFINES += -DFEAT_OLE
319EXTRA_OBJS += $(OUTDIR)/if_ole.o
320EXTRA_LIBS += -loleaut32 -lstdc++
321endif
322
323##############################
324ifeq ($(GUI),yes)
325EXE = gvim$(DEBUG_SUFFIX).exe
326OUTDIR = gobj$(DEBUG_SUFFIX)
327DEFINES += -DFEAT_GUI_W32 -DFEAT_CLIPBOARD
328EXTRA_OBJS += $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/os_w32exe.o
329EXTRA_LIBS += -mwindows -lcomctl32
330else
331EXE = vim$(DEBUG_SUFFIX).exe
332OUTDIR = obj$(DEBUG_SUFFIX)
333LIBS += -luser32 -lgdi32 -lcomdlg32
334endif
335
336##############################
337ifneq (sh.exe, $(SHELL))
338DEL = rm
339DIRSLASH = /
340else
341DEL = del
342DIRSLASH = \\
343endif
344
345#>>>>> end of choices
346###########################################################################
347
348INCL = vim.h globals.h option.h keymap.h macros.h ascii.h term.h os_win32.h \
349 structs.h version.h
350
351CFLAGS = $(OPTFLAG) $(DEFINES) $(INCLUDES)
352
353RCFLAGS = -O coff $(DEFINES)
354
355OBJ = \
356 $(OUTDIR)/buffer.o \
357 $(OUTDIR)/charset.o \
358 $(OUTDIR)/diff.o \
359 $(OUTDIR)/digraph.o \
360 $(OUTDIR)/edit.o \
361 $(OUTDIR)/eval.o \
362 $(OUTDIR)/ex_cmds.o \
363 $(OUTDIR)/ex_cmds2.o \
364 $(OUTDIR)/ex_docmd.o \
365 $(OUTDIR)/ex_eval.o \
366 $(OUTDIR)/ex_getln.o \
367 $(OUTDIR)/fileio.o \
368 $(OUTDIR)/fold.o \
369 $(OUTDIR)/getchar.o \
370 $(OUTDIR)/main.o \
371 $(OUTDIR)/mark.o \
372 $(OUTDIR)/memfile.o \
373 $(OUTDIR)/memline.o \
374 $(OUTDIR)/menu.o \
375 $(OUTDIR)/message.o \
376 $(OUTDIR)/misc1.o \
377 $(OUTDIR)/misc2.o \
378 $(OUTDIR)/move.o \
379 $(OUTDIR)/mbyte.o \
380 $(OUTDIR)/normal.o \
381 $(OUTDIR)/ops.o \
382 $(OUTDIR)/option.o \
383 $(OUTDIR)/os_win32.o \
384 $(OUTDIR)/os_mswin.o \
385 $(OUTDIR)/pathdef.o \
386 $(OUTDIR)/quickfix.o \
387 $(OUTDIR)/regexp.o \
388 $(OUTDIR)/screen.o \
389 $(OUTDIR)/search.o \
390 $(OUTDIR)/syntax.o \
391 $(OUTDIR)/tag.o \
392 $(OUTDIR)/term.o \
393 $(OUTDIR)/ui.o \
394 $(OUTDIR)/undo.o \
395 $(OUTDIR)/version.o \
396 $(OUTDIR)/vimrc.o \
397 $(OUTDIR)/window.o \
398 $(EXTRA_OBJS)
399
400all: $(EXE) xxd/xxd.exe vimrun.exe install.exe uninstal.exe GvimExt/gvimext.dll
401
402# According to the Cygwin doc 1.2 FAQ, kernel32 should not be specified for
403# linking unless calling ld directly.
404# See /usr/doc/cygwin-doc-1.2/html/faq_toc.html#TOC93 for more information.
405$(EXE): $(OUTDIR) $(OBJ)
406 $(CC) $(CFLAGS) -o $(EXE) $(OBJ) $(LIBS) -luuid -lole32 $(EXTRA_LIBS)
407
408xxd/xxd.exe: xxd/xxd.c
409 $(MAKE) -C xxd -f Make_cyg.mak USEDLL=$(USEDLL)
410
411GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
412 $(MAKE) -C GvimExt -f Make_ming.mak
413
414vimrun.exe: vimrun.c
415 $(CC) $(CFLAGS) -o vimrun.exe vimrun.c $(LIBS)
416
417install.exe: dosinst.c
418 $(CC) $(CFLAGS) -o install.exe dosinst.c $(LIBS) -luuid -lole32
419
420uninstal.exe: uninstal.c
421 $(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIBS)
422
423$(OUTDIR):
424 mkdir $(OUTDIR)
425
426tags:
427 command /c ctags *.c $(INCL)
428
429clean:
430 -$(DEL) $(OUTDIR)$(DIRSLASH)*.o
431 -rmdir $(OUTDIR)
432 -$(DEL) *.exe
433ifdef PERL
434 -$(DEL) if_perl.c
435endif
436 -$(DEL) pathdef.c
437 $(MAKE) -C xxd -f Make_cyg.mak clean
438 $(MAKE) -C GvimExt -f Make_ming.mak clean
439
440###########################################################################
441
442$(OUTDIR)/%.o : %.c $(INCL)
443 $(CC) -c $(CFLAGS) $< -o $@
444
445$(OUTDIR)/ex_docmd.o: ex_docmd.c $(INCL) ex_cmds.h
446 $(CC) -c $(CFLAGS) ex_docmd.c -o $(OUTDIR)/ex_docmd.o
447
448$(OUTDIR)/ex_eval.o: ex_eval.c $(INCL) ex_cmds.h
449 $(CC) -c $(CFLAGS) ex_eval.c -o $(OUTDIR)/ex_eval.o
450
451$(OUTDIR)/if_cscope.o: if_cscope.c $(INCL) if_cscope.h
452 $(CC) -c $(CFLAGS) if_cscope.c -o $(OUTDIR)/if_cscope.o
453
454$(OUTDIR)/if_ole.o: if_ole.cpp $(INCL)
455 $(CC) -c $(CFLAGS) -D__IID_DEFINED__ if_ole.cpp -o $(OUTDIR)/if_ole.o
456
457if_perl.c: if_perl.xs typemap
458 perl $(PERL)/lib/ExtUtils/xsubpp -prototypes -typemap \
459 $(PERL)/lib/ExtUtils/typemap if_perl.xs > $@
460
461$(OUTDIR)/if_perl.o: if_perl.c $(INCL)
462ifeq (yes, $(USEDLL))
463 $(CC) -c $(CFLAGS) -I/usr/include/mingw -D__MINGW32__ if_perl.c -o $(OUTDIR)/if_perl.o
464endif
465
466$(OUTDIR)/if_ruby.o: if_ruby.c $(INCL)
467ifeq (16, $(RUBY_VER))
468 $(CC) -c $(CFLAGS) -U_WIN32 if_ruby.c -o $(OUTDIR)/if_ruby.o
469endif
470
471$(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_DEP)
472 $(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
473
474$(OUTDIR)/vimrc.o: vim.rc version.h gui_w32_rc.h
475 $(RC) $(RCFLAGS) vim.rc -o $(OUTDIR)/vimrc.o
476
477pathdef.c: $(INCL)
478ifneq (sh.exe, $(SHELL))
479 @echo creating pathdef.c
480 @echo '/* pathdef.c */' > pathdef.c
481 @echo '#include "vim.h"' >> pathdef.c
482 @echo 'char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)";' >> pathdef.c
483 @echo 'char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)";' >> pathdef.c
484 @echo 'char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)";' >> pathdef.c
485 @echo 'char_u *all_lflags = (char_u *)"$(CC) -s -o $(EXE) $(LIBS) -luuid -lole32 $(EXTRA_LIBS)";' >> pathdef.c
486 @echo 'char_u *compiled_user = (char_u *)"$(USERNAME)";' >> pathdef.c
487 @echo 'char_u *compiled_sys = (char_u *)"$(USERDOMAIN)";' >> pathdef.c
488else
489 @echo creating pathdef.c
490 @echo /* pathdef.c */ > pathdef.c
491 @echo #include "vim.h" >> pathdef.c
492 @echo char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)"; >> pathdef.c
493 @echo char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)"; >> pathdef.c
494 @echo char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)"; >> pathdef.c
495 @echo char_u *all_lflags = (char_u *)"$(CC) -s -o $(EXE) $(LIBS) -luuid -lole32 $(EXTRA_LIBS)"; >> pathdef.c
496 @echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> pathdef.c
497 @echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> pathdef.c
498endif