1
2# this makefile in OW WMake style creates JWasm.EXE (Win32) and optionally
3# JWasmD.EXE (DOS).
4# tools used:
5# - Open Watcom v1.9
6# - jwlink ( optionally OW Wlink may be used, see below )
7# - HXDev  ( needed only if a DOS version is to be created )
8#
9# "WMake"         - creates the Win32 version.
10# "WMake debug=1" - creates the Win32 debug version.
11# "WMake dos=1"   - creates both Win32 and DOS version (JWasmD.exe)
12# "WMake djgpp=1" - creates a Win32 version with DJGPP support.
13# "WMake wlink=1" - create a Win32 version that is linked with OW Wlink.
14
15name = JWasm
16
17WIN=1
18
19# Open Watcom root directory
20!ifndef WATCOM
21WATCOM = \Watcom
22!endif
23# if a DOS version is to be created, HXDIR must contain the HX root directory
24!ifndef HXDIR
25HXDIR = \HX
26!endif
27
28!ifndef DEBUG
29DEBUG=0
30!endif
31!ifndef DOS
32DOS=0
33!endif
34!ifndef DJGPP
35DJGPP=0
36!endif
37
38# to track memory leaks, the Open Watcom TRMEM module can be included.
39# it's useful only if FASTMEM=0 is set, though, otherwise most allocs
40# won't use the C heap.
41!ifndef TRMEM
42TRMEM=0
43!endif
44
45!ifndef OUTD
46!if $(DEBUG)
47OUTD=Build\Debug
48!else
49OUTD=Build\Release
50!endif
51!endif
52
53inc_dirs  = -Isrc\H -I$(WATCOM)\H
54c_flags = -q -bc -bt=nt -3r -fpi87
55
56# -zc flag makes wcc386 place constant data in code segment.
57# used with wlink because it won't accept readonly attribute for segments
58!ifdef WLINK
59LINK = $(WATCOM)\binnt\wlink.exe
60c_flags += -zc
61!else
62LINK = jwlink.exe
63!endif
64
65#cflags stuff
66#########
67extra_c_flags =
68!if $(DEBUG)
69extra_c_flags += -od -d2 -w3 -hc -DDEBUG_OUT
70!else
71#extra_c_flags += -obmilrt -s -DNDEBUG
72extra_c_flags += -oxa -s -DNDEBUG
73!endif
74
75!if $(TRMEM)
76extra_c_flags += -of -DTRMEM -DFASTMEM=0
77!endif
78!if $(DJGPP)
79extra_c_flags += -DDJGPP_SUPPORT=1
80!endif
81#########
82
83!if $(DEBUG)
84# for OW v1.8, the debug version needs user32.lib to resolve CharUpperA()
85# without it, WD(W) will crash immediately.
86LOPTD = debug c op cvp, symfile lib user32.lib
87!else
88LOPTD =
89!endif
90
91CC=$(WATCOM)\binnt\wcc386 $(c_flags) $(inc_dirs) $(extra_c_flags) -fo$@
92LIB=$(WATCOM)\binnt\wlib
93
94{src}.c{$(OUTD)}.obj:
95	$(CC) $<
96
97proj_obj = &
98!include owmod.inc
99
100!if $(TRMEM)
101proj_obj += $(OUTD)/trmem.obj
102!endif
103
104!if $(WIN)
105TARGET1=$(OUTD)/$(name).exe
106!endif
107!if $(DOS)
108TARGET2=$(OUTD)/$(name)d.exe
109!endif
110
111ALL: $(OUTD) $(TARGET1) $(TARGET2)
112
113$(OUTD):
114	@if not exist $(OUTD) mkdir $(OUTD)
115
116$(OUTD)/$(name).exe: $(OUTD)/main.obj $(proj_obj)
117	$(LINK) @<<
118$(LOPTD)
119format windows pe runtime console
120file { $(OUTD)/main.obj $(proj_obj) } name $@
121Libpath $(WATCOM)\lib386\nt;$(WATCOM)\lib386
122Library kernel32.lib
123op quiet, stack=0x40000, heapsize=0x100000, map=$^*, norelocs
124com stack=0x1000
125disable 171
126!ifndef NOGBL
127sort global
128!endif
129op statics
130!ifndef WLINK
131segment CONST readonly
132segment CONST2 readonly
133!endif
134<<
135!if $(DEBUG)
136	@if not exist TEST mkdir TEST
137	copy $(OUTD)\$(name).exe TEST\*.* >NUL
138	copy $(OUTD)\$(name).sym TEST\*.* >NUL
139!endif
140
141$(OUTD)/$(name)d.exe: $(OUTD)/main.obj $(proj_obj)
142	$(LINK) @<<
143$(LOPTD)
144!ifndef WLINK
145format windows pe hx runtime console
146!else
147format windows pe runtime console
148!endif
149file { $(OUTD)/main.obj $(proj_obj) } name $@
150Libpath $(WATCOM)\lib386\nt;$(WATCOM)\lib386
151Libfile cstrtwhx.obj
152libpath $(HXDIR)\lib
153Library imphlp.lib, dkrnl32s.lib, HXEmu387.lib
154reference EMUInit
155op quiet, stack=0x40000, heapsize=0x40000, map=$^*, stub=$(HXDIR)\Bin\loadpex.bin
156sort global op statics
157!ifndef WLINK
158segment CONST readonly
159segment CONST2 readonly
160!endif
161<<
162!ifdef WLINK
163#	$(HXDIR)\Bin\pestub.exe -x -z -n $@
164	pestub.exe -x -z -n $@
165!endif
166
167$(OUTD)/msgtext.obj: src/msgtext.c src/H/msgdef.h src/H/globals.h
168	$(CC) src\msgtext.c
169
170$(OUTD)/reswords.obj: src/reswords.c src/H/instruct.h src/H/special.h src/H/directve.h src/H/opndcls.h src/H/instravx.h
171	$(CC) src\reswords.c
172
173######
174
175clean: .SYMBOLIC
176	@if exist $(OUTD)\$(name).exe erase $(OUTD)\$(name).exe
177	@if exist $(OUTD)\$(name)d.exe erase $(OUTD)\$(name)d.exe
178	@if exist $(OUTD)\$(name).map erase $(OUTD)\$(name).map
179	@if exist $(OUTD)\$(name)d.map erase $(OUTD)\$(name)d.map
180	@if exist $(OUTD)\*.obj erase $(OUTD)\*.obj
181