Patch by tinus: clean up long lines of = outputted by freeldr build.
[reactos.git] / reactos / boot / freeldr / freeldr / Makefile
1 #
2 # FreeLoader
3 # Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19
20 PATH_TO_TOP = ../../..
21
22 include ../rules.mak
23
24 TARGET = i386
25 ifeq ($(DEBUG),)
26 # Debugging information on (bigger binary)
27 #DEBUG = yes
28 # Debugging information off (smaller binary)
29 DEBUG = no
30 endif
31
32 SRCDIR = .
33
34 BOOTCD_DIR = $(PATH_TO_TOP)/bootcd
35
36 TOOLSDIR = $(SRCDIR)/../tools
37
38 DEPTOOL = $(subst /,$(SEP),$(FREELDR_TOOLS_PATH))$(SEP)deptool
39 TOOLS = $(DEPTOOL)
40
41 preall : all
42
43 .PHONY: BUILD_TOOLS
44 BUILD_TOOLS:
45 @$(MAKE) --no-print-directory -C $(FREELDR_TOOLS_PATH)
46
47 #############################################
48
49 .PHONY : clean
50 clean:
51 @-$(RM) $(ALL_OBJS)
52 @-$(RM) $(ALL_OBJS:.o=.d)
53 @-$(RM) freeldr.exe
54 @-$(RM) freeldr.sys
55 @-$(RM) freeldr.map
56 @-$(RM) setupldr.exe
57 @-$(RM) setupldr.sys
58 @-$(RM) setupldr.map
59 @$(MAKE) --no-print-directory -C $(FREELDR_TOOLS_PATH)
60 @echo freeldr: Clean ALL done.
61
62 #############################################
63
64 .PHONY : bootcd
65 bootcd : bootcd_dirs setup_loader boot_loader
66
67 .PHONY : bootcd_dirs
68 bootcd_dirs:
69 $(MKDIR) $(BOOTCD_DIR)
70 $(MKDIR) $(BOOTCD_DIR)/disk
71 $(MKDIR) $(BOOTCD_DIR)/disk/reactos
72 $(MKDIR) $(BOOTCD_DIR)/disk/install
73 $(MKDIR) $(BOOTCD_DIR)/disk/bootdisk
74 $(MKDIR) $(BOOTCD_DIR)/disk/loader
75
76 .PHONY : boot_loader
77 boot_loader : freeldr.sys
78 $(CP) freeldr.sys $(BOOTCD_DIR)/disk/loader/freeldr.sys
79 $(CP) ../freeldr.ini $(BOOTCD_DIR)/disk/loader/freeldr.ini
80
81 .PHONY : setup_loader
82 setup_loader : setupldr.sys
83 $(CP) setupldr.sys $(BOOTCD_DIR)/disk/loader/setupldr.sys
84
85
86 COMPILER_OPTIONS = -Wall -Werror -nostdlib -ffreestanding -fno-builtin -fno-inline \
87 -fno-zero-initialized-in-bss -O1 -MD
88 # FreeLoader does not use any of the standard libraries, includes, or built-in functions
89
90 ifeq ($(DEBUG),yes)
91 COMPILER_DEBUG_DEFINES = -DDEBUG
92 else
93 COMPILER_DEBUG_DEFINES =
94 endif
95
96 COMPILER_DEFINES = -D__$(TARGET)__ $(COMPILER_DEBUG_DEFINES)
97
98 COMPILER_INCLUDES = -I$(SRCDIR)/include -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/ntoskrnl/include
99
100 CFLAGS = $(COMPILER_OPTIONS) \
101 $(COMPILER_DEFINES) \
102 $(COMPILER_INCLUDES)
103
104 LINKER_OPTIONS = -N -Ttext=0x8000
105
106 LFLAGS = $(LINKER_OPTIONS)
107
108 ifeq ($(HOST),mingw32-linux)
109 NASMFLAGS = -f win32
110 else
111 NASMFLAGS = -f elf
112 endif
113
114 # fathelp.o must come first in the link line because it contains bootsector helper code
115 # arch.o must come second in the link line because it contains the startup code
116 ARCH_I386_OBJS = fathelp.o \
117 arch.o \
118 i386idt.o \
119 i386trap.o \
120 i386cpu.o \
121 i386pnp.o \
122 boot.o \
123 linux.o \
124 mb.o \
125 i386rtl.o \
126 i386vid.o \
127 drvmap.o \
128 int386.o \
129 i386disk.o \
130 portio.o \
131 hardware.o \
132 hwacpi.o \
133 hwapm.o \
134 hwcpu.o \
135 hwpci.o \
136 archmach.o \
137 machpc.o \
138 machxbox.o \
139 pccons.o \
140 pcdisk.o \
141 pcmem.o \
142 pcrtc.o \
143 pcvideo.o \
144 xboxcons.o \
145 xboxdisk.o \
146 xboxfont.o \
147 xboxhw.o \
148 xboxmem.o \
149 xboxrtc.o \
150 xboxvideo.o \
151 _alloca.o # For Mingw32 builds
152
153 ARCH_OBJS = $(addprefix i386/,$(ARCH_I386_OBJS))
154
155 RTL_OBJS = print.o \
156 stdlib.o \
157 string.o \
158 list.o \
159 memcmp.o \
160 memcpy.o \
161 memmove.o \
162 memset.o
163
164 FS_OBJS = fs.o \
165 fat.o \
166 iso.o \
167 ext2.o \
168 ntfs.o \
169 fsrec.o
170
171 UI_OBJS = tui.o \
172 tuimenu.o \
173 ui.o \
174 gui.o
175
176 REACTOS_OBJS = arcname.o \
177 binhive.o \
178 registry.o
179
180 COMM_OBJS = rs232.o
181
182 DISK_OBJS = disk.o \
183 partition.o
184
185 MM_OBJS = mm.o \
186 meminit.o
187
188 CACHE_OBJS = cache.o \
189 blocklist.o
190
191 INIFILE_OBJS = inifile.o \
192 ini_init.o \
193 parse.o
194
195 INFFILE_OBJS = inffile.o
196
197 VIDEO_OBJS = video.o \
198 fade.o \
199 palette.o \
200 pixel.o \
201 bank.o
202
203 # libgcc2.o contains code (__udivdi3, __umoddi3) necessary to do
204 # 64-bit division on the i386 (and other 32-bit) architectures
205 # This code was taken from the GCC v3.1 source
206 MATH_OBJS = libgcc2.o
207
208 BASE_OBJS = freeldr.o \
209 debug.o \
210 multiboot.o \
211 version.o \
212 cmdline.o \
213 machine.o
214
215 FREELDR_OBJS = bootmgr.o \
216 drivemap.o \
217 miscboot.o \
218 options.o \
219 linuxboot.o \
220 oslist.o \
221 custom.o
222
223 ROSLDR_OBJS = reactos.o
224
225 SETUPLDR_OBJS = setupldr.o
226
227 COMMON_OBJS = $(addprefix arch/,$(ARCH_OBJS)) \
228 $(addprefix rtl/,$(RTL_OBJS)) \
229 $(addprefix fs/,$(FS_OBJS)) \
230 $(addprefix ui/,$(UI_OBJS)) \
231 $(addprefix reactos/,$(REACTOS_OBJS)) \
232 $(addprefix comm/,$(COMM_OBJS)) \
233 $(addprefix disk/,$(DISK_OBJS)) \
234 $(addprefix mm/,$(MM_OBJS)) \
235 $(addprefix cache/,$(CACHE_OBJS)) \
236 $(addprefix video/,$(VIDEO_OBJS)) \
237 $(addprefix math/,$(MATH_OBJS)) \
238 $(BASE_OBJS)
239
240 SPECIAL_OBJS = $(addprefix inifile/,$(INIFILE_OBJS)) \
241 $(addprefix inffile/,$(INFFILE_OBJS)) \
242 $(FREELDR_OBJS) \
243 $(addprefix reactos/,$(ROSLDR_OBJS)) \
244 $(addprefix reactos/,$(SETUPLDR_OBJS))
245
246 F_OBJS = $(COMMON_OBJS) \
247 $(addprefix inifile/,$(INIFILE_OBJS)) \
248 $(addprefix reactos/,$(ROSLDR_OBJS)) \
249 $(FREELDR_OBJS)
250
251 S_OBJS = $(COMMON_OBJS) \
252 $(addprefix inifile/,$(INIFILE_OBJS)) \
253 $(addprefix inffile/,$(INFFILE_OBJS)) \
254 $(addprefix reactos/,$(SETUPLDR_OBJS))
255
256
257 ALL_OBJS = $(COMMON_OBJS) \
258 $(SPECIAL_OBJS)
259
260
261 all : freeldr.sys setupldr.sys
262 @echo freeldr: Make ALL done.
263
264
265 freeldr.sys : $(ALL_OBJS) $(PATH_TO_TOP)/dk/w32/lib/librossym.a
266 @echo freeldr: LINKING $@
267 @$(LD) $(LFLAGS) -o freeldr.exe $(F_OBJS) $(PATH_TO_TOP)/dk/w32/lib/librossym.a
268 ifeq ($(FULL_MAP),yes)
269 @$(OBJDUMP) -d -S freeldr.exe > freeldr.map
270 else
271 @$(NM) --numeric-sort freeldr.exe > freeldr.map
272 endif
273 @$(OBJCOPY) -O binary freeldr.exe freeldr.sys
274
275
276 setupldr.sys : $(ALL_OBJS)
277 @echo freeldr: LINKING $@
278 @$(LD) $(LFLAGS) -Map setupldr.map -o setupldr.exe $(S_OBJS)
279 ifeq ($(FULL_MAP),yes)
280 @$(OBJDUMP) -d -S setupldr.exe > setupldr.map
281 else
282 @$(NM) --numeric-sort setupldr.exe > setupldr.map
283 endif
284 @$(OBJCOPY) -O binary setupldr.exe setupldr.sys
285
286
287 %.o :: %.c
288 @echo freeldr: Compiling $*
289 @$(CC) $(CFLAGS) -o $@ -c $<
290 @$(DEPTOOL) $*.d
291
292 %.o :: %.S
293 @echo freeldr: Assembling $*
294 @$(CC) $(CFLAGS) -o $@ -c $<
295 @$(DEPTOOL) $*.d
296
297 %.o :: %.asm
298 @echo freeldr: Assembling $*
299 @$(NASM_CMD) $(NASMFLAGS) -o $@ $<