]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/cpu/common.mak
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / cpu / common.mak
1 # this makefile is included from all the dos*.mak files, do not use directly
2 # NTS: HPS is either \ (DOS) or / (Linux)
3
4 # The build system we have has no effect on NASM (at the moment) and
5 # all memory models+CPU modes build the same binary. So why build them
6 # again and again? Build them only in dos86s mode.
7 !ifndef TARGET_WINDOWS
8 ! ifndef TARGET_OS2
9 !  ifeq TARGET_MSDOS 16
10 !   ifeq TARGET86 86
11 !    ifeq MMODE s
12 BUILD_NASM_COM = 1
13 !    endif
14 !   endif
15 !  endif
16 ! endif
17 !endif
18
19 CFLAGS_THIS = -fr=nul -fo=$(SUBDIR)$(HPS).obj -i=.. -i..$(HPS)..
20 AFLAGS_THIS = -fr=nul -fo=$(SUBDIR)$(HPS).obj -i=.. -i..$(HPS)..
21 NASMFLAGS_THIS = 
22 NOW_BUILDING = HW_CPU_LIB
23
24 # NTS: CPU functions here are to be moved at some point to the cpu library!
25 OBJS =        $(SUBDIR)$(HPS)cpuasm.obj $(SUBDIR)$(HPS)cpup3sn.obj $(SUBDIR)$(HPS)cpup3snc.obj $(SUBDIR)$(HPS)cpusse.obj $(SUBDIR)$(HPS)cpu.obj $(SUBDIR)$(HPS)cpuidext.obj $(SUBDIR)$(HPS)gdt_enum.obj $(SUBDIR)$(HPS)libgrind.obj $(SUBDIR)$(HPS)cpurdtsc.obj $(SUBDIR)$(HPS)cpuiopd.obj $(SUBDIR)$(HPS)cpustrlv.obj $(SUBDIR)$(HPS)resetasm.obj $(SUBDIR)$(HPS)cpuid.obj $(SUBDIR)$(HPS)cpurdmsr.obj $(SUBDIR)$(HPS)cpussea.obj
26
27 # test programs (MS-DOS and Windows)
28 MMX_EXE =     $(SUBDIR)$(HPS)mmx.exe
29 SSE_EXE =     $(SUBDIR)$(HPS)sse.exe
30 TEST_EXE =    $(SUBDIR)$(HPS)test.exe
31 GRIND_EXE =   $(SUBDIR)$(HPS)grind.exe
32 GR_ADD_EXE =  $(SUBDIR)$(HPS)gr_add.exe
33 DISPSN_EXE =  $(SUBDIR)$(HPS)dispsn.exe
34 SSEOFF_EXE =  $(SUBDIR)$(HPS)sseoff.exe
35 GDTLIST_EXE = $(SUBDIR)$(HPS)gdtlist.exe
36 !ifndef WIN386
37 GDTTAE_EXE =  $(SUBDIR)$(HPS)gdttae.exe
38 !endif
39 RDTSC_EXE =   $(SUBDIR)$(HPS)rdtsc.exe
40
41 !ifndef TARGET_WINDOWS
42 ! ifndef TARGET_OS2
43 # test programs (MS-DOS only)
44 RESET_EXE =   $(SUBDIR)$(HPS)reset.exe
45 APIC_EXE =    $(SUBDIR)$(HPS)apic.exe
46 ! endif
47 !endif
48
49 !ifdef BUILD_NASM_COM
50 # MS-DOS COM output
51 V86_COM =     $(SUBDIR)$(HPS)v86.com
52 TSS_COM =     $(SUBDIR)$(HPS)tss.com
53 PROT286_COM = $(SUBDIR)$(HPS)prot286.com
54 PROT386_COM = $(SUBDIR)$(HPS)prot386.com
55 TSSRING_COM = $(SUBDIR)$(HPS)tssring.com
56 V86KERN_COM = $(SUBDIR)$(HPS)v86kern.com
57 PROTVCPI_COM =$(SUBDIR)$(HPS)protvcpi.com
58 PROTDPMI_COM =$(SUBDIR)$(HPS)protdpmi.com
59 V86KERN2_COM =$(SUBDIR)$(HPS)v86kern2.com
60 ALIGNCHK_COM =$(SUBDIR)$(HPS)alignchk.com
61 !endif
62
63 !ifdef APIC_EXE
64 OBJS +=       $(SUBDIR)$(HPS)apiclib.obj
65 !endif
66
67 $(HW_CPU_LIB): $(OBJS)
68         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)cpu.obj -+$(SUBDIR)$(HPS)cpuasm.obj
69         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)gdt_enum.obj -+$(SUBDIR)$(HPS)libgrind.obj
70         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)cpuidext.obj -+$(SUBDIR)$(HPS)cpusse.obj
71         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)cpup3sn.obj -+$(SUBDIR)$(HPS)cpup3snc.obj
72         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)cpurdtsc.obj -+$(SUBDIR)$(HPS)cpuiopd.obj
73         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)cpustrlv.obj -+$(SUBDIR)$(HPS)resetasm.obj
74         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)cpuid.obj -+$(SUBDIR)$(HPS)cpurdmsr.obj
75         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)cpussea.obj
76 !ifdef APIC_EXE
77         wlib -q -b -c $(HW_CPU_LIB) -+$(SUBDIR)$(HPS)apiclib.obj
78 !endif
79
80 # NTS we have to construct the command line into tmp.cmd because for MS-DOS
81 # systems all arguments would exceed the pitiful 128 char command line limit
82 .C.OBJ:
83         %write tmp.cmd $(CFLAGS_THIS) $(CFLAGS_CON) $[@
84         $(CC) @tmp.cmd
85
86 .ASM.OBJ:
87         nasm -o $@ -f obj $(NASMFLAGS_CON) $[@
88
89 all: lib exe
90         
91 lib: $(HW_CPU_LIB) .symbolic
92         
93 exe: $(GDTTAE_EXE) $(TEST_EXE) $(GRIND_EXE) $(GR_ADD_EXE) $(DISPSN_EXE) $(RESET_EXE) $(APIC_EXE) $(MMX_EXE) $(SSE_EXE) $(SSEOFF_EXE) $(PROT286_COM) $(PROT386_COM) $(TSS_COM) $(TSSRING_COM) $(ALIGNCHK_COM) $(V86_COM) $(V86KERN_COM) $(V86KERN2_COM) $(PROTVCPI_COM) $(PROTDPMI_COM) $(RDTSC_EXE) $(GDTLIST_EXE) .symbolic
94
95 !ifdef BUILD_NASM_COM
96 $(V86_COM): v86.asm
97         nasm -o $@ -f bin $(NASMFLAGS) $[@
98
99 $(TSS_COM): tss.asm
100         nasm -o $@ -f bin $(NASMFLAGS) $[@
101
102 $(TSSRING_COM): tssring.asm
103         nasm -o $@ -f bin $(NASMFLAGS) $[@
104
105 $(PROT286_COM): prot286.asm
106         nasm -o $@ -f bin $(NASMFLAGS) $[@
107
108 $(PROT386_COM): prot386.asm
109         nasm -o $@ -f bin $(NASMFLAGS) $[@
110
111 $(V86KERN_COM): v86kern.asm
112         nasm -o $@ -f bin $(NASMFLAGS) -l $(SUBDIR)$(HPS)v86kern.lst -O9 $[@
113
114 $(PROTVCPI_COM): protvcpi.asm
115         nasm -o $@ -f bin $(NASMFLAGS) -l $(SUBDIR)$(HPS)protvcpi.lst -O9 $[@
116
117 $(PROTDPMI_COM): protdpmi.asm
118         nasm -o $@ -f bin $(NASMFLAGS) -l $(SUBDIR)$(HPS)protdpmi.lst -O9 $[@
119
120 $(V86KERN2_COM): v86kern2.asm
121         nasm -o $@ -f bin $(NASMFLAGS) -l $(SUBDIR)$(HPS)v86kern2.lst -O9 $[@
122
123 $(ALIGNCHK_COM): alignchk.asm
124         nasm -o $@ -f bin $(NASMFLAGS) $[@
125 !endif
126
127 $(MMX_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)mmx.obj
128         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)mmx.obj option map=$(SUBDIR)$(HPS)mmx.map
129 ! ifdef TARGET_WINDOWS
130 !  ifeq TARGET_MSDOS 16
131         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
132         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
133 !  endif
134 ! endif
135         %write tmp.cmd name $(MMX_EXE)
136         @wlink @tmp.cmd
137         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
138 ! ifdef WIN386
139         @$(WIN386_EXE_TO_REX_IF_REX) $(MMX_EXE)
140         @wbind $(MMX_EXE) -q -n
141 ! endif
142 ! ifdef WIN_NE_SETVER_BUILD
143         $(WIN_NE_SETVER_BUILD) $(MMX_EXE)
144 ! endif
145
146 $(SSE_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)sse.obj
147         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)sse.obj option map=$(SUBDIR)$(HPS)sse.map
148 ! ifdef TARGET_WINDOWS
149 !  ifeq TARGET_MSDOS 16
150         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
151         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
152 !  endif
153 ! endif
154         %write tmp.cmd name $(SSE_EXE)
155         @wlink @tmp.cmd
156         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
157 ! ifdef WIN386
158         @$(WIN386_EXE_TO_REX_IF_REX) $(SSE_EXE)
159         @wbind $(SSE_EXE) -q -n
160 ! endif
161 ! ifdef WIN_NE_SETVER_BUILD
162         $(WIN_NE_SETVER_BUILD) $(SSE_EXE)
163 ! endif
164
165 $(TEST_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)test.obj
166         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)test.obj option map=$(SUBDIR)$(HPS)test.map
167 ! ifdef TARGET_WINDOWS
168 !  ifeq TARGET_MSDOS 16
169         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
170         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
171 !  endif
172 ! endif
173         %write tmp.cmd name $(TEST_EXE)
174         @wlink @tmp.cmd
175         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
176 ! ifdef WIN386
177         @$(WIN386_EXE_TO_REX_IF_REX) $(TEST_EXE)
178         @wbind $(TEST_EXE) -q -n
179 ! endif
180 ! ifdef WIN_NE_SETVER_BUILD
181         $(WIN_NE_SETVER_BUILD) $(TEST_EXE)
182 ! endif
183
184 $(GRIND_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)grind.obj
185         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)grind.obj option map=$(SUBDIR)$(HPS)grind.map
186 ! ifdef TARGET_WINDOWS
187 !  ifeq TARGET_MSDOS 16
188         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
189         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
190 !  endif
191 ! endif
192         %write tmp.cmd name $(GRIND_EXE)
193         @wlink @tmp.cmd
194         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
195 ! ifdef WIN386
196         @$(WIN386_EXE_TO_REX_IF_REX) $(GRIND_EXE)
197         @wbind $(GRIND_EXE) -q -n
198 ! endif
199 ! ifdef WIN_NE_SETVER_BUILD
200         $(WIN_NE_SETVER_BUILD) $(GRIND_EXE)
201 ! endif
202
203 $(GR_ADD_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)gr_add.obj
204         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)gr_add.obj option map=$(SUBDIR)$(HPS)gr_add.map
205 ! ifdef TARGET_WINDOWS
206 !  ifeq TARGET_MSDOS 16
207         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
208         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
209 !  endif
210 ! endif
211         %write tmp.cmd name $(GR_ADD_EXE)
212         @wlink @tmp.cmd
213         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
214 ! ifdef WIN386
215         @$(WIN386_EXE_TO_REX_IF_REX) $(GR_ADD_EXE)
216         @wbind $(GR_ADD_EXE) -q -n
217 ! endif
218 ! ifdef WIN_NE_SETVER_BUILD
219         $(WIN_NE_SETVER_BUILD) $(GR_ADD_EXE)
220 ! endif
221
222 $(RDTSC_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(HW_8254_LIB) $(SUBDIR)$(HPS)rdtsc.obj
223         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) library $(HW_8254_LIB) file $(SUBDIR)$(HPS)rdtsc.obj option map=$(SUBDIR)$(HPS)rdtsc.map
224 ! ifdef TARGET_WINDOWS
225 !  ifeq TARGET_MSDOS 16
226         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
227         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
228 !  endif
229 ! endif
230         %write tmp.cmd name $(RDTSC_EXE)
231         @wlink @tmp.cmd
232         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
233 ! ifdef WIN386
234         @$(WIN386_EXE_TO_REX_IF_REX) $(RDTSC_EXE)
235         @wbind $(RDTSC_EXE) -q -n
236 ! endif
237 ! ifdef WIN_NE_SETVER_BUILD
238         $(WIN_NE_SETVER_BUILD) $(RDTSC_EXE)
239 ! endif
240
241 !ifdef RESET_EXE
242 $(RESET_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(HW_8042_LIB) $(HW_8254_LIB) $(SUBDIR)$(HPS)reset.obj
243         %write tmp.cmd option quiet system $(WLINK_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) library $(HW_8042_LIB) library $(HW_8254_LIB) file $(SUBDIR)$(HPS)reset.obj option map=$(SUBDIR)$(HPS)reset.map
244         %write tmp.cmd name $(RESET_EXE)
245         @wlink @tmp.cmd
246         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
247 !endif
248
249 !ifdef APIC_EXE
250 $(APIC_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(HW_FLATREAL_LIB) $(SUBDIR)$(HPS)apic.obj
251         %write tmp.cmd option quiet system $(WLINK_SYSTEM) $(WLINK_FLAGS) $(HW_FLATREAL_LIB_WLINK_LIBRARIES) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)apic.obj option map=$(SUBDIR)$(HPS)apic.map
252         %write tmp.cmd name $(APIC_EXE)
253         @wlink @tmp.cmd
254         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
255 !endif
256
257 $(DISPSN_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)dispsn.obj
258         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)dispsn.obj option map=$(SUBDIR)$(HPS)dispsn.map
259 ! ifdef TARGET_WINDOWS
260 !  ifeq TARGET_MSDOS 16
261         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
262         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
263 !  endif
264 ! endif
265         %write tmp.cmd name $(DISPSN_EXE)
266         @wlink @tmp.cmd
267         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
268 ! ifdef WIN386
269         @$(WIN386_EXE_TO_REX_IF_REX) $(DISPSN_EXE)
270         @wbind $(DISPSN_EXE) -q -n
271 ! endif
272 ! ifdef WIN_NE_SETVER_BUILD
273         $(WIN_NE_SETVER_BUILD) $(DISPSN_EXE)
274 ! endif
275
276 $(SSEOFF_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)sseoff.obj
277         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)sseoff.obj option map=$(SUBDIR)$(HPS)sseoff.map
278 ! ifdef TARGET_WINDOWS
279 !  ifeq TARGET_MSDOS 16
280         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
281         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
282 !  endif
283 ! endif
284         %write tmp.cmd name $(SSEOFF_EXE)
285         @wlink @tmp.cmd
286         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
287 ! ifdef WIN386
288         @$(WIN386_EXE_TO_REX_IF_REX) $(SSEOFF_EXE)
289         @wbind $(SSEOFF_EXE) -q -n
290 ! endif
291 ! ifdef WIN_NE_SETVER_BUILD
292         $(WIN_NE_SETVER_BUILD) $(SSEOFF_EXE)
293 ! endif
294
295 $(GDTLIST_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)gdtlist.obj
296         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)gdtlist.obj option map=$(SUBDIR)$(HPS)gdtlist.map
297 ! ifdef TARGET_WINDOWS
298 !  ifeq TARGET_MSDOS 16
299         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
300         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
301 !  endif
302 ! endif
303         %write tmp.cmd name $(GDTLIST_EXE)
304         @wlink @tmp.cmd
305         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
306 ! ifdef WIN386
307         @$(WIN386_EXE_TO_REX_IF_REX) $(GDTLIST_EXE)
308         @wbind $(GDTLIST_EXE) -q -n
309 ! endif
310 ! ifdef WIN_NE_SETVER_BUILD
311         $(WIN_NE_SETVER_BUILD) $(GDTLIST_EXE)
312 ! endif
313
314 !ifdef GDTTAE_EXE
315 $(GDTTAE_EXE): $(HW_CPU_LIB) $(HW_CPU_LIB_DEPENDENCIES) $(SUBDIR)$(HPS)gdttae.obj
316         %write tmp.cmd option quiet system $(WLINK_CON_SYSTEM) $(WLINK_FLAGS) $(HW_CPU_LIB_WLINK_LIBRARIES) file $(SUBDIR)$(HPS)gdttae.obj option map=$(SUBDIR)$(HPS)gdttae.map
317 ! ifdef TARGET_WINDOWS
318 !  ifeq TARGET_MSDOS 16
319         %write tmp.cmd segment TYPE CODE PRELOAD FIXED DISCARDABLE SHARED
320         %write tmp.cmd segment TYPE DATA PRELOAD MOVEABLE
321 !  endif
322 ! endif
323         %write tmp.cmd name $(GDTTAE_EXE)
324         @wlink @tmp.cmd
325         @$(COPY) ..$(HPS)..$(HPS)dos32a.dat $(SUBDIR)$(HPS)dos4gw.exe
326 ! ifdef WIN386
327         @$(WIN386_EXE_TO_REX_IF_REX) $(GDTTAE_EXE)
328         @wbind $(GDTTAE_EXE) -q -n
329 ! endif
330 ! ifdef WIN_NE_SETVER_BUILD
331         $(WIN_NE_SETVER_BUILD) $(GDTTAE_EXE)
332 ! endif
333 !endif
334
335 clean: .SYMBOLIC
336           del $(SUBDIR)$(HPS)*.obj
337           del $(HW_CPU_LIB)
338           del tmp.cmd
339           @echo Cleaning done
340