source: trunk/src/os2ahci/wmakefile@ 144

Last change on this file since 144 was 144, checked in by rousseau, 13 years ago

Fixed the Open Watcom build

Building with Open Watcom produced a non working driver.

Causes & Fixes

o Enum types were 8 bits when using WCC

This caused the functions with variable arguments to fail.
Adding the -ei compiler-flag to WCC solved this issue.

o Incorrect inline assembler syntax to call DeviceHelp in os2ahci.c

DeviceHelp is a 16:16 far pointer residing in memory.
MASM interprets 'call DeviceHelp' differently than WASM.
The correct syntax is: 'call dword ptr [DeviceHelp]'.

o Missing segments from TGROUP in init.asm

WLINK then generates the AUTO class, most probably causing incorrect
relocation fixups.

Enhancements

o WASM (or JWASM) can now be used instead of ALP
o WCC can now be used instead of CL
o The Open Watcom linker (WLINK) can now be used instead of LINK
o Streamlined both makefiles a notch so it's easy to use both tool-chains

To investigate

o CL barks about a missing prototype for DevHelp_Yield() in lib.c

The prototype is actually defined in dhcalls.h but CL still barks.

o Using WCC with ALP and WLINK produces an oversized image

Probaly due to misplaced BSS segments. WCC with ALP and LINK produces
a normal sized image however.

  • Property svn:executable set to *
