1 | #################################################################################################### |
---|
2 | # Makefile to build XTIDE Universal BIOS. # |
---|
3 | # # |
---|
4 | # Valid makefile targets are: # |
---|
5 | # all Removes existing files and builds binary files in \Build (without checksums) # |
---|
6 | # small Builds only binaries smaller than or equal to 8 kiB (without checksums) # |
---|
7 | # large Builds only binaries larger than 8 kiB (without checksums) # |
---|
8 | # custom Builds custom binary without checksum (change DEFINES_CUSTOM / BIOS_SIZE_CUSTOM first) # |
---|
9 | # clean Removes all files from \Build # |
---|
10 | # checksum* Same as 'all' but also applies checksums to the binaries # |
---|
11 | # strings* Compress src\Strings.asm to src\StringsCompressed.asm # |
---|
12 | # unused* Checks if there are any unused functions that can be removed to save space # |
---|
13 | # # |
---|
14 | # * at the end of target name means that Perl is required for the job. # |
---|
15 | # Build directory must be created manually if it does not exist. # |
---|
16 | # # |
---|
17 | # # |
---|
18 | # Following modules can be included or excluded: # |
---|
19 | # MODULE_8BIT_IDE Support for 8-BIT IDE cards like XTIDE # |
---|
20 | # MODULE_8BIT_IDE_ADVANCED Support for memory mapped and DMA based cards like JRIDE and XTCF # |
---|
21 | # MODULE_ADVANCED_ATA Native support for some VLB IDE controllers (requires USE_386) # |
---|
22 | # MODULE_COMPATIBLE_TABLES Support for ill behaving software that tries to access DPT directly # |
---|
23 | # MODULE_BOOT_MENU Boot Menu for selection of drive to boot from # |
---|
24 | # MODULE_EBIOS Enhanced functions for accessing drives over 8.4 GB # |
---|
25 | # MODULE_HOTKEYS Hotkey Bar to boot from any drive # |
---|
26 | # MODULE_IRQ IDE IRQ support # |
---|
27 | # MODULE_SERIAL Virtual hard disks using serial port # |
---|
28 | # MODULE_SERIAL_FLOPPY Virtual floppy drives using serial port (requires MODULE_SERIAL) # |
---|
29 | # MODULE_STRINGS_COMPRESSED Use compressed strings to save space # |
---|
30 | # MODULE_VERY_LATE_INIT Initialize on INT 13h if our INT 19h handler is not called # |
---|
31 | # MODULE_POWER_MANAGEMENT Power Management support # |
---|
32 | # MODULE_WIN9X_CMOS_HACK Hack for Windows 9x compatibility # |
---|
33 | # MODULE_MFM_COMPATIBILITY Restores BDA drive count for MFM controllers that expect to be the # |
---|
34 | # only hard drive controller on the system # |
---|
35 | # # |
---|
36 | # Not modules but these affect the assembly: # |
---|
37 | # ELIMINATE_CGA_SNOW Prevents CGA snowing at the cost of a few bytes # |
---|
38 | # RELOCATE_INT13H_STACK ** Relocates INT 13h stack to beginning of stolen conventional memory # |
---|
39 | # NO_ATAID_VALIDATION *** Excludes code that tries to ensure proper communication with drives # |
---|
40 | # NO_ATAID_CORRECTION Excludes code that corrects illegal CHS values from some CF cards # |
---|
41 | # USE_186 Use instructions supported by 80188/80186 and V20/V30 and later # |
---|
42 | # USE_286 Use instructions supported by 286 and later (defines USE_UNDOC_INTEL)# |
---|
43 | # USE_386 Use instructions supported by 386 and later (defines USE_286) # |
---|
44 | # USE_AT Use features supported on AT and later systems (not available on XT) # |
---|
45 | # USE_UNDOC_INTEL Optimizations for Intel CPU:s - do NOT use on NEC V20/V30/Sony CPU:s # |
---|
46 | # USE_NEC_V Optimizations for use with NEC V20/V30 processors only # |
---|
47 | # CLD_NEEDED Only needed for compatibility with buggy software/BIOSes # |
---|
48 | # # |
---|
49 | # ** AT Builds only (when USE_AT is defined) # |
---|
50 | # *** Use this only when certain known good drives are not being detected (eg WD Caviars) # |
---|
51 | #################################################################################################### |
---|
52 | |
---|
53 | ########################################### |
---|
54 | # Source files and destination executable # |
---|
55 | ########################################### |
---|
56 | |
---|
57 | # Assembly source code file (*.asm): |
---|
58 | SRC_ASM = Src/Main.asm |
---|
59 | |
---|
60 | # Program executable file name without extension: |
---|
61 | PROG = ide |
---|
62 | |
---|
63 | |
---|
64 | ####################################### |
---|
65 | # Destination and include directories # |
---|
66 | ####################################### |
---|
67 | |
---|
68 | # Directory where binary file will be compiled to |
---|
69 | BUILD_DIR = Build |
---|
70 | |
---|
71 | # Subdirectories where included files are: |
---|
72 | HEADERS = Inc/ |
---|
73 | HEADERS += Inc/Controllers/ |
---|
74 | HEADERS += Src/ |
---|
75 | HEADERS += Src/Handlers/ |
---|
76 | HEADERS += Src/Handlers/Int13h/ |
---|
77 | HEADERS += Src/Handlers/Int13h/EBIOS/ |
---|
78 | HEADERS += Src/Handlers/Int13h/Tools/ |
---|
79 | HEADERS += Src/Handlers/Int19h/ |
---|
80 | HEADERS += Src/Device/ |
---|
81 | HEADERS += Src/Device/IDE/ |
---|
82 | HEADERS += Src/Device/MemoryMappedIDE/ |
---|
83 | HEADERS += Src/Device/Serial/ |
---|
84 | HEADERS += Src/Initialization/ |
---|
85 | HEADERS += Src/Initialization/AdvancedAta/ |
---|
86 | HEADERS += Src/Menus/ |
---|
87 | HEADERS += Src/Menus/BootMenu/ |
---|
88 | HEADERS += Src/Libraries/ |
---|
89 | HEADERS += Src/VariablesAndDPTs/ |
---|
90 | |
---|
91 | # Subdirectories where library files are: |
---|
92 | LIBS = ../Assembly_Library/Inc/ |
---|
93 | LIBS += ../Assembly_Library/Src/ |
---|
94 | LIBS += ../Assembly_Library/Src/Display/ |
---|
95 | LIBS += ../Assembly_Library/Src/File/ |
---|
96 | LIBS += ../Assembly_Library/Src/Keyboard/ |
---|
97 | LIBS += ../Assembly_Library/Src/Menu/ |
---|
98 | LIBS += ../Assembly_Library/Src/Menu/Dialog/ |
---|
99 | LIBS += ../Assembly_Library/Src/String/ |
---|
100 | LIBS += ../Assembly_Library/Src/Time/ |
---|
101 | LIBS += ../Assembly_Library/Src/Util/ |
---|
102 | LIBS += ../Assembly_Library/Src/Serial/ |
---|
103 | LIBS += ../XTIDE_Universal_BIOS/Inc/ |
---|
104 | HEADERS += $(LIBS) |
---|
105 | |
---|
106 | |
---|
107 | ################################## |
---|
108 | # Assembler preprocessor defines # |
---|
109 | ################################## |
---|
110 | DEFINES_COMMON = MODULE_STRINGS_COMPRESSED MODULE_HOTKEYS MODULE_8BIT_IDE MODULE_EBIOS MODULE_SERIAL MODULE_SERIAL_FLOPPY MODULE_POWER_MANAGEMENT NO_ATAID_VALIDATION CLD_NEEDED |
---|
111 | DEFINES_COMMON_LARGE = MODULE_BOOT_MENU MODULE_8BIT_IDE_ADVANCED MODULE_COMPATIBLE_TABLES |
---|
112 | |
---|
113 | DEFINES_XT = $(DEFINES_COMMON) ELIMINATE_CGA_SNOW MODULE_8BIT_IDE_ADVANCED |
---|
114 | DEFINES_XTPLUS = $(DEFINES_XT) USE_186 |
---|
115 | DEFINES_AT = $(DEFINES_COMMON) USE_AT USE_286 MODULE_IRQ MODULE_COMPATIBLE_TABLES |
---|
116 | DEFINES_386 = $(DEFINES_AT) USE_386 MODULE_ADVANCED_ATA MODULE_WIN9X_CMOS_HACK |
---|
117 | |
---|
118 | DEFINES_XT_LARGE = $(DEFINES_XT) $(DEFINES_COMMON_LARGE) |
---|
119 | DEFINES_XTPLUS_LARGE = $(DEFINES_XTPLUS) $(DEFINES_COMMON_LARGE) |
---|
120 | DEFINES_AT_LARGE = $(DEFINES_AT) $(DEFINES_COMMON_LARGE) |
---|
121 | DEFINES_386_LARGE = $(DEFINES_386) $(DEFINES_COMMON_LARGE) |
---|
122 | |
---|
123 | DEFINES_XT_TINY = MODULE_STRINGS_COMPRESSED MODULE_8BIT_IDE NO_ATAID_VALIDATION NO_ATAID_CORRECTION CLD_NEEDED |
---|
124 | |
---|
125 | DEFINES_CUSTOM = ? |
---|
126 | |
---|
127 | |
---|
128 | ################### |
---|
129 | # Other variables # |
---|
130 | ################### |
---|
131 | |
---|
132 | # Target size of the BIOS, used in Main.asm for number of 512B blocks (CNT_ROM_BLOCKS) and by checksum Perl script below ('make checksum'). |
---|
133 | # Note! The size must be a multiple of 2 KB for compatibility reasons. |
---|
134 | BIOS_SIZE_TINY = 4096 |
---|
135 | BIOS_SIZE_SMALL = 8192 |
---|
136 | BIOS_SIZE_LARGE = 10240 |
---|
137 | BIOS_SIZE_CUSTOM = ? |
---|
138 | |
---|
139 | # Add -D in front of every preprocessor define declaration |
---|
140 | DEFS_XT = $(DEFINES_XT:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL) |
---|
141 | DEFS_XTPLUS = $(DEFINES_XTPLUS:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL) |
---|
142 | DEFS_AT = $(DEFINES_AT:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL) |
---|
143 | DEFS_XT_LARGE = $(DEFINES_XT_LARGE:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_LARGE) |
---|
144 | DEFS_XTPLUS_LARGE = $(DEFINES_XTPLUS_LARGE:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_LARGE) |
---|
145 | DEFS_AT_LARGE = $(DEFINES_AT_LARGE:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_LARGE) |
---|
146 | DEFS_XT_TINY = $(DEFINES_XT_TINY:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_TINY) |
---|
147 | DEFS_386 = $(DEFINES_386:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_SMALL) |
---|
148 | DEFS_386_LARGE = $(DEFINES_386_LARGE:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_LARGE) |
---|
149 | DEFS_CUSTOM = $(DEFINES_CUSTOM:%=-D%) -DBIOS_SIZE=$(BIOS_SIZE_CUSTOM) |
---|
150 | |
---|
151 | # Add -I in front of all header directories |
---|
152 | IHEADERS = $(HEADERS:%=-I%) |
---|
153 | |
---|
154 | # Path + target file to be built |
---|
155 | TARGET = $(BUILD_DIR)/$(PROG) |
---|
156 | |
---|
157 | |
---|
158 | ######################### |
---|
159 | # Compilers and linkers # |
---|
160 | ######################### |
---|
161 | |
---|
162 | # Make |
---|
163 | MAKE = mingw32-make.exe |
---|
164 | |
---|
165 | # Assembler |
---|
166 | AS = nasm.exe |
---|
167 | |
---|
168 | # use this command to erase files. |
---|
169 | RM = -del /Q |
---|
170 | |
---|
171 | |
---|
172 | ############################# |
---|
173 | # Compiler and linker flags # |
---|
174 | ############################# |
---|
175 | |
---|
176 | # Assembly compiler flags |
---|
177 | ASFLAGS = -f bin # Produce binary object files |
---|
178 | ASFLAGS += $(IHEADERS) # Set header file directory paths |
---|
179 | ASFLAGS += -Worphan-labels # Warn about labels without colon |
---|
180 | ASFLAGS += -Ox # Optimize operands to their shortest forms |
---|
181 | |
---|
182 | |
---|
183 | ############################################ |
---|
184 | # Build process. Actual work is done here. # |
---|
185 | ############################################ |
---|
186 | |
---|
187 | all: clean small large |
---|
188 | @echo All done! |
---|
189 | |
---|
190 | small: xt_tiny xt xtplus at 386 |
---|
191 | @echo All small binaries built! |
---|
192 | |
---|
193 | large: xt_large xtplus_large at_large 386_large |
---|
194 | @echo All large binaries built! |
---|
195 | |
---|
196 | at: |
---|
197 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT) -l"$(TARGET)_at.lst" -o"$(TARGET)_at.bin" |
---|
198 | @echo * Small AT version "$(TARGET)_at.bin" built. |
---|
199 | |
---|
200 | at_large: |
---|
201 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT_LARGE) -l"$(TARGET)_atl.lst" -o"$(TARGET)_atl.bin" |
---|
202 | @echo * Large AT version "$(TARGET)_atl.bin" built. |
---|
203 | |
---|
204 | xtplus: |
---|
205 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS) -l"$(TARGET)_xtp.lst" -o"$(TARGET)_xtp.bin" |
---|
206 | @echo * Small XT Plus version "$(TARGET)_xtp.bin" built. |
---|
207 | |
---|
208 | xtplus_large: |
---|
209 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS_LARGE) -l"$(TARGET)_xtpl.lst" -o"$(TARGET)_xtpl.bin" |
---|
210 | @echo * Large XT Plus version "$(TARGET)_xtpl.bin" built. |
---|
211 | |
---|
212 | xt: |
---|
213 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT) -l"$(TARGET)_xt.lst" -o"$(TARGET)_xt.bin" |
---|
214 | @echo * Small XT version "$(TARGET)_xt.bin" built. |
---|
215 | |
---|
216 | xt_large: |
---|
217 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_LARGE) -l"$(TARGET)_xtl.lst" -o"$(TARGET)_xtl.bin" |
---|
218 | @echo * Large XT version "$(TARGET)_xtl.bin" built. |
---|
219 | |
---|
220 | xt_tiny: |
---|
221 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_TINY) -l"$(TARGET)_tiny.lst" -o"$(TARGET)_tiny.bin" |
---|
222 | @echo * Tiny XT version "$(TARGET)_tiny.bin" built. |
---|
223 | |
---|
224 | 386: |
---|
225 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_386) -l"$(TARGET)_386.lst" -o"$(TARGET)_386.bin" |
---|
226 | @echo * Small 386 version "$(TARGET)_386.bin" built. |
---|
227 | |
---|
228 | 386_large: |
---|
229 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_386_LARGE) -l"$(TARGET)_386l.lst" -o"$(TARGET)_386l.bin" |
---|
230 | @echo * Large 386 version "$(TARGET)_386l.bin" built. |
---|
231 | |
---|
232 | custom: |
---|
233 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_CUSTOM) -l"$(TARGET)_custom.lst" -o"$(TARGET)_custom.bin" |
---|
234 | @echo * Custom version "$(TARGET)_custom.bin" built. |
---|
235 | |
---|
236 | strings: src\Strings.asm |
---|
237 | @$(AS) src\Strings.asm $(ASFLAGS) $(DEFS_AT_LARGE) -DCHECK_FOR_UNUSED_ENTRYPOINTS -DMODULE_STRINGS_COMPRESSED_PRECOMPRESS -o build\Strings.bin -l build\StringsPrecompress.lst |
---|
238 | @perl ..\Tools\StringsCompress.pl < build\StringsPrecompress.lst > src\StringsCompressed.asm |
---|
239 | @echo StringsCompressed.asm updated! |
---|
240 | |
---|
241 | clean: |
---|
242 | @$(RM) $(BUILD_DIR)\*.* |
---|
243 | @echo Deleted "(*.*)" from "$(BUILD_DIR)/" |
---|
244 | |
---|
245 | checksum: all |
---|
246 | @perl ..\Tools\checksum.pl $(TARGET)_tiny.bin $(BIOS_SIZE_TINY) |
---|
247 | @perl ..\Tools\checksum.pl $(TARGET)_xt.bin $(BIOS_SIZE_SMALL) |
---|
248 | @perl ..\Tools\checksum.pl $(TARGET)_xtp.bin $(BIOS_SIZE_SMALL) |
---|
249 | @perl ..\Tools\checksum.pl $(TARGET)_at.bin $(BIOS_SIZE_SMALL) |
---|
250 | @perl ..\Tools\checksum.pl $(TARGET)_xtl.bin $(BIOS_SIZE_LARGE) |
---|
251 | @perl ..\Tools\checksum.pl $(TARGET)_xtpl.bin $(BIOS_SIZE_LARGE) |
---|
252 | @perl ..\Tools\checksum.pl $(TARGET)_atl.bin $(BIOS_SIZE_LARGE) |
---|
253 | @perl ..\Tools\checksum.pl $(TARGET)_386.bin $(BIOS_SIZE_SMALL) |
---|
254 | @perl ..\Tools\checksum.pl $(TARGET)_386l.bin $(BIOS_SIZE_LARGE) |
---|
255 | |
---|
256 | unused: |
---|
257 | @echo "XT Tiny" |
---|
258 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_TINY) -o"$(TARGET)_unused_tiny.asm" -l"$(TARGET)_unused_tiny.lst" |
---|
259 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_TINY) -o"$(TARGET)_unused_tiny.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
260 | @perl ..\Tools\unused.pl $(TARGET)_unused_tiny.lst $(TARGET)_unused_tiny.asm |
---|
261 | @echo "XT Small" |
---|
262 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT) -o"$(TARGET)_unused_xt.asm" -l"$(TARGET)_unused_xt.lst" |
---|
263 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT) -o"$(TARGET)_unused_xt.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
264 | @perl ..\Tools\unused.pl $(TARGET)_unused_xt.lst $(TARGET)_unused_xt.asm |
---|
265 | @echo "XT Large" |
---|
266 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_LARGE) -o"$(TARGET)_unused_xtl.asm" -l"$(TARGET)_unused_xtl.lst" |
---|
267 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT_LARGE) -o"$(TARGET)_unused_xtl.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
268 | @perl ..\Tools\unused.pl $(TARGET)_unused_xtl.lst $(TARGET)_unused_xtl.asm |
---|
269 | @echo "XT Plus Small" |
---|
270 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS) -o"$(TARGET)_unused_xtp.asm" -l"$(TARGET)_unused_xtp.lst" |
---|
271 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS) -o"$(TARGET)_unused_xtp.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
272 | @perl ..\Tools\unused.pl $(TARGET)_unused_xtp.lst $(TARGET)_unused_xtp.asm |
---|
273 | @echo "XT Plus Large" |
---|
274 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS_LARGE) -o"$(TARGET)_unused_xtpl.asm" -l"$(TARGET)_unused_xtpl.lst" |
---|
275 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS_LARGE) -o"$(TARGET)_unused_xtpl.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
276 | @perl ..\Tools\unused.pl $(TARGET)_unused_xtpl.lst $(TARGET)_unused_xtpl.asm |
---|
277 | @echo "AT Small" |
---|
278 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT) -o"$(TARGET)_unused_at.asm" -l"$(TARGET)_unused_at.lst" |
---|
279 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT) -o"$(TARGET)_unused_at.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
280 | @perl ..\Tools\unused.pl $(TARGET)_unused_at.lst $(TARGET)_unused_at.asm |
---|
281 | @echo "AT Large" |
---|
282 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT_LARGE) -o"$(TARGET)_unused_atl.asm" -l"$(TARGET)_unused_atl.lst" |
---|
283 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT_LARGE) -o"$(TARGET)_unused_atl.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
284 | @perl ..\Tools\unused.pl $(TARGET)_unused_atl.lst $(TARGET)_unused_atl.asm |
---|
285 | @echo "386 Small" |
---|
286 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_386) -o"$(TARGET)_unused_386.asm" -l"$(TARGET)_unused_386.lst" |
---|
287 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_386) -o"$(TARGET)_unused_386.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
288 | @perl ..\Tools\unused.pl $(TARGET)_unused_386.lst $(TARGET)_unused_386.asm |
---|
289 | @echo "386 Large" |
---|
290 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_386_LARGE) -o"$(TARGET)_unused_386l.asm" -l"$(TARGET)_unused_386l.lst" |
---|
291 | @$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_386_LARGE) -o"$(TARGET)_unused_386l.asm" -E -DCHECK_FOR_UNUSED_ENTRYPOINTS |
---|
292 | @perl ..\Tools\unused.pl $(TARGET)_unused_386l.lst $(TARGET)_unused_386l.asm |
---|
293 | |
---|