blob: 06780627bee56c6f06fc73c492ac7ed9f157abed [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001# Makefile for VIM on Win32, using 'EGCS/mingw32 1.1.2'.
2# Info at http://www.mingw.org
3# Also requires 'GNU make 3.77', which you can get through a link
4# to 'JanJaap's page from the above page.
5# Get missing libraries from http://gnuwin32.sf.net.
6#
7# Tested on Win32 NT 4 and Win95.
8#
9# To make everything, just 'make -f Make_ming.mak'
10# To make just e.g. gvim.exe, 'make -f Make_ming.mak gvim.exe'
11# After a run, you can 'make -f Make_ming.mak clean' to clean up
12#
13# NOTE: Sometimes 'GNU Make' will stop after building vimrun.exe -- I think
14# it's just run out of memory or something. Run again, and it will continue
15# with 'xxd'.
16#
17# "make upx" makes *compressed* versions of the GUI and console EXEs, using the
18# excellent UPX compressor:
19# http://upx.sourceforge.net/
20#
21# Maintained by Ron Aaron <ronaharon@yahoo.com>
22# updated 2003 Jan 20
23
24#>>>>> choose options:
25# set to yes for a debug build
26DEBUG=no
27# set to SIZE for size, SPEED for speed, MAXSPEED for maximium optimization
28OPTIMIZE=MAXSPEED
29# set to yes to make gvim, no for vim
30GUI=yes
31# FEATURES=[TINY | SMALL | NORMAL | BIG | HUGE]
32# set to TINY to make minimal version (few features)
33FEATURES=BIG
34# set to one of i386, i486, i586, i686 as the *target* processor
35CPUNR=i686
36# set to same choices as 'CPUNR', but will prevent running on 'lower' cpus:
37ARCH=i386
38# set to yes to cross-compile from unix; no=native Windows
39CROSS=no
40# set to path to iconv.h and libiconv.a to enable using 'iconv.dll'
41#ICONV="."
42ICONV=yes
43GETTEXT=yes
44# set to yes to include multibyte support
45MBYTE=yes
46# set to yes to include IME support
47IME=yes
48DYNAMIC_IME=yes
49# set to yes to enable writing a postscript file with :hardcopy
50POSTSCRIPT=no
51# set to yes to enable OLE support
52OLE=no
53# Set the default $(WINVER) to make it work with pre-Win2k
54WINVER = 0x0400
55# Set to yes to enable Cscope support
56CSCOPE=yes
57# Set to yes to enable Netbeans support
58NETBEANS=$(GUI)
59
60
61# If the user doesn't want gettext, undefine it.
62ifeq (no, $(GETTEXT))
63GETTEXT=
64endif
65# Added by E.F. Amatria <eferna1@platea.ptic.mec.es> 2001 Feb 23
66# Uncomment the first line and one of the following three if you want Native Language
67# Support. You'll need gnu_gettext.win32, a MINGW32 Windows PORT of gettext by
68# Franco Bez <franco.bez@gmx.de>. It may be found at
69# http://home.a-city.de/franco.bez/gettext/gettext_win32_en.html
70# Tested with mingw32 with GCC-2.95.2 on Win98
71# Updated 2001 Jun 9
72#GETTEXT=c:/gettext.win32.msvcrt
73#STATIC_GETTEXT=USE_STATIC_GETTEXT
74#DYNAMIC_GETTEXT=USE_GETTEXT_DLL
75#DYNAMIC_GETTEXT=USE_SAFE_GETTEXT_DLL
76SAFE_GETTEXT_DLL_OBJ = $(GETTEXT)/src/safe_gettext_dll/safe_gettext_dll.o
77# Alternatively, if you uncomment the two following lines, you get a "safe" version
78# without linking the safe_gettext_dll.o object file.
79#DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
80#GETTEXT_DYNAMIC=gnu_gettext.dll
81INTLPATH=$(GETTEXT)/lib/mingw32
82INTLLIB=gnu_gettext
83
84# If you are using gettext-0.10.35 from http://sourceforge.net/projects/gettext
85# or gettext-0.10.37 from http://sourceforge.net/projects/mingwrep/
86# uncomment the following, but I can't build a static versión with them, ?-(|
87#GETTEXT=c:/gettext-0.10.37-20010430
88#STATIC_GETTEXT=USE_STATIC_GETTEXT
89#DYNAMIC_GETTEXT=DYNAMIC_GETTEXT
90#INTLPATH=$(GETTEXT)/lib
91#INTLLIB=intl
92
93# uncomment 'PERL' if you want a perl-enabled version
94#PERL=C:/perl
95ifdef PERL
96ifndef PERL_VER
97PERL_VER=56
98endif
99ifndef DYNAMIC_PERL
100DYNAMIC_PERL=yes
101endif
102# on Linux, for cross-compile, it's here:
103#PERLLIB=/home/ron/ActivePerl/lib
104# on NT, it's here:
105PERLLIB=$(PERL)/lib
106PERLLIBS=$(PERLLIB)/Core
107endif
108
109# Python support -- works with the ActiveState python 2.0 release (and others
110# too, probably)
111#
112# uncomment 'PYTHON' to make python-enabled version
113# Put the path to the python distro here. If cross compiling from Linux, you
114# will also need to convert the header files to unix instead of dos format:
115# for fil in *.h ; do vim -e -c 'set ff=unix|w|q' $fil
116# and also, you will need to make a mingw32 'libpython20.a' to link with:
117# cd $PYTHON/libs
118# pexports python20.dll > python20.def
119# dlltool -d python20.def -l libpython20.a
120# on my Linux box, I put the Python stuff here:
121#PYTHON=/home/ron/ActivePython-2.0.0-202/src/Core
122# on my NT box, it's here:
123#PYTHON=c:/python20
124
125ifdef PYTHON
126ifndef DYNAMIC_PYTHON
127DYNAMIC_PYTHON=yes
128endif
129
130ifndef PYTHON_VER
131PYTHON_VER=22
132endif
133
134ifeq (no,$(DYNAMIC_PYTHON))
135PYTHONLIB=-L$(PYTHON)/libs -lpython$(PYTHON_VER)
136endif
137# my include files are in 'win32inc' on Linux, and 'include' in the standard
138# NT distro (ActiveState)
139ifeq ($(CROSS),no)
140PYTHONINC=-I $(PYTHON)/include
141else
142PYTHONINC=-I $(PYTHON)/win32inc
143endif
144endif
145
146# TCL interface:
147# TCL=[Path to TCL directory]
148# DYNAMIC_TCL=yes (to load the TCL DLL dynamically)
149# TCL_VER=[TCL version, eg 83, 84] (default is 83)
150#TCL=c:/tcl
151ifdef TCL
152ifndef DYNAMIC_TCL
153DYNAMIC_TCL=yes
154endif
155ifndef TCL_VER
156TCL_VER = 83
157endif
158TCLINC += -I$(TCL)/include
159endif
160
161
162# Ruby interface:
163# RUBY=[Path to Ruby directory]
164# DYNAMIC_RUBY=yes (to load the Ruby DLL dynamically)
165# RUBY_VER=[Ruby version, eg 16, 17] (default is 16)
166# RUBY_VER_LONG=[Ruby version, eg 1.6, 1.7] (default is 1.6)
167# You must set RUBY_VER_LONG when change RUBY_VER.
168#RUBY=c:/ruby
169ifdef RUBY
170ifndef DYNAMIC_RUBY
171DYNAMIC_RUBY=yes
172endif
173# Set default value
174ifndef RUBY_VER
175RUBY_VER = 16
176endif
177ifndef RUBY_VER_LONG
178RUBY_VER_LONG = 1.6
179endif
180
181ifeq ($(RUBY_VER), 16)
182ifndef RUBY_PLATFORM
183RUBY_PLATFORM = i586-mswin32
184endif
185ifndef RUBY_INSTALL_NAME
186RUBY_INSTALL_NAME = mswin32-ruby$(RUBY_VER)
187endif
188else
189ifndef RUBY_PLATFORM
190RUBY_PLATFORM = i386-mswin32
191endif
192ifndef RUBY_INSTALL_NAME
193RUBY_INSTALL_NAME = msvcrt-ruby$(RUBY_VER)
194endif
195endif
196
197RUBYINC =-I $(RUBY)/lib/ruby/$(RUBY_VER_LONG)/$(RUBY_PLATFORM)
198ifeq (no, $(DYNAMIC_RUBY))
199RUBYLIB = -L$(RUBY)/lib -l$(RUBY_INSTALL_NAME)
200endif
201
202endif # RUBY
203
204# See feature.h for a list of options.
205# Any other defines can be included here.
206DEF_GUI=-DFEAT_GUI_W32 -DFEAT_CLIPBOARD
207DEFINES=-DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) \
208 -DHAVE_PATHDEF -DFEAT_$(FEATURES)
209ifeq ($(CROSS),yes)
210# cross-compiler:
211CC = i586-pc-mingw32msvc-gcc
212DEL = rm
213WINDRES = i586-pc-mingw32msvc-windres
214else
215# normal (Windows) compilation:
216CC = gcc
217ifneq (sh.exe, $(SHELL))
218DEL = rm
219DIRSLASH = /
220else
221DEL = del
222DIRSLASH = \\
223endif
224WINDRES = windres
225endif
226
227#>>>>> end of choices
228###########################################################################
229
230CFLAGS = -Iproto $(DEFINES) -pipe -w -march=$(ARCH) -mcpu=$(CPUNR) -Wall
231
232ifdef GETTEXT
233DEFINES +=-DHAVE_GETTEXT -DHAVE_LOCALE_H
234GETTEXTINCLUDE = $(GETTEXT)/include
235GETTEXTLIB = $(INTLPATH)
236ifeq (yes, $(GETTEXT))
237DEFINES +=-DDYNAMIC_GETTEXT
238else
239ifdef DYNAMIC_GETTEXT
240DEFINES +=-D$(DYNAMIC_GETTEXT)
241ifdef GETTEXT_DYNAMIC
242DEFINES += -DGETTEXT_DYNAMIC -DGETTEXT_DLL=\"$(GETTEXT_DYNAMIC)\"
243endif
244endif
245endif
246endif
247
248ifdef PERL
249CFLAGS += -I$(PERLLIBS) -DFEAT_PERL -L$(PERLLIBS)
250ifeq (yes, $(DYNAMIC_PERL))
251CFLAGS += -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl$(PERL_VER).dll\"
252endif
253endif
254
255ifdef RUBY
256CFLAGS += -DFEAT_RUBY $(RUBYINC)
257ifeq (yes, $(DYNAMIC_RUBY))
258CFLAGS += -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"$(RUBY_INSTALL_NAME).dll\"
259CFLAGS += -DDYNAMIC_RUBY_VER=$(RUBY_VER)
260endif
261endif
262
263ifdef PYTHON
264CFLAGS += -DFEAT_PYTHON $(PYTHONINC)
265ifeq (yes, $(DYNAMIC_PYTHON))
266CFLAGS += -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python$(PYTHON_VER).dll\"
267endif
268endif
269
270ifdef TCL
271CFLAGS += -DFEAT_TCL $(TCLINC)
272ifeq (yes, $(DYNAMIC_TCL))
273CFLAGS += -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl$(TCL_VER).dll\"
274endif
275endif
276
277ifeq ($(POSTSCRIPT),yes)
278DEFINES += -DMSWINPS
279endif
280
281ifeq (yes, $(OLE))
282DEFINES += -DFEAT_OLE
283endif
284
285ifeq ($(CSCOPE),yes)
286DEFINES += -DFEAT_CSCOPE
287endif
288
289ifeq ($(NETBEANS),yes)
290DEFINES += -DFEAT_NETBEANS_INTG
291ifeq ($(DEBUG), yes)
292DEFINES += -DNBDEBUG
293NBDEBUG_INCL = nbdebug.h
294NBDEBUG_SRC = nbdebug.c
295endif
296endif
297
298ifdef XPM
299CFLAGS += -DFEAT_XPM_W32 -I $(XPM)/include
300endif
301
302ifeq ($(DEBUG),yes)
303CFLAGS += -g -fstack-check
304DEBUG_SUFFIX=d
305else
306ifeq ($(OPTIMIZE), SIZE)
307CFLAGS += -Os
308else
309ifeq ($(OPTIMIZE), MAXSPEED)
310CFLAGS += -O3
311CFLAGS += -fomit-frame-pointer -freg-struct-return -malign-double
312else # SPEED
313CFLAGS += -O2
314endif
315endif
316CFLAGS += -s
317endif
318
319LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32
320GUIOBJ = $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/os_w32exe.o
321OBJ = \
322 $(OUTDIR)/buffer.o \
323 $(OUTDIR)/charset.o \
324 $(OUTDIR)/diff.o \
325 $(OUTDIR)/digraph.o \
326 $(OUTDIR)/edit.o \
327 $(OUTDIR)/eval.o \
328 $(OUTDIR)/ex_cmds.o \
329 $(OUTDIR)/ex_cmds2.o \
330 $(OUTDIR)/ex_docmd.o \
331 $(OUTDIR)/ex_eval.o \
332 $(OUTDIR)/ex_getln.o \
333 $(OUTDIR)/fileio.o \
334 $(OUTDIR)/fold.o \
335 $(OUTDIR)/getchar.o \
336 $(OUTDIR)/main.o \
337 $(OUTDIR)/mark.o \
338 $(OUTDIR)/memfile.o \
339 $(OUTDIR)/memline.o \
340 $(OUTDIR)/menu.o \
341 $(OUTDIR)/message.o \
342 $(OUTDIR)/misc1.o \
343 $(OUTDIR)/misc2.o \
344 $(OUTDIR)/move.o \
345 $(OUTDIR)/mbyte.o \
346 $(OUTDIR)/normal.o \
347 $(OUTDIR)/ops.o \
348 $(OUTDIR)/option.o \
349 $(OUTDIR)/os_win32.o \
350 $(OUTDIR)/os_mswin.o \
351 $(OUTDIR)/pathdef.o \
352 $(OUTDIR)/quickfix.o \
353 $(OUTDIR)/regexp.o \
354 $(OUTDIR)/screen.o \
355 $(OUTDIR)/search.o \
356 $(OUTDIR)/syntax.o \
357 $(OUTDIR)/tag.o \
358 $(OUTDIR)/term.o \
359 $(OUTDIR)/ui.o \
360 $(OUTDIR)/undo.o \
361 $(OUTDIR)/version.o \
362 $(OUTDIR)/vimrc.o \
363 $(OUTDIR)/window.o
364
365ifdef PERL
366OBJ += $(OUTDIR)/if_perl.o
367endif
368ifdef PYTHON
369OBJ += $(OUTDIR)/if_python.o
370endif
371ifdef RUBY
372OBJ += $(OUTDIR)/if_ruby.o
373endif
374ifdef TCL
375OBJ += $(OUTDIR)/if_tcl.o
376endif
377ifeq ($(CSCOPE),yes)
378OBJ += $(OUTDIR)/if_cscope.o
379endif
380ifeq ($(NETBEANS),yes)
381OBJ += $(OUTDIR)/netbeans.o $(OUTDIR)/gui_beval.o
382LIB += -lwsock32
383endif
384ifdef XPM
385OBJ += $(OUTDIR)/xpm_w32.o
386# You'll need libXpm.a from http://gnuwin32.sf.net
387LIB += -L $(XPM)/lib -lXpm
388endif
389
390
391ifeq ($(GUI),yes)
392TARGET := gvim$(DEBUG_SUFFIX).exe
393DEFINES += $(DEF_GUI)
394OBJ += $(GUIOBJ)
395LFLAGS += -mwindows
396OUTDIR = gobj$(DEBUG_SUFFIX)
397else
398TARGET := vim$(DEBUG_SUFFIX).exe
399OUTDIR = obj$(DEBUG_SUFFIX)
400endif
401
402ifdef GETTEXT
403ifneq (yes, $(GETTEXT))
404CFLAGS += -I$(GETTEXTINCLUDE)
405ifndef STATIC_GETTEXT
406LIB += -L$(GETTEXTLIB) -l$(INTLLIB)
407ifeq (USE_SAFE_GETTEXT_DLL, $(DYNAMIC_GETTEXT))
408OBJ+=$(SAFE_GETTEXT_DLL_OBJ)
409endif
410else
411LIB += -L$(GETTEXTLIB) -lintl
412endif
413endif
414endif
415
416ifdef PERL
417ifeq (no, $(DYNAMIC_PERL))
418LIB += -lperl$(PERL_VER)
419endif
420endif
421
422ifdef TCL
423LIB += -L$(TCL)/lib
424ifeq (yes, $(DYNAMIC_TCL))
425LIB += -ltclstub$(TCL_VER)
426else
427LIB += -ltcl$(TCL_VER)
428endif
429endif
430
431ifeq (yes, $(OLE))
432LIB += -loleaut32 -lstdc++
433OBJ += $(OUTDIR)/if_ole.o
434endif
435
436ifeq (yes, $(MBYTE))
437DEFINES += -DFEAT_MBYTE
438endif
439
440ifeq (yes, $(IME))
441DEFINES += -DFEAT_MBYTE_IME
442ifeq (yes, $(DYNAMIC_IME))
443DEFINES += -DDYNAMIC_IME
444else
445LIB += -limm32
446endif
447endif
448
449ifdef ICONV
450ifneq (yes, $(ICONV))
451LIB += -L$(ICONV)
452CFLAGS += -I$(ICONV)
453endif
454DEFINES+=-DDYNAMIC_ICONV
455endif
456
457all: $(TARGET) vimrun.exe xxd/xxd.exe install.exe uninstal.exe GvimExt/gvimext.dll
458
459vimrun.exe: vimrun.c
460 $(CC) $(CFLAGS) -o vimrun.exe vimrun.c $(LIB)
461
462install.exe: dosinst.c
463 $(CC) $(CFLAGS) -o install.exe dosinst.c $(LIB) -lole32 -luuid
464
465uninstal.exe: uninstal.c
466 $(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIB)
467
468$(TARGET): $(OUTDIR) $(OBJ)
469 $(CC) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(PYTHONLIB) $(RUBYLIB)
470
471upx: exes
472 upx gvim.exe
473 upx vim.exe
474
475xxd/xxd.exe: xxd/xxd.c
476 $(MAKE) -C xxd -f Make_cyg.mak
477
478GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
479 $(MAKE) -C GvimExt -f Make_ming.mak
480
481clean:
482 -$(DEL) $(OUTDIR)$(DIRSLASH)*.o
483 -$(DEL) $(OUTDIR)$(DIRSLASH)*.res
484 -rmdir $(OUTDIR)
485 -$(DEL) *.exe
486 -$(DEL) pathdef.c
487ifdef PERL
488 -$(DEL) if_perl.c
489endif
490 $(MAKE) -C GvimExt -f Make_ming.mak clean
491 $(MAKE) -C xxd -f Make_cyg.mak clean
492
493###########################################################################
494INCL = vim.h feature.h os_win32.h os_dos.h ascii.h keymap.h term.h macros.h \
495 structs.h regexp.h option.h ex_cmds.h proto.h globals.h farsi.h \
496 gui.h
497
498$(OUTDIR)/%.o : %.c $(INCL)
499 $(CC) -c $(CFLAGS) $< -o $@
500
501$(OUTDIR)/vimres.res: vim.rc version.h gui_w32_rc.h
502 $(WINDRES) $(DEFINES) vim.rc $(OUTDIR)/vimres.res
503
504$(OUTDIR)/vimrc.o: $(OUTDIR)/vimres.res
505 $(WINDRES) $(OUTDIR)/vimres.res $(OUTDIR)/vimrc.o
506
507$(OUTDIR):
508 mkdir $(OUTDIR)
509
510$(OUTDIR)/ex_docmd.o: ex_docmd.c $(INCL) ex_cmds.h
511 $(CC) -c $(CFLAGS) ex_docmd.c -o $(OUTDIR)/ex_docmd.o
512
513$(OUTDIR)/ex_eval.o: ex_eval.c $(INCL) ex_cmds.h
514 $(CC) -c $(CFLAGS) ex_eval.c -o $(OUTDIR)/ex_eval.o
515
516$(OUTDIR)/if_cscope.o: if_cscope.c $(INCL) if_cscope.h
517 $(CC) -c $(CFLAGS) if_cscope.c -o $(OUTDIR)/if_cscope.o
518
519$(OUTDIR)/if_ole.o: if_ole.cpp $(INCL)
520 $(CC) $(CFLAGS) -D__IID_DEFINED__ -c -o $(OUTDIR)/if_ole.o if_ole.cpp
521
522$(OUTDIR)/if_ruby.o: if_ruby.c $(INCL)
523ifeq (16, $(RUBY))
524 $(CC) $(CFLAGS) -U_WIN32 -c -o $(OUTDIR)/if_ruby.o if_ruby.c
525endif
526
527if_perl.c: if_perl.xs typemap
528 perl $(PERLLIB)/ExtUtils/xsubpp -prototypes -typemap \
529 $(PERLLIB)/ExtUtils/typemap if_perl.xs > $@
530
531$(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
532 $(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
533
534pathdef.c: $(INCL)
535ifneq (sh.exe, $(SHELL))
536 @echo creating pathdef.c
537 @echo '/* pathdef.c */' > pathdef.c
538 @echo '#include "vim.h"' >> pathdef.c
539 @echo 'char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)";' >> pathdef.c
540 @echo 'char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)";' >> pathdef.c
541 @echo 'char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)";' >> pathdef.c
542 @echo 'char_u *all_lflags = (char_u *)"$(CC) -s -o $(TARGET) $(LIB) -luuid -lole32 $(PYTHONLIB) $(RUBYLIB)";' >> pathdef.c
543 @echo 'char_u *compiled_user = (char_u *)"$(USERNAME)";' >> pathdef.c
544 @echo 'char_u *compiled_sys = (char_u *)"$(USERDOMAIN)";' >> pathdef.c
545else
546 @echo creating pathdef.c
547 @echo /* pathdef.c */ > pathdef.c
548 @echo #include "vim.h" >> pathdef.c
549 @echo char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)"; >> pathdef.c
550 @echo char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)"; >> pathdef.c
551 @echo char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)"; >> pathdef.c
552 @echo char_u *all_lflags = (char_u *)"$(CC) -s -o $(TARGET) $(LIB) -luuid -lole32 $(PYTHONLIB) $(RUBYLIB)"; >> pathdef.c
553 @echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> pathdef.c
554 @echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> pathdef.c
555endif