summaryrefslogtreecommitdiff
path: root/src/Make_bc5.mak
blob: 8dcb6e8b4cf6714f4eaf1a2a6f48f42eb3a0aff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
#
# Makefile for Vim.
# Compiler: Borland C++ 5.0 and later 32-bit compiler
#  Targets: Dos16 or Win32 (Windows NT and Windows 95) (with/without GUI)
#
# NOTE: THIS IS OLD AND PROBABLY NO LONGER WORKS.
#
# Contributed by Ben Singer.
# Updated 4/1997 by Ron Aaron
#	6/1997 - added support for 16 bit DOS
#	Note: this has been tested, and works, for BC5.  Your mileage may vary.
#	Has been reported NOT to work with BC 4.52.  Maybe it can be fixed?
#	10/1997 - ron - fixed bugs w/ BC 5.02
#	8/1998 - ron - updated with new targets, fixed some stuff
#	3/2000 - Bram: Made it work with BC 5.5 free command line compiler,
#			cleaned up variables.
#	6/2001 - Dan - Added support for compiling Python and TCL
#	7/2001 - Dan - Added support for compiling Ruby
#
# It builds on Windows 95 and NT-Intel, producing the same binary in either
# case.  To build using Microsoft Visual C++, use Make_mvc.mak.
#
# This should work with the free Borland command line compiler, version 5.5.
# You need at least sp1 (service pack 1).  With sp2 it compiles faster.
# Use a command like this:
# <path>\bin\make /f Make_bc5.mak BOR=<path>
#

# let the make utility do the hard work:
.AUTODEPEND
.CACHEAUTODEPEND

# VARIABLES:
# name		value (default)
#
# BOR		path to root of Borland C install (c:\bc5)
# LINK		name of the linker ($(BOR)\bin\ilink if OSTYPE is DOS16,
#		$(BOR)\bin\ilink32 otherwise)
# GUI		no or yes: set to yes if you want the GUI version (yes)
# LUA     define to path to Lua dir to get Lua support (not defined)
#   LUA_VER	  define to version of Lua being used (51)
#   DYNAMIC_LUA  no or yes: set to yes to load the Lua DLL dynamically (no)
# PERL		define to path to Perl dir to get Perl support (not defined)
#   PERL_VER	  define to version of Perl being used (56)
#   DYNAMIC_PERL  no or yes: set to yes to load the Perl DLL dynamically (no)
# PYTHON	define to path to Python dir to get PYTHON support (not defined)
#   PYTHON_VER	    define to version of Python being used (22)
#   DYNAMIC_PYTHON  no or yes: use yes to load the Python DLL dynamically (no)
# PYTHON3	define to path to Python3 dir to get PYTHON3 support (not defined)
#   PYTHON3_VER	    define to version of Python3 being used (31)
#   DYNAMIC_PYTHON3  no or yes: use yes to load the Python3 DLL dynamically (no)
# TCL		define to path to TCL dir to get TCL support (not defined)
#   TCL_VER	define to version of TCL being used (83)
#   DYNAMIC_TCL no or yes: use yes to load the TCL DLL dynamically (no)
# RUBY		define to path to Ruby dir to get Ruby support (not defined)
#		NOTE: You may have to remove the defines for uid_t and gid_t
#		from the Ruby config.h header file.
#   RUBY_VER	define to version of Ruby being used (16)
#		NOTE: compilation on WinNT/2K/XP requires
#		at least version 1.6.5 of Ruby.  Earlier versions
#		of Ruby will cause a compile error on these systems.
#   RUBY_VER_LONG  same, but in format with dot. (1.6)
#   DYNAMIC_RUBY no or yes: use yes to load the Ruby DLL dynamically (no)
# MBYTE		no or yes: set to yes for multi-byte support (yes)
#		NOTE: multi-byte support is broken in the Borland libraries,
#		not everything will work properly!  Esp. handling multi-byte
#		file names.
# IME		no or yes: set to yes for multi-byte IME support (yes)
#   DYNAMIC_IME no or yes: set to yes to load imm32.dll dynamically (yes)
# GETTEXT	no or yes: set to yes for multi-language support (yes)
# ICONV		no or yes: set to yes for dynamic iconv support (yes)
# OLE		no or yes: set to yes to make OLE gvim (no)
# OSTYPE	DOS16 or WIN32 (WIN32)
# DEBUG		no or yes: set to yes if you wish a DEBUGging build (no)
# CODEGUARD	no or yes: set to yes if you want to use CODEGUARD (no)
# CPUNR		1 through 6: select -CPU argument to compile with (3)
#		3 for 386, 4 for 486, 5 for pentium, 6 for pentium pro.
# USEDLL	no or yes: set to yes to use the Runtime library DLL (no)
#		For USEDLL=yes the cc3250.dll is required to run Vim.
# VIMDLL	no or yes: create vim32.dll, and stub (g)vim.exe (no)
# ALIGN		1, 2 or 4: Alignment to use (4 for Win32, 2 for DOS16)
# FASTCALL	no or yes: set to yes to use register-based function protocol (yes)
# OPTIMIZE	SPACE, SPEED, or MAXSPEED: type of optimization (MAXSPEED)
# POSTSCRIPT	no or yes: set to yes for PostScript printing
# FEATURES	TINY, SMALL, NORMAL, BIG or HUGE
#		(BIG for WIN32, SMALL for DOS16)
# WINVER	0x0400 or 0x0500: minimum Win32 version to support (0x0400)
# CSCOPE	no or yes: include support for Cscope interface (yes)
# NETBEANS	no or yes: include support for Netbeans interface (yes if GUI
#		is yes)
# NBDEBUG	no or yes: include support for debugging Netbeans interface (no)
# XPM		define to path to XPM dir to get support for loading XPM images.