File size: 6.5 KB
Line 
1###############################################################################
2# wmakefile - makefile for os2ahci driver using WATCOM compiler
3#
4# Copyright (c) 2010 Christian Mueller, Markus Thielen.
5# Parts copied from/inspired by the Linux AHCI driver;
6# those parts are (c) Linux AHCI/ATA maintainers
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22###############################################################################
23# Calling Syntax
24#
25# wmake -ms -f wmakefile
26#
27# NOTE: we use MS compatibility mode (-ms) so we can use a syntax similar
28# to the well known nmake syntax.
29#
30
31###############################################################################
32# wmake directives
33.HOLD # do not prompt for deletion of created files on error; leave them alone
34
35
36
37###############################################################################
38# Environment
39
40
41# main path to OS/2 DDK; this needs to be set before this makefile will work
42!ifndef DDK
43DDK = i:\ddk
44!endif
45
46# main path to WATCOM installation
47!ifndef WATCOM
48WATCOM = i:\watcom
49!endif
50
51CC_INCLUDE = -I..\include \
52 -I$(DDK)\base\h \
53 -I$(DDK)\base\ibmh \
54 -I$(DDK)\base\src\dev\dasd\diskh \
55 -I$(DDK)\base\src\dev\thinkpad\dockii\apmcalls \
56# -I$(CC16)\include
57
58AS_INCLUDE = -I=$(DDK)\base\inc \
59 -I=$(DDK)\base\src\dev\dasd\diskinc
60
61LIB_DIRS = $(DDK)\base\lib\ \
62 $(DDK)\base\src\dev\dasd\devhlp\ \
63 $(DDK)\base\src\dev\thinkpad\dockii\apmcalls\ \
64
65
66
67
68###############################################################################
69# Tool Chain
70#
71# This makefile uses the Watcom 16-bit compiler, Watcom Assembler and Linker.
72# You can change to the DDK Linker and Assembler by modifying the macros below.
73#
74
75
76#LINKER=ibm
77LINKER=watcom
78
79
80#AS = $(DDK)\tools\alp.exe
81#AS = jwasm -Cp
82AS = wasm
83CC = wcc
84LD = $(DDK)\base\tools\link.exe
85BLDLEVEL = cmd.exe /c ..\..\tools\bldlvl.cmd
86BLDDATE = cmd.exe /c ..\..\tools\blddate.cmd
87MAPSYM = $(DDK)\base\tools\mapsym.exe
88
89#AFLAGS = -Mb
90#CFLAGS = -ei -5 -d3 -hc -bt=os2 -ms -zu -w3 -wcd=138 -wcd=300 -ecc -zp1 -q -s -zgp -zfp -oi
91CFLAGS = -ei -5 -d0 -bt=os2 -ms -zu -w=0 -ecc -zp=1 -q -s -zgp -zfp -oi
92CFLAGS_DEBUG = -ei -5 -d3 -hc -bt=os2 -ms -zu -ecc -zp=1 -q -s -zgp -zfp -od
93
94LFLAGS = /noe /nod /packd /a:16 /batch /map /line
95
96###############################################################################
97# Main dependencies
98
99TARGET = os2ahci.add
100
101#LIBS = addcalls doscalls rmcalls apmcalls # dhcalls not needed, see local devhelp.h
102LIBS = addcalls doscalls rmcalls apmcalls dhcalls
103
104SRCS = init.asm math.asm libc.c os2ahci.c pci.c ahci.c ata.c atapi.c \
105 ctxhook.c trace.c ioctl.c apm.c
106
107OBJS = init.obj libc.obj os2ahci.obj pci.obj ahci.obj ata.obj atapi.obj \
108 ctxhook.obj trace.obj ioctl.obj apm.obj
109
110INCS = os2ahci.h ahci.h version.h
111
112
113all: $(TARGET)
114
115clean:
116 rm -f $(OBJS) $(TARGET) *.cod *.lst *.def *.map *.sym *.err *.lnk \
117 bldday.h
118
119###############################################################################
120# Object/source dependencies
121
122init.obj: $*.asm wmakefile
123
124libc.obj: $*.c wmakefile $(INCS)
125
126os2ahci.obj: $*.c wmakefile $(INCS) bldday.h ioctl.h
127
128pci.obj: $*.c wmakefile $(INCS)
129
130ahci.obj: $*.c wmakefile $(INCS) ata.h atapi.h
131
132ata.obj: $*.c wmakefile $(INCS) $*.h
133
134atapi.obj: $*.c wmakefile $(INCS) $*.h ata.h
135
136ctxhook.obj: $*.c wmakefile $(INCS) ata.h atapi.h
137
138apm.obj: $*.c wmakefile $(INCS)
139
140ioctl.obj: $*.c wmakefile $(INCS) $*.h atapi.h
141
142trace.obj: $*.c wmakefile $(INCS)
143
144os2ahci.def: version.h $*.def.template
145
146###############################################################################
147# Action definitions (compile/link commands)
148
149# emacs TAGS file creation
150# NOTE: OS/2 emacs etags.exe expects an empty file named c:\dev\null...
151tags: $(SRCS) $(INCS)
152 etags.exe $(SRCS) $(INCS)
153
154bldday.h:
155 $(BLDDATE) > bldday.h
156
157.asm.obj:
158 $(AS) $(AFLAGS) $(AS_INCLUDE) $*.asm
159 wdis -l $*.obj
160
161.c.obj:
162 $(CC) $(CFLAGS) $(CC_INCLUDE) $*.c
163 wdis -l $*.obj
164
165os2ahci.def:
166 $(BLDLEVEL) $*.def.template $*.def version.h
167
168$(TARGET): $(OBJS) $*.def wmakefile
169
170!if "$(LINKER)"=="watcom"
171 # Target name, system and type
172 @%create $*.lnk
173 @%append $*.lnk name $*.add
174 @%append $*.lnk sys os2 dll
175 # Merge BLDLEVEL information
176 @%append $*.lnk option
177 @qgrep -y -e "description" $*.def >> $*.lnk
178 # Set various options
179 @%append $*.lnk option protmode
180 @%append $*.lnk option map
181 @%append $*.lnk option quiet
182 @%append $*.lnk option nocase
183 @%append $*.lnk option stack=0
184 # Generate directives for objects, libraries and library search-paths
185 @for %f in ($(OBJS)) do @%append $*.lnk file %f
186 @for %f in ($(LIBS)) do @%append $*.lnk lib %f
187 @for %f in ($(LIB_DIRS)) do @%append $*.lnk libpath %f
188 # Attributes for the DATA and CODE segments
189 @%append $*.lnk segment type DATA SHARED
190 @%append $*.lnk segment type CODE IOPL
191 # Order segments by class
192 @%append $*.lnk order
193 @%append $*.lnk clname 'DATA'
194 @%append $*.lnk clname 'CONST'
195 @%append $*.lnk clname 'BSS'
196 @%append $*.lnk clname 'CODE'
197 # Link the stuff together and build the target
198 wlink @$*.lnk
199
200!elseif "$(LINKER)"=="ibm"
201 $(LD) $(LFLAGS) $(OBJS),$(TARGET),$*.map,$(LIB_DIRS) $(LIBS),$*.def
202 mapsym $*
203!else
204 @echo "Error: No valid linker specified"
205!endif
206
Note: See TracBrowser for help on using the repository browser.