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