### BOR: root of the BC installation
!if ("$(BOR)"=="")
BOR = c:\bc5
!endif

### LINK: Name of the linker: tlink or ilink32 (this is below, depends on
# $(OSTYPE)

### GUI: yes for GUI version, no for console version
!if ("$(GUI)"=="")
GUI = yes
!endif

### MBYTE: yes for multibyte support, no to disable it.
!if ("$(MBYTE)"=="")
MBYTE = yes
!endif

### IME: yes for multibyte support, no to disable it.
!if ("$(IME)"=="")
IME = yes
!endif
!if ("$(DYNAMIC_IME)"=="")
DYNAMIC_IME = yes
!endif

### GETTEXT: yes for multilanguage support, no to disable it.
!if ("$(GETTEXT)"=="")
GETTEXT = yes
!endif

### ICONV: yes to enable dynamic-iconv support, no to disable it
!if ("$(ICONV)"=="")
ICONV = yes
!endif

### CSCOPE: yes to enable Cscope support, no to disable it
!if ("$(CSCOPE)"=="")
CSCOPE = yes
!endif

### NETBEANS: yes to enable NetBeans interface support, no to disable it
!if ("$(NETBEANS)"=="") && ("$(GUI)"=="yes")
NETBEANS = yes
!endif

### LUA: uncomment this line if you want lua support in vim
# LUA=c:\lua

### PERL: uncomment this line if you want perl support in vim
# PERL=c:\perl

### PYTHON: uncomment this line if you want python support in vim
# PYTHON=c:\python22

### PYTHON3: uncomment this line if you want python3 support in vim
# PYTHON3=c:\python31

### RUBY: uncomment this line if you want ruby support in vim
# RUBY=c:\ruby

### TCL: uncomment this line if you want tcl support in vim
# TCL=c:\tcl

### OLE: no for normal gvim, yes for OLE-capable gvim (only works with GUI)
#OLE = yes

### OSTYPE: DOS16 for Windows 3.1 version, WIN32 for Windows 95/98/NT/2000
#   version
!if ("$(OSTYPE)"=="")
OSTYPE = WIN32
!endif

### DEBUG: Uncomment to make an executable for debugging
# DEBUG = yes
!if ("$(DEBUG)"=="yes")
DEBUG_FLAG = -v
!endif

### CODEGUARD: Uncomment to use the CODEGUARD stuff (BC 5.0 or later):
# CODEGUARD = yes
!if ("$(CODEGUARD)"=="yes")
CODEGUARD_FLAG = -vG
!endif

### CPUNR: set your target processor (3 to 6)
!if ("$(CPUNR)" == "i386") || ("$(CPUNR)" == "3")
CPUNR = 3
!elif ("$(CPUNR)" == "i486") || ("$(CPUNR)" == "4")
CPUNR = 4
!elif ("$(CPUNR)" == "i586") || ("$(CPUNR)" == "5")
CPUNR = 5
!elif ("$(CPUNR)" == "i686") || ("$(CPUNR)" == "6")
CPUNR = 6
!else
CPUNR = 3
!endif

### Comment out to use precompiled headers (faster, but uses lots of disk!)
HEADERS = -H -H=vim.csm -Hc

### USEDLL: no for statically linked version of run-time, yes for DLL runtime
!if ("$(USEDLL)"=="")
USEDLL = no
!endif

### VIMDLL: yes for a DLL version of VIM (NOT RECOMMENDED), no otherwise
#VIMDLL = yes

### ALIGN: alignment you desire: (1,2 or 4: s/b 4 for Win32, 2 for DOS)
!if ("$(ALIGN)"=="")
!if ($(OSTYPE)==DOS16)
ALIGN = 2
!else
ALIGN = 4
!endif
!endif

### FASTCALL: yes to use FASTCALL calling convention (RECOMMENDED!), no otherwise
#   Incompatible when calling external functions (like MSVC-compiled DLLs), so
#   don't use FASTCALL when linking with external libs.
!if ("$(FASTCALL)"=="") && \
	("$(LUA)"=="") && \
	("$(PYTHON)"=="") && \
	("$(PYTHON3)"=="") && \
	("$(PERL)"=="") && \
	("$(TCL)"=="") && \
	("$(RUBY)"=="") && \
	("$(ICONV)"!="yes") && \
	("$(IME)"!="yes") && \
	("$(MBYTE)"!="yes") && \
	("$(XPM)"=="")
FASTCALL = yes
!endif

### OPTIMIZE: SPEED to optimize for speed, SPACE otherwise (SPEED RECOMMENDED)
!if ("$(OPTIMIZE)"=="")
OPTIMIZE = MAXSPEED
!endif

### FEATURES: TINY, SMALL, NORMAL, BIG or HUGE (BIG for WIN32, SMALL for DOS16)
!if ("$(FEATURES)"=="")
! if ($(OSTYPE)==DOS16)
FEATURES = SMALL
! else
FEATURES = BIG
! endif
!endif

### POSTSCRIPT: uncomment this line if you want PostScript printing
#POSTSCRIPT = yes

###
# If you have a fixed directory for $VIM or $VIMRUNTIME, other than the normal
# default, use these lines.
#VIMRCLOC = somewhere
#VIMRUNTIMEDIR = somewhere

### Set the default $(WINVER) to make it work with Bcc 5.5.
!ifndef WINVER
WINVER = 0x0400
!endif

#
# Sanity checks for the above options:
#

!if ($(OSTYPE)==DOS16)
!if (($(CPUNR)+0)>4)
!error CPUNR Must be less than or equal to 4 for DOS16
!endif

!if (($(ALIGN)+0)>2)
!error ALIGN Must be less than or equal to 2 for DOS16
!endif

!else	# not DOS16
!if (($(CPUNR)+0)<3)
!error CPUNR Must be greater or equal to 3 for WIN32
!endif
!endif

!if ($(OSTYPE)!=WIN32) && ($(OSTYPE)!=DOS16)
!error Check the OSTYPE variable again: $(OSTYPE) is not supported!
!endif

#
# Optimizations: change as desired (RECOMMENDATION: Don't change!):
#
!if ("$(DEBUG)"=="yes")
OPT = -Od -N
!else
!if ("$(OPTIMIZE)"=="SPACE")
OPT = -O1 -f- -d
!elif ("$(OPTIMIZE)"=="MAXSPEED")
OPT = -O2 -f- -d -Ocavi -O
!else
OPT = -O2 -f- -d -Oc -O
!endif
!if ("$(FASTCALL)"=="yes")
OPT = $(OPT) -pr
!endif
!if ("$(CODEGUARD)"!="yes")
OPT = $(OPT) -vi-
!endif
!endif
!if ($(OSTYPE)==DOS16)
!undef GUI
!undef VIMDLL
!undef USEDLL
!endif
# shouldn't have to change:
LIB = $(BOR)\lib
INCLUDE = $(BOR)\include;.;proto
DEFINES = -DFEAT_$(FEATURES) -DWIN32 -DHAVE_PATHDEF \
	  -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER)

!ifdef LUA
INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_LUA
INCLUDE = $(LUA)\include;$(INCLUDE)
!  ifndef LUA_VER
LUA_VER = 51
!  endif
!  if ("$(DYNAMIC_LUA)" == "yes")
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua$(LUA_VER).dll\"
LUA_LIB_FLAG = /nodefaultlib:
!  endif
!endif

!ifdef PERL
INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_PERL
INCLUDE = $(PERL)\lib\core;$(INCLUDE)
!  ifndef PERL_VER
PERL_VER = 56
!  endif
!  if ("$(DYNAMIC_PERL)" == "yes")
!    if ($(PERL_VER) > 55)
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl$(PERL_VER).dll\"
PERL_LIB_FLAG = /nodefaultlib:
!    else
!      message "Cannot dynamically load Perl versions less than 5.6.  Loading statically..."
!    endif
!  endif
!endif

!ifdef PYTHON
!ifdef PYTHON3
DYNAMIC_PYTHON=yes
DYNAMIC_PYTHON3=yes
!endif
!endif

!ifdef PYTHON
INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_PYTHON
!ifndef PYTHON_VER
PYTHON_VER = 22
!endif
!if "$(DYNAMIC_PYTHON)" == "yes"
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python$(PYTHON_VER).dll\"
PYTHON_LIB_FLAG = /nodefaultlib:
!endif
!endif

!ifdef PYTHON3
INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_PYTHON3
!ifndef PYTHON3_VER
PYTHON3_VER = 31
!endif
!if "$(DYNAMIC_PYTHON3)" == "yes"
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python$(PYTHON3_VER).dll\"
PYTHON3_LIB_FLAG = /nodefaultlib:
!endif
!endif


!ifdef RUBY
!ifndef RUBY_VER
RUBY_VER = 16
!endif
!ifndef RUBY_VER_LONG
RUBY_VER_LONG = 1.6
!endif

!if "$(RUBY_VER)" == "16"
!ifndef RUBY_PLATFORM
RUBY_PLATFORM = i586-mswin32
!endif
!ifndef RUBY_INSTALL_NAME
RUBY_INSTALL_NAME = mswin32-ruby$(RUBY_VER)
!endif
!else
!ifndef RUBY_PLATFORM
RUBY_PLATFORM = i386-mswin32
!endif
!ifndef RUBY_INSTALL_NAME
RUBY_INSTALL_NAME = msvcrt-ruby$(RUBY_VER)
!endif
!endif

INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_RUBY
INCLUDE = $(RUBY)\lib\ruby\$(RUBY_VER_LONG)\$(RUBY_PLATFORM);$(INCLUDE)

!if "$(DYNAMIC_RUBY)" == "yes"
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"$(RUBY_INSTALL_NAME).dll\"
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_RUBY_VER=$(RUBY_VER)
RUBY_LIB_FLAG = /nodefaultlib:
!endif
!endif

!ifdef TCL
INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_TCL
INCLUDE = $(TCL)\include;$(INCLUDE)
!ifndef TCL_VER
TCL_VER = 83
!endif
TCL_LIB = $(TCL)\lib\tcl$(TCL_VER).lib
TCL_LIB_FLAG =
!if "$(DYNAMIC_TCL)" == "yes"
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl$(TCL_VER).dll\"
TCL_LIB = tclstub$(TCL_VER)-bor.lib
TCL_LIB_FLAG =
!endif
!endif
#
# DO NOT change below:
#
CPUARG = -$(CPUNR)
ALIGNARG = -a$(ALIGN)
#
!if ("$(DEBUG)"=="yes")
DEFINES=$(DEFINES) -DDEBUG -D_DEBUG
!endif
#
!if ("$(OLE)"=="yes")
DEFINES = $(DEFINES) -DFEAT_OLE
!endif
#
!if ("$(MBYTE)"=="yes")
MBDEFINES = $(MBDEFINES) -DFEAT_MBYTE
!endif
!if ("$(IME)"=="yes")
MBDEFINES = $(MBDEFINES) -DFEAT_MBYTE_IME
!if ("$(DYNAMIC_IME)" == "yes")
MBDEFINES = $(MBDEFINES) -DDYNAMIC_IME
!endif
!endif
!if ("$(ICONV)"=="yes")
MBDEFINES = $(MBDEFINES) -DDYNAMIC_ICONV
!endif
!if ("$(GETTEXT)"=="yes")
MBDEFINES = $(MBDEFINES) -DDYNAMIC_GETTEXT
!endif

!if ("$(CSCOPE)"=="yes")
DEFINES = $(DEFINES) -DFEAT_CSCOPE
!endif

!if ("$(GUI)"=="yes")
DEFINES = $(DEFINES) -DFEAT_GUI_W32 -DFEAT_CLIPBOARD
!if ("$(DEBUG)"=="yes")
TARGET = gvimd.exe
!else
TARGET = gvim.exe
!endif
!if ("$(VIMDLL)"=="yes")
EXETYPE=-WD
DEFINES = $(DEFINES) -DVIMDLL
!else
EXETYPE=-W
!endif
STARTUPOBJ = c0w32.obj
LINK2 = -aa
RESFILE = vim.res
!else
!undef NETBEANS
!undef XPM
!undef VIMDLL
!if ("$(DEBUG)"=="yes")
TARGET = vimd.exe
!else
# for now, anyway: VIMDLL is only for the GUI version
TARGET = vim.exe
!endif
!if ($(OSTYPE)==DOS16)
DEFINES= -DFEAT_$(FEATURES) -DMSDOS
EXETYPE=-ml
STARTUPOBJ = c0l.obj
LINK2 =
!else
EXETYPE=-WC
STARTUPOBJ = c0x32.obj
LINK2 = -ap -OS -o -P
!endif
RESFILE = vim.res
!endif

!if ("$(NETBEANS)"=="yes")
DEFINES = $(DEFINES) -DFEAT_NETBEANS_INTG
!if ("$(NBDEBUG)"=="yes")
DEFINES = $(DEFINES) -DNBDEBUG
NBDEBUG_DEP = nbdebug.h nbdebug.c
!endif
!endif

!ifdef XPM
!if ("$(GUI)"=="yes")
DEFINES = $(DEFINES) -DFEAT_XPM_W32
INCLUDE = $(XPM)\include;$(INCLUDE)
!endif
!endif

!if ("$(USEDLL)"=="yes")
DEFINES = $(DEFINES) -D_RTLDLL
!endif

!if ("$(DEBUG)"=="yes")
OBJDIR	= $(OSTYPE)\objdbg
!else
!if ("$(GUI)"=="yes")
!if ("$(OLE)"=="yes")
OBJDIR	= $(OSTYPE)\oleobj
!else
OBJDIR	= $(OSTYPE)\gobj
!endif
!else
OBJDIR	= $(OSTYPE)\obj
!endif
!endif

!if ("$(POSTSCRIPT)"=="yes")
DEFINES = $(DEFINES) -DMSWINPS
!endif

##### BASE COMPILER/TOOLS RULES #####
MAKE = $(BOR)\bin\make
CFLAGS = -w-aus -w-par -w-pch -w-ngu -w-csu -I$(INCLUDE)
!if ($(OSTYPE)==DOS16)
BRC =
!if ("$(LINK)"=="")
LINK	= $(BOR)\BIN\TLink
!endif
CC   = $(BOR)\BIN\Bcc
LFLAGS	= -Tde -c -m -L$(LIB) $(DEBUG_FLAG) $(LINK2)
LFLAGSDLL  =
CFLAGS = $(CFLAGS) -H- $(HEADERS)
!else
BRC = $(BOR)\BIN\brc32
!if ("$(LINK)"=="")
LINK	= $(BOR)\BIN\ILink32
!endif
CC   = $(BOR)\BIN\Bcc32
LFLAGS	= -OS -Tpe -c -m -L$(LIB) $(DEBUG_FLAG) $(LINK2)
LFLAGSDLL  = -Tpd -c -m -L$(LIB) $(DEBUG_FLAG) $(LINK2)
CFLAGS = $(CFLAGS) -d -RT- -k- -Oi $(HEADERS) -f-
!endif

CC1 = -c
CC2 = -o
CCARG = +$(OBJDIR)\bcc.cfg

# implicit rules:

# Without the following, the implicit rule in BUILTINS.MAK is picked up
# for a rule for .c.obj rather than the local implicit rule
.SUFFIXES
.SUFFIXES .c .obj
.path.c = .

{.}.c{$(OBJDIR)}.obj:
	$(CC) $(CCARG) $(CC1) -n$(OBJDIR)\ {$< }

.cpp.obj:
	$(CC) $(CCARG) $(CC1) $(CC2)$@ $*.cpp

!if ($(OSTYPE)==DOS16)
!else # win32:
vimmain = \
	$(OBJDIR)\os_w32exe.obj
!if ("$(VIMDLL)"=="yes")
vimwinmain = \
	$(OBJDIR)\os_w32dll.obj
!else
vimwinmain = \
	$(OBJDIR)\os_w32exe.obj
!endif
!endif

vimobj =  \
	$(OBJDIR)\blowfish.obj \
	$(OBJDIR)\buffer.obj \
	$(OBJDIR)\charset.obj \
	$(OBJDIR)\crypt.obj \
	$(OBJDIR)\crypt_zip.obj \
	$(OBJDIR)\diff.obj \
	$(OBJDIR)\digraph.obj \
	$(OBJDIR)\edit.obj \
	$(OBJDIR)\eval.obj \
	$(OBJDIR)\ex_cmds.obj \
	$(OBJDIR)\ex_cmds2.obj \
	$(OBJDIR)\ex_docmd.obj \
	$(OBJDIR)\ex_eval.obj \
	$(OBJDIR)\ex_getln.obj \
	$(OBJDIR)\fileio.obj \
	$(OBJDIR)\fold.obj \
	$(OBJDIR)\getchar.obj \
	$(OBJDIR)\hardcopy.obj \
	$(OBJDIR)\hashtab.obj \
	$(OBJDIR)\json.obj \
	$(OBJDIR)\main.obj \
	$(OBJDIR)\mark.obj \
	$(OBJDIR)\memfile.obj \
	$(OBJDIR)\memline.obj \
	$(OBJDIR)\menu.obj \
	$(OBJDIR)\message.obj \
	$(OBJDIR)\misc1.obj \
	$(OBJDIR)\misc2.obj \
	$(OBJDIR)\move.obj \
	$(OBJDIR)\mbyte.obj \
	$(OBJDIR)\normal.obj \
	$(OBJDIR)\ops.obj \
	$(OBJDIR)\option.obj \
	$(OBJDIR)\popupmnu.obj \
	$(OBJDIR)\quickfix.obj \
	$(OBJDIR)\regexp.obj \
	$(OBJDIR)\screen.obj \
	$(OBJDIR)\search.obj \
	$(OBJDIR)\sha256.obj \
	$(OBJDIR)\spell.obj \
	$(OBJDIR)\syntax.obj \
	$(OBJDIR)\tag.obj \
	$(OBJDIR)\term.obj \
	$(OBJDIR)\ui.obj \
	$(OBJDIR)\undo.obj \
	$(OBJDIR)\version.obj \
	$(OBJDIR)\window.obj \
	$(OBJDIR)\pathdef.obj

!if ("$(OLE)"=="yes")
vimobj = $(vimobj) \
	$(OBJDIR)\if_ole.obj
!endif

!ifdef LUA
vimobj = $(vimobj) \
    $(OBJDIR)\if_lua.obj
!endif

!ifdef PERL
vimobj = $(vimobj) \
    $(OBJDIR)\if_perl.obj
!endif

!ifdef PYTHON
vimobj = $(vimobj) \
    $(OBJDIR)\if_python.obj
!endif

!ifdef PYTHON3
vimobj = $(vimobj) \
    $(OBJDIR)\if_python3.obj
!endif

!ifdef RUBY
vimobj = $(vimobj) \
    $(OBJDIR)\if_ruby.obj
!endif

!ifdef TCL
vimobj = $(vimobj) \
    $(OBJDIR)\if_tcl.obj
!endif

!if ("$(CSCOPE)"=="yes")
vimobj = $(vimobj) \
    $(OBJDIR)\if_cscope.obj
!endif

!if ("$(NETBEANS)"=="yes")
vimobj = $(vimobj) \
    $(OBJDIR)\netbeans.obj
!endif

!ifdef XPM
vimobj = $(vimobj) \
    $(OBJDIR)\xpm_w32.obj
!endif

!if ("$(VIMDLL)"=="yes")
vimdllobj = $(vimobj)
!if ("$(DEBUG)"=="yes")
DLLTARGET = vim32d.dll
!else
DLLTARGET = vim32.dll
!endif
!else
DLLTARGET = joebob
!endif

!if ("$(GUI)"=="yes")
vimobj = $(vimobj) \
	$(vimwinmain) \
	$(OBJDIR)\gui.obj \
	$(OBJDIR)\gui_beval.obj \
	$(OBJDIR)\gui_w32.obj
!endif

!if ($(OSTYPE)==WIN32)
vimobj = $(vimobj) \
	$(OBJDIR)\os_win32.obj $(OBJDIR)\os_mswin.obj $(OBJDIR)\winclip.obj
!elif ($(OSTYPE)==DOS16)
vimobj = $(vimobj) \
	$(OBJDIR)\os_msdos.obj
!endif
# Blab what we are going to do:
MSG = Compiling $(OSTYPE) $(TARGET) $(OLETARGET), with:
!if ("$(GUI)"=="yes")
MSG = $(MSG) GUI
!endif
!if ("$(OLE)"=="yes")
MSG = $(MSG) OLE
!endif
!if ("$(USEDLL)"=="yes")
MSG = $(MSG) USEDLL
!endif
!if ("$(VIMDLL)"=="yes")
MSG = $(MSG) VIMDLL
!endif
!if ("$(FASTCALL)"=="yes")
MSG = $(MSG) FASTCALL
!endif
!if ("$(MBYTE)"=="yes")
MSG = $(MSG) MBYTE
!endif
!if ("$(IME)"=="yes")
MSG = $(MSG) IME
! if "$(DYNAMIC_IME)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
!if ("$(GETTEXT)"=="yes")
MSG = $(MSG) GETTEXT
!endif
!if ("$(ICONV)"=="yes")
MSG = $(MSG) ICONV
!endif
!if ("$(DEBUG)"=="yes")
MSG = $(MSG) DEBUG
!endif
!if ("$(CODEGUARD)"=="yes")
MSG = $(MSG) CODEGUARD
!endif
!if ("$(CSCOPE)"=="yes")
MSG = $(MSG) CSCOPE
!endif
!if ("$(NETBEANS)"=="yes")
MSG = $(MSG) NETBEANS
!endif
!ifdef XPM
MSG = $(MSG) XPM
!endif
!ifdef LUA
MSG = $(MSG) LUA
! if "$(DYNAMIC_LUA)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
!ifdef PERL
MSG = $(MSG) PERL
! if "$(DYNAMIC_PERL)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
!ifdef PYTHON
MSG = $(MSG) PYTHON
! if "$(DYNAMIC_PYTHON)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
!ifdef PYTHON3
MSG = $(MSG) PYTHON3
! if "$(DYNAMIC_PYTHON3)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
!ifdef RUBY
MSG = $(MSG) RUBY
! if "$(DYNAMIC_RUBY)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
!ifdef TCL
MSG = $(MSG) TCL
! if "$(DYNAMIC_TCL)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
MSG = $(MSG) cpu=$(CPUARG)
MSG = $(MSG) Align=$(ALIGNARG)

!message $(MSG)

!if ($(OSTYPE)==DOS16)
TARGETS = $(TARGET)
!else
!if ("$(VIMDLL)"=="yes")
TARGETS = $(DLLTARGET)
!endif
TARGETS = $(TARGETS) $(TARGET)
!endif

# Targets:
all: vim vimrun.exe install.exe xxd uninstal.exe GvimExt/gvimext.dll

vim: $(OSTYPE) $(OBJDIR) $(OBJDIR)\bcc.cfg $(TARGETS)
	@if exist $(OBJDIR)\version.obj del $(OBJDIR)\version.obj
	@if exist auto\pathdef.c del auto\pathdef.c

$(OSTYPE):
	-@md $(OSTYPE)

$(OBJDIR):
	-@md $(OBJDIR)

xxd:
	@cd xxd
	$(MAKE) /f Make_bc5.mak BOR="$(BOR)" BCC="$(CC)"
	@cd ..

GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
	cd GvimExt
	$(MAKE) /f Make_bc5.mak USEDLL=$(USEDLL) BOR=$(BOR)
	cd ..

install.exe: dosinst.c $(OBJDIR)\bcc.cfg
!if ($(OSTYPE)==WIN32)
	$(CC) $(CCARG) -WC -DWIN32 -einstall dosinst.c
!else
	$(CC) $(CCARG) -WC -einstall dosinst.c
!endif

uninstal.exe: uninstal.c $(OBJDIR)\bcc.cfg
!if ($(OSTYPE)==WIN32)
	$(CC) $(CCARG) -WC -DWIN32 -O2 -euninstal uninstal.c
!else
	$(CC) $(CCARG) -WC -O2 -euninstal uninstal.c
!endif

clean:
!if "$(OS)" == "Windows_NT"
	# For Windows NT/2000, doesn't work on Windows 95/98...
	# $(COMSPEC) needed to ensure rmdir.exe is not run
	-@$(COMSPEC) /C rmdir /Q /S $(OBJDIR)
!else
	# For Windows 95/98, doesn't work on Windows NT/2000...
	-@deltree /y $(OBJDIR)
!endif
	-@del *.res
	-@del vim32*.dll
	-@del vim32*.lib
	-@del *vim*.exe
	-@del *install*.exe
	-@del *.csm
	-@del *.map
	-@del *.ilc
	-@del *.ild
	-@del *.ilf
	-@del *.ils
	-@del *.tds
!ifdef LUA
	-@del lua.lib
!endif
!ifdef PERL
	-@del perl.lib
!endif
!ifdef PYTHON
	-@del python.lib
!endif
!ifdef PYTHON3
	-@del python3.lib
!endif
!ifdef RUBY
	-@del ruby.lib
!endif
!ifdef TCL
	-@del tcl.lib
!endif
!ifdef XPM
	-@del xpm.lib
!endif
	cd xxd
	$(MAKE) /f Make_bc5.mak BOR="$(BOR)" clean
	cd ..
	cd GvimExt
	$(MAKE) /f Make_bc5.mak BOR="$(BOR)" clean
	cd ..

$(DLLTARGET): $(OBJDIR) $(vimdllobj)
  $(LINK) @&&|
	$(LFLAGSDLL) +
	c0d32.obj +
	$(vimdllobj)
	$<,$*
!if ("$(CODEGUARD)"=="yes")
	cg32.lib+
!endif
# $(OSTYPE)==WIN32 causes os_mswin.c compilation. FEAT_SHORTCUT in it needs OLE
!if ("$(OLE)"=="yes" || $(OSTYPE)==WIN32)
	ole2w32.lib +
!endif
!if ($(OSTYPE)==WIN32)
	import32.lib+
!ifdef LUA
	$(LUA_LIB_FLAG)lua.lib+
!endif
!ifdef PERL
	$(PERL_LIB_FLAG)perl.lib+
!endif
!ifdef PYTHON
	$(PYTHON_LIB_FLAG)python.lib+
!endif
!ifdef PYTHON3
	$(PYTHON3_LIB_FLAG)python3.lib+
!endif
!ifdef RUBY
	$(RUBY_LIB_FLAG)ruby.lib+
!endif
!ifdef TCL
	$(TCL_LIB_FLAG)tcl.lib+
!endif
!ifdef XPM
	xpm.lib+
!endif
!if ("$(USEDLL)"=="yes")
	cw32i.lib
!else
	cw32.lib
!endif
	vim.def
!else
	cl.lib
!endif
|

!if ("$(VIMDLL)"=="yes")
$(TARGET): $(OBJDIR) $(DLLTARGET) $(vimmain) $(OBJDIR)\$(RESFILE)
!else
$(TARGET): $(OBJDIR) $(vimobj) $(OBJDIR)\$(RESFILE)
!endif
  $(LINK) @&&|
	$(LFLAGS) +
	$(STARTUPOBJ) +
!if ("$(VIMDLL)"=="yes")
	$(vimmain)
!else
	$(vimobj)
!endif
	$<,$*
!if ($(OSTYPE)==WIN32)
!if ("$(CODEGUARD)"=="yes")
	cg32.lib+
!endif
# $(OSTYPE)==WIN32 causes os_mswin.c compilation. FEAT_SHORTCUT in it needs OLE
!if ("$(OLE)"=="yes" || $(OSTYPE)==WIN32)
	ole2w32.lib +
!endif
	import32.lib+
!ifdef LUA
	$(LUA_LIB_FLAG)lua.lib+
!endif
!ifdef PERL
	$(PERL_LIB_FLAG)perl.lib+
!endif
!ifdef PYTHON
	$(PYTHON_LIB_FLAG)python.lib+
!endif
!ifdef PYTHON3
	$(PYTHON3_LIB_FLAG)python3.lib+
!endif
!ifdef RUBY
	$(RUBY_LIB_FLAG)ruby.lib+
!endif
!ifdef TCL
	$(TCL_LIB_FLAG)tcl.lib+
!endif
!ifdef XPM
	xpm.lib+
!endif
!if ("$(USEDLL)"=="yes")
	cw32i.lib
!else
	cw32.lib
!endif

	$(OBJDIR)\$(RESFILE)
!else
	emu.lib + cl.lib
!endif
|

test:
	cd testdir
	$(MAKE) /NOLOGO -f Make_dos.mak win32
	cd ..

$(OBJDIR)\ex_docmd.obj:  ex_docmd.c ex_cmds.h

$(OBJDIR)\ex_eval.obj:  ex_eval.c ex_cmds.h

$(OBJDIR)\if_ole.obj: if_ole.cpp

$(OBJDIR)\if_lua.obj: if_lua.c lua.lib
	$(CC) $(CCARG) $(CC1) $(CC2)$@ -pc if_lua.c

$(OBJDIR)\if_perl.obj: if_perl.c perl.lib
	$(CC) $(CCARG) $(CC1) $(CC2)$@ -pc if_perl.c

if_perl.c: if_perl.xs typemap
	$(PERL)\bin\perl.exe $(PERL)\lib\ExtUtils\xsubpp -prototypes -typemap \
	    $(PERL)\lib\ExtUtils\typemap if_perl.xs > $@

$(OBJDIR)\if_python.obj: if_python.c if_py_both.h python.lib
	$(CC) -I$(PYTHON)\include $(CCARG) $(CC1) $(CC2)$@ -pc if_python.c

$(OBJDIR)\if_python3.obj: if_python3.c if_py_both.h python3.lib
	$(CC) -I$(PYTHON3)\include $(CCARG) $(CC1) $(CC2)$@ -pc if_python3.c

$(OBJDIR)\if_ruby.obj: if_ruby.c ruby.lib
	$(CC) $(CCARG) $(CC1) $(CC2)$@ -pc if_ruby.c

$(OBJDIR)\if_tcl.obj: if_tcl.c tcl.lib
	$(CC) $(CCARG) $(CC1) $(CC2)$@ -pc if_tcl.c

$(OBJDIR)\xpm_w32.obj: xpm_w32.c xpm.lib
	$(CC) $(CCARG) $(CC1) $(CC2)$@ -pc xpm_w32.c

$(OBJDIR)\netbeans.obj: netbeans.c $(NBDEBUG_DEP)
	$(CC) $(CCARG) $(CC1) $(CC2)$@ netbeans.c

$(OBJDIR)\vim.res: vim.rc version.h tools.bmp tearoff.bmp \
		vim.ico vim_error.ico vim_alert.ico vim_info.ico vim_quest.ico
	$(BRC) -fo$(OBJDIR)\vim.res -i $(BOR)\include -w32 -r vim.rc @&&|
	$(DEFINES)
|

$(OBJDIR)\pathdef.obj:	auto\pathdef.c
	$(CC) $(CCARG) $(CC1) $(CC2)$@ auto\pathdef.c


# Need to escape both quotes and backslashes in $INTERP_DEFINES
INTERP_DEFINES_ESC_BKS=$(INTERP_DEFINES:\=\\)
INTERP_DEFINES_ESC=$(INTERP_DEFINES_ESC_BKS:"=\")

# Note:  the silly /*"*/ below are there to trick make into accepting
# the # character as something other than a comment without messing up
# the preprocessor directive.
auto\pathdef.c::
	-@md auto
	@echo creating auto/pathdef.c
	@copy /y &&|
/* pathdef.c */
/*"*/#include "vim.h"/*"*/

char_u *default_vim_dir = (char_u *)"$(VIMRCLOC:\=\\)";
char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR:\=\\)";
char_u *all_cflags = (char_u *)"$(CC:\=\\) $(CFLAGS:\=\\) $(DEFINES) $(MBDEFINES) $(INTERP_DEFINES_ESC) $(OPT) $(EXETYPE) $(CPUARG) $(ALIGNARG) $(DEBUG_FLAG) $(CODEGUARD_FLAG)";
char_u *all_lflags = (char_u *)"$(LINK:\=\\) $(LFLAGS:\=\\)";
char_u *compiled_user = (char_u *)"$(USERNAME)";
char_u *compiled_sys = (char_u *)"$(USERDOMAIN)";
| auto\pathdef.c

lua.lib: $(LUA)\lib\lua$(LUA_VER).lib
	coff2omf $(LUA)\lib\lua$(LUA_VER).lib $@

perl.lib: $(PERL)\lib\CORE\perl$(PERL_VER).lib
	coff2omf $(PERL)\lib\CORE\perl$(PERL_VER).lib $@

python.lib: $(PYTHON)\libs\python$(PYTHON_VER).lib
	coff2omf $(PYTHON)\libs\python$(PYTHON_VER).lib $@

python3.lib: $(PYTHON3)\libs\python$(PYTHON3_VER).lib
	coff2omf $(PYTHON3)\libs\python$(PYTHON3_VER).lib $@

ruby.lib: $(RUBY)\lib\$(RUBY_INSTALL_NAME).lib
	coff2omf $(RUBY)\lib\$(RUBY_INSTALL_NAME).lib $@

# For some reason, the coff2omf method doesn't work on libXpm.lib, so
# we have to manually generate an import library straight from the DLL.
xpm.lib: $(XPM)\lib\libXpm.lib
	implib -a $@ $(XPM)\bin\libXpm.dll

tcl.lib: $(TCL_LIB)
!if ("$(DYNAMIC_TCL)" == "yes")
	copy $(TCL_LIB) $@
!else
	coff2omf $(TCL_LIB) $@
!endif

!if ("$(DYNAMIC_TCL)" == "yes")
tclstub$(TCL_VER)-bor.lib:
	-@IF NOT EXIST $@ ECHO You must download tclstub$(TCL_VER)-bor.lib separately and\
	place it in the src directory in order to compile a dynamic TCL-enabled\
	(g)vim with the Borland compiler.  You can get the tclstub$(TCL_VER)-bor.lib file\
	at http://mywebpage.netscape.com/sharppeople/vim/tclstub$(TCL_VER)-bor.lib
!endif

# vimrun.exe:
vimrun.exe: vimrun.c
!if ("$(USEDLL)"=="yes")
	$(CC) -WC -O1 -I$(INCLUDE) -L$(LIB) -D_RTLDLL vimrun.c cw32mti.lib
!else
	$(CC) -WC -O1 -I$(INCLUDE) -L$(LIB) vimrun.c
!endif

# The dependency on $(OBJDIR) is to have bcc.cfg generated each time.
$(OBJDIR)\bcc.cfg: Make_bc5.mak $(OBJDIR)
  copy /y &&|
	$(CFLAGS)
	-L$(LIB)
	$(DEFINES)
	$(MBDEFINES)
	$(INTERP_DEFINES)
	$(EXETYPE)
	$(DEBUG_FLAG)
	$(OPT)
	$(CODEGUARD_FLAG)
	$(CPUARG)
	$(ALIGNARG)
| $@

# vi:set sts=4 sw=4: