aboutsummaryrefslogtreecommitdiff
path: root/makefile
blob: 1383c12b424af394f13cd710b21ade32f5944c70 (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
# This is an Open Watcom wmake makefile, not GNU make.
# Assuming you have sourced `owsetenv` beforehand.

# All binaries to build
bins = vbmouse.exe vbsf.exe vbmouse.drv moustest.exe

# Inf files
infs = oemsetup.inf

# Object files for vbmouse
mousedos_objs = mousetsr.obj mousmain.obj kitten.obj vbox.obj
mousew16_objs = mousew16.obj

# Object files for vbsf
sfdos_objs = sftsr.obj sfmain.obj kitten.obj vbox.obj

# Compiler arguments for DOS
dos_cflags = -bt=dos -ms -6 -osi -w3 -wcd=202
# -ms to use small memory model (this assumes ss == ds)
# -osi to optimize for size, put intrinsics inline (to avoid runtime calls)
# -w3 enables warnings
# -wcd=202 disables the unreferenced function warning (e.g., for inline functions in headers)

# Compiler arguments for DOS TSR files
dostsr_cflags = $(dos_cflags) -DIN_TSR -zu -s -g=RES_GROUP -nd=RES -nt=RES_TEXT -nc=RES_CODE
# -s to disable stack checks, since it inserts calls to the runtime from the TSR part
# -zu since ss != ds on the TSR

# Compiler arguments for W16 .DLL/.DRV files
w16dll_cflags = -bt=windows -bd -mc -zu -s -6 -osi -w3 -wcd=202
# -bd to build DLL
# -mc to use compact memory model (far data pointers, ss != ds in a DLL)
# -zu for DLL calling convention (ss != ds)
# -s to disable stack checks, since the runtime uses MessageBox() to abort (which we can't call from mouse.drv)

# Full compiler command lines
compile_dos = *wcc -fo=$^@ $(dos_cflags) $[@
compile_dostsr = *wcc -fo=$^@ $(dostsr_cflags) $[@
compile_w16dll = *wcc -fo=$^@ $(w16dll_cflags) $[@
compile_link_host = *wcl386 -i=$(%originclude) -os -fe=$^@ $[@

!ifdef __UNIX__
run_host = ./
!else
run_host =
!endif

.BEFORE:
	# We need DOS and Windows headers, not host platform's
	set originclude=$(%include)
	set include=$(%watcom)/h/win;$(%watcom)/h

all: $(bins) .SYMBOLIC

# DOS mouse driver
vbmouse.exe: vbmouse.lnk $(mousedos_objs) kittenc.exe
	*wlink @$[@ name $@ file { $(mousedos_objs) }
	$(run_host)kittenc.exe $@ attach nls/vbmouse.*

mousetsr.obj: mousetsr.c .AUTODEPEND
	$(compile_dostsr)

mousmain.obj: mousmain.c .AUTODEPEND
	$(compile_dos)

# Windows 3.x mouse driver
vbmouse.drv: mousew16.lnk $(mousew16_objs)
	*wlink @$[@ name $@ file { $(mousew16_objs) }

mousew16.obj: mousew16.c .AUTODEPEND
	$(compile_w16dll)

# DOS shared folders
vbsf.exe: vbsf.lnk $(sfdos_objs) kittenc.exe
	*wlink @$[@ name $@ file { $(sfdos_objs) }
	$(run_host)kittenc.exe $@ attach nls/vbsf.*

sftsr.obj: sftsr.c .AUTODEPEND
	$(compile_dostsr)

sfmain.obj: sfmain.c unitbl.h .AUTODEPEND
	$(compile_dos)

# Auxiliary object files
vbox.obj: vbox.c .AUTODEPEND
	$(compile_dos)

kitten.obj: kitten.c .AUTODEPEND
	$(compile_dos)

# embed all unitbl/*.tbl files into a single unitbl.h
unitbl.h: unitbl2c.exe $(unitbls)
	$(run_host)unitbl2c.exe $@ unitbl/*.tbl

# Test programs
moustest_objs = moustest.obj

moustest.exe: moustest.obj
	*wlink system dos name $@ file { $(moustest_objs) }

moustest.obj: moustest.c .AUTODEPEND
	$(compile_dos) -mc -zu

# Programs to build for the host
host_bins = unitbl2c.exe kittenc.exe
unitbl2c.exe: unitbl2c.c
	$(compile_link_host)

kittenc.exe: kittenc.c
	$(compile_link_host)

# Other targets
clean: .SYMBOLIC
	rm -f vbados.zip vbados.flp vbasrc.zip
	rm -f $(bins) $(host_bins)
	rm -f *.obj *.map

vbados.flp:
	mformat -C -f 1440 -v VBADOS -i $^@ ::

# Build a floppy image containing the driver
flp: vbados.flp $(bins) $(infs) .SYMBOLIC
	mcopy -i vbados.flp -o $(bins) $(infs) ::

# Build a zip with the driver binaries
zip: vbmouse.exe vbmouse.drv oemsetup.inf vbsf.exe .SYMBOLIC
	zip --DOS-names -fz- -j vbados.zip nls/vbsf.* nls/vbmouse.*
	zip --DOS-names -fz- vbados.zip $(bins) $(infs)

srczip: .SYMBOLIC
	zip --DOS-names -fz- vbasrc.zip COPYING README.md makefile *.lnk *.h *.c *.inf nls/* unitbl/* doc/*