1# 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 <[email protected]> 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 <[email protected]> 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 <[email protected]>. 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) 290# Only allow NETBEANS for a GUI build. 291ifeq (yes, $(GUI)) 292DEFINES += -DFEAT_NETBEANS_INTG 293 294ifeq ($(NBDEBUG), yes) 295DEFINES += -DNBDEBUG 296NBDEBUG_INCL = nbdebug.h 297NBDEBUG_SRC = nbdebug.c 298endif 299endif 300endif 301 302ifdef XPM 303# Only allow XPM for a GUI build. 304ifeq (yes, $(GUI)) 305CFLAGS += -DFEAT_XPM_W32 -I $(XPM)/include 306endif 307endif 308 309ifeq ($(DEBUG),yes) 310CFLAGS += -g -fstack-check 311DEBUG_SUFFIX=d 312else 313ifeq ($(OPTIMIZE), SIZE) 314CFLAGS += -Os 315else 316ifeq ($(OPTIMIZE), MAXSPEED) 317CFLAGS += -O3 318CFLAGS += -fomit-frame-pointer -freg-struct-return -malign-double 319else # SPEED 320CFLAGS += -O2 321endif 322endif 323CFLAGS += -s 324endif 325 326LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 327GUIOBJ = $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/os_w32exe.o 328OBJ = \ 329 $(OUTDIR)/buffer.o \ 330 $(OUTDIR)/charset.o \ 331 $(OUTDIR)/diff.o \ 332 $(OUTDIR)/digraph.o \ 333 $(OUTDIR)/edit.o \ 334 $(OUTDIR)/eval.o \ 335 $(OUTDIR)/ex_cmds.o \ 336 $(OUTDIR)/ex_cmds2.o \ 337 $(OUTDIR)/ex_docmd.o \ 338 $(OUTDIR)/ex_eval.o \ 339 $(OUTDIR)/ex_getln.o \ 340 $(OUTDIR)/fileio.o \ 341 $(OUTDIR)/fold.o \ 342 $(OUTDIR)/getchar.o \ 343 $(OUTDIR)/main.o \ 344 $(OUTDIR)/mark.o \ 345 $(OUTDIR)/memfile.o \ 346 $(OUTDIR)/memline.o \ 347 $(OUTDIR)/menu.o \ 348 $(OUTDIR)/message.o \ 349 $(OUTDIR)/misc1.o \ 350 $(OUTDIR)/misc2.o \ 351 $(OUTDIR)/move.o \ 352 $(OUTDIR)/mbyte.o \ 353 $(OUTDIR)/normal.o \ 354 $(OUTDIR)/ops.o \ 355 $(OUTDIR)/option.o \ 356 $(OUTDIR)/os_win32.o \ 357 $(OUTDIR)/os_mswin.o \ 358 $(OUTDIR)/pathdef.o \ 359 $(OUTDIR)/quickfix.o \ 360 $(OUTDIR)/regexp.o \ 361 $(OUTDIR)/screen.o \ 362 $(OUTDIR)/search.o \ 363 $(OUTDIR)/syntax.o \ 364 $(OUTDIR)/tag.o \ 365 $(OUTDIR)/term.o \ 366 $(OUTDIR)/ui.o \ 367 $(OUTDIR)/undo.o \ 368 $(OUTDIR)/version.o \ 369 $(OUTDIR)/vimrc.o \ 370 $(OUTDIR)/window.o 371 372ifdef PERL 373OBJ += $(OUTDIR)/if_perl.o 374endif 375ifdef PYTHON 376OBJ += $(OUTDIR)/if_python.o 377endif 378ifdef RUBY 379OBJ += $(OUTDIR)/if_ruby.o 380endif 381ifdef TCL 382OBJ += $(OUTDIR)/if_tcl.o 383endif 384ifeq ($(CSCOPE),yes) 385OBJ += $(OUTDIR)/if_cscope.o 386endif 387ifeq ($(NETBEANS),yes) 388# Only allow NETBEANS for a GUI build. 389ifeq (yes, $(GUI)) 390OBJ += $(OUTDIR)/netbeans.o $(OUTDIR)/gui_beval.o 391LIB += -lwsock32 392endif 393endif 394ifdef XPM 395# Only allow XPM for a GUI build. 396ifeq (yes, $(GUI)) 397OBJ += $(OUTDIR)/xpm_w32.o 398# You'll need libXpm.a from http://gnuwin32.sf.net 399LIB += -L $(XPM)/lib -lXpm 400endif 401endif 402 403 404ifeq ($(GUI),yes) 405TARGET := gvim$(DEBUG_SUFFIX).exe 406DEFINES += $(DEF_GUI) 407OBJ += $(GUIOBJ) 408LFLAGS += -mwindows 409OUTDIR = gobj$(DEBUG_SUFFIX) 410else 411TARGET := vim$(DEBUG_SUFFIX).exe 412OUTDIR = obj$(DEBUG_SUFFIX) 413endif 414 415ifdef GETTEXT 416ifneq (yes, $(GETTEXT)) 417CFLAGS += -I$(GETTEXTINCLUDE) 418ifndef STATIC_GETTEXT 419LIB += -L$(GETTEXTLIB) -l$(INTLLIB) 420ifeq (USE_SAFE_GETTEXT_DLL, $(DYNAMIC_GETTEXT)) 421OBJ+=$(SAFE_GETTEXT_DLL_OBJ) 422endif 423else 424LIB += -L$(GETTEXTLIB) -lintl 425endif 426endif 427endif 428 429ifdef PERL 430ifeq (no, $(DYNAMIC_PERL)) 431LIB += -lperl$(PERL_VER) 432endif 433endif 434 435ifdef TCL 436LIB += -L$(TCL)/lib 437ifeq (yes, $(DYNAMIC_TCL)) 438LIB += -ltclstub$(TCL_VER) 439else 440LIB += -ltcl$(TCL_VER) 441endif 442endif 443 444ifeq (yes, $(OLE)) 445LIB += -loleaut32 -lstdc++ 446OBJ += $(OUTDIR)/if_ole.o 447endif 448 449ifeq (yes, $(MBYTE)) 450DEFINES += -DFEAT_MBYTE 451endif 452 453ifeq (yes, $(IME)) 454DEFINES += -DFEAT_MBYTE_IME 455ifeq (yes, $(DYNAMIC_IME)) 456DEFINES += -DDYNAMIC_IME 457else 458LIB += -limm32 459endif 460endif 461 462ifdef ICONV 463ifneq (yes, $(ICONV)) 464LIB += -L$(ICONV) 465CFLAGS += -I$(ICONV) 466endif 467DEFINES+=-DDYNAMIC_ICONV 468endif 469 470all: $(TARGET) vimrun.exe xxd/xxd.exe install.exe uninstal.exe GvimExt/gvimext.dll 471 472vimrun.exe: vimrun.c 473 $(CC) $(CFLAGS) -o vimrun.exe vimrun.c $(LIB) 474 475install.exe: dosinst.c 476 $(CC) $(CFLAGS) -o install.exe dosinst.c $(LIB) -lole32 -luuid 477 478uninstal.exe: uninstal.c 479 $(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIB) 480 481$(TARGET): $(OUTDIR) $(OBJ) 482 $(CC) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(PYTHONLIB) $(RUBYLIB) 483 484upx: exes 485 upx gvim.exe 486 upx vim.exe 487 488xxd/xxd.exe: xxd/xxd.c 489 $(MAKE) -C xxd -f Make_cyg.mak 490 491GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h 492 $(MAKE) -C GvimExt -f Make_ming.mak 493 494clean: 495 -$(DEL) $(OUTDIR)$(DIRSLASH)*.o 496 -$(DEL) $(OUTDIR)$(DIRSLASH)*.res 497 -rmdir $(OUTDIR) 498 -$(DEL) *.exe 499 -$(DEL) pathdef.c 500ifdef PERL 501 -$(DEL) if_perl.c 502endif 503 $(MAKE) -C GvimExt -f Make_ming.mak clean 504 $(MAKE) -C xxd -f Make_cyg.mak clean 505 506########################################################################### 507INCL = vim.h feature.h os_win32.h os_dos.h ascii.h keymap.h term.h macros.h \ 508 structs.h regexp.h option.h ex_cmds.h proto.h globals.h farsi.h \ 509 gui.h 510 511$(OUTDIR)/%.o : %.c $(INCL) 512 $(CC) -c $(CFLAGS) $< -o $@ 513 514$(OUTDIR)/vimres.res: vim.rc version.h gui_w32_rc.h 515 $(WINDRES) $(DEFINES) vim.rc $(OUTDIR)/vimres.res 516 517$(OUTDIR)/vimrc.o: $(OUTDIR)/vimres.res 518 $(WINDRES) $(OUTDIR)/vimres.res $(OUTDIR)/vimrc.o 519 520$(OUTDIR): 521 mkdir $(OUTDIR) 522 523$(OUTDIR)/ex_docmd.o: ex_docmd.c $(INCL) ex_cmds.h 524 $(CC) -c $(CFLAGS) ex_docmd.c -o $(OUTDIR)/ex_docmd.o 525 526$(OUTDIR)/ex_eval.o: ex_eval.c $(INCL) ex_cmds.h 527 $(CC) -c $(CFLAGS) ex_eval.c -o $(OUTDIR)/ex_eval.o 528 529$(OUTDIR)/if_cscope.o: if_cscope.c $(INCL) if_cscope.h 530 $(CC) -c $(CFLAGS) if_cscope.c -o $(OUTDIR)/if_cscope.o 531 532$(OUTDIR)/if_ole.o: if_ole.cpp $(INCL) 533 $(CC) $(CFLAGS) -D__IID_DEFINED__ -c -o $(OUTDIR)/if_ole.o if_ole.cpp 534 535$(OUTDIR)/if_ruby.o: if_ruby.c $(INCL) 536ifeq (16, $(RUBY)) 537 $(CC) $(CFLAGS) -U_WIN32 -c -o $(OUTDIR)/if_ruby.o if_ruby.c 538endif 539 540if_perl.c: if_perl.xs typemap 541 perl $(PERLLIB)/ExtUtils/xsubpp -prototypes -typemap \ 542 $(PERLLIB)/ExtUtils/typemap if_perl.xs > $@ 543 544$(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC) 545 $(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o 546 547pathdef.c: $(INCL) 548ifneq (sh.exe, $(SHELL)) 549 @echo creating pathdef.c 550 @echo '/* pathdef.c */' > pathdef.c 551 @echo '#include "vim.h"' >> pathdef.c 552 @echo 'char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)";' >> pathdef.c 553 @echo 'char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)";' >> pathdef.c 554 @echo 'char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)";' >> pathdef.c 555 @echo 'char_u *all_lflags = (char_u *)"$(CC) -s -o $(TARGET) $(LIB) -luuid -lole32 $(PYTHONLIB) $(RUBYLIB)";' >> pathdef.c 556 @echo 'char_u *compiled_user = (char_u *)"$(USERNAME)";' >> pathdef.c 557 @echo 'char_u *compiled_sys = (char_u *)"$(USERDOMAIN)";' >> pathdef.c 558else 559 @echo creating pathdef.c 560 @echo /* pathdef.c */ > pathdef.c 561 @echo #include "vim.h" >> pathdef.c 562 @echo char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)"; >> pathdef.c 563 @echo char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)"; >> pathdef.c 564 @echo char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)"; >> pathdef.c 565 @echo char_u *all_lflags = (char_u *)"$(CC) -s -o $(TARGET) $(LIB) -luuid -lole32 $(PYTHONLIB) $(RUBYLIB)"; >> pathdef.c 566 @echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> pathdef.c 567 @echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> pathdef.c 568endif 569