3 # Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
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.
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.
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.
20 #############################################
21 # CHANGE THESE FOR YOUR OUTPUT
24 # Debugging information on (bigger binary)
26 # Debugging information off (smaller binary)
30 OUTPUT_DIR
= $(OBJDIR
)/$(TARGET
)
32 BOOTCD_DIR
= ..
/..
/bootcd
34 #############################################
35 # COMPILER AND LINKER PROGRAMS
37 TOOLSDIR
= $(SRCDIR
)/..
/tools
39 RM
= $(subst /,$(SEP
),$(TOOLSDIR
))$(SEP
)rdel
40 CP
= $(subst /,$(SEP
),$(TOOLSDIR
))$(SEP
)rcopy
41 MKDIR
= $(subst /,$(SEP
),$(TOOLSDIR
))$(SEP
)rmkdir
42 RMDIR
= $(subst /,$(SEP
),$(TOOLSDIR
))$(SEP
)rrmdir
44 DEPTOOL
= $(subst /,$(SEP
),$(TOOLSDIR
))$(SEP
)deptool
45 HOSTTOOL
= $(subst /,$(SEP
),$(TOOLSDIR
))$(SEP
)hosttype
46 TOOLS
= $(DEPTOOL
) $(HOSTTOOL
)
48 HOSTTYPE
= $(shell $(HOSTTOOL
))
50 #-----------------------------------------------------------------------------------------------------
51 # TEST IF WE ARE IN THE TARGET DIRECTORY
52 # IF NOT WE WILL CHANGE TO THE TARGET DIRECTORY AND RUN MAKE FROM THERE
53 #-----------------------------------------------------------------------------------------------------
54 #ifeq (,$(filter $(CURDIR)/$(OUTPUT_DIR),$(notdir $(CURDIR))))
55 ifneq ($(CURDIR
), $(SRCDIR
)/$(OUTPUT_DIR
))
61 #############################################
62 # VARIABLE TO CHANGE TO TARGET DIRECTORY AND INVOKE MAKE FROM THERE
64 MAKETARGET
= $(MAKE
) --no-print-directory
-C
$(OUTPUT_DIR
) \
65 -f ..
/..
/Makefile SRCDIR
=$(CURDIR
) $(MAKECMDGOALS
)
67 .PHONY
: CHANGE_TO_TARGET
68 CHANGE_TO_TARGET setupldr
: BUILD_TOOLS
$(OBJDIR
) $(OBJDIR
)/$(TARGET
)
69 @echo Calculating source file dependencies...
74 @
$(MAKE
) --no-print-directory
-C
$(TOOLSDIR
)
77 @echo Creating directory
: $(OBJDIR
)
80 $(OBJDIR
)/$(TARGET
): $(OBJDIR
)
81 @echo Creating directory
: $(OBJDIR
)/$(TARGET
)
82 @
$(MKDIR
) $(OBJDIR
)/$(TARGET
)
89 #############################################
93 @
$(MAKE
) --no-print-directory
-C
$(TOOLSDIR
)
94 @echo Cleaning directory
$(OBJDIR
)/$(TARGET
)
95 @
-$(RM
) $(OBJDIR
)/$(TARGET
)/*
96 @echo Removing directory
$(OBJDIR
)/$(TARGET
)
97 @
-$(RMDIR
) $(OBJDIR
)/$(TARGET
)
101 #############################################
104 bootcd
: bootcd_dirs setup_loader boot_loader
108 $(MKDIR
) $(BOOTCD_DIR
)
109 $(MKDIR
) $(BOOTCD_DIR
)/disk
110 $(MKDIR
) $(BOOTCD_DIR
)/disk
/reactos
111 $(MKDIR
) $(BOOTCD_DIR
)/disk
/install
112 $(MKDIR
) $(BOOTCD_DIR
)/disk
/bootdisk
113 $(MKDIR
) $(BOOTCD_DIR
)/disk
/loader
116 boot_loader
: $(OBJDIR
)/$(TARGET
)/freeldr.sys
117 $(CP
) $(OBJDIR
)/$(TARGET
)/freeldr.sys
$(BOOTCD_DIR
)/disk
/loader
/freeldr.sys
118 $(CP
) ..
/freeldr.ini
$(BOOTCD_DIR
)/disk
/loader
/freeldr.ini
120 .PHONY
: setup_loader
121 setup_loader
: $(OBJDIR
)/$(TARGET
)/setupldr.sys
122 $(CP
) $(OBJDIR
)/$(TARGET
)/setupldr.sys
$(BOOTCD_DIR
)/disk
/loader
/setupldr.sys
124 #############################################
126 #-----------------------------------------------------------------------------------------------------
127 # END MAGIC TARGET DIRECTORY CHANGE STUFF
128 #-----------------------------------------------------------------------------------------------------
131 #############################################
132 # COMPILER COMMAND LINE OPTIONS
134 COMPILER_OPTIONS
= -Wall
-nostdlib
-nostdinc
-ffreestanding
-fno-builtin
-fno-inline \
135 -fno-zero-initialized-in-bss
-O1
-MD
136 # FreeLoader does not use any of the standard libraries, includes, or built-in functions
138 #############################################
142 COMPILER_DEBUG_DEFINES
= -DDEBUG
144 COMPILER_DEBUG_DEFINES
=
147 COMPILER_DEFINES
= -D__
$(TARGET
)__
$(COMPILER_DEBUG_DEFINES
)
149 #############################################
150 # INCLUDE DIRECTORY OPTIONS
152 COMPILER_INCLUDES
= -I
$(SRCDIR
)/include
154 #############################################
157 CFLAGS
= $(COMPILER_OPTIONS
) \
158 $(COMPILER_DEFINES
) \
161 #############################################
162 # LINKER COMMAND LINE OPTIONS
164 #LINKER_OPTIONS = -N -Ttext=0x8000 --oformat=binary -s
165 LINKER_OPTIONS
= -N
-Ttext
=0x8000
167 #############################################
170 LFLAGS
= $(LINKER_OPTIONS
)
172 #############################################
175 ifeq ($(HOSTTYPE
), dos
)
178 ifeq ($(HOSTTYPE
), win32
)
185 #############################################
186 # LIST ALL THE OBJECT FILE GROUPS
188 # fathelp.o must come first in the link line because it contains bootsector helper code
189 # arch.o must come second in the link line because it contains the startup code
190 ARCH_OBJS
= fathelp.o \
209 _alloca.o
# For Mingw32 builds
233 REACTOS_OBJS
= arcname.o \
246 CACHE_OBJS
= cache.o \
249 INIFILE_OBJS
= inifile.o \
253 INFFILE_OBJS
= inffile.o
255 VIDEO_OBJS
= video.o \
262 # libgcc2.o contains code (__udivdi3, __umoddi3) necessary to do
263 # 64-bit division on the i386 (and other 32-bit) architectures
264 # This code was taken from the GCC v3.1 source
265 MATH_OBJS
= libgcc2.o
267 BASE_OBJS
= freeldr.o \
272 FREELDR_OBJS
= bootmgr.o \
280 ROSLDR_OBJS
= reactos.o
282 SETUPLDR_OBJS
= setupldr.o
284 COMMON_OBJS
= $(ARCH_OBJS
) \
297 SPECIAL_OBJS
= $(INIFILE_OBJS
) \
304 F_OBJS
= $(COMMON_OBJS
) \
309 S_OBJS
= $(COMMON_OBJS
) \
315 #############################################
318 ALL_OBJS
= $(COMMON_OBJS
) \
322 #############################################
323 # SET THE VPATH SO MAKE CAN FIND THE SOURCE FILES
326 $(SRCDIR
)/arch
/$(TARGET
) \
341 #############################################
343 all : freeldr.sys setupldr.sys
346 #############################################
348 freeldr.sys
: $(ALL_OBJS
)
349 @echo
===================================================== LINKING
$@
350 # @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o freeldr.sys $(F_OBJS)
351 @
$(LD
) $(LFLAGS
) -Map freeldr.map
-o freeldr.exe
$(F_OBJS
)
352 # @$(CC) -Wl,-Ttext=0x8000,-N,-Map,freeldr.map -o freeldr.exe $(F_OBJS)
353 @
$(NM
) --numeric-sort freeldr.exe
> freeldr.sym
354 @
$(OBJCOPY
) -O binary freeldr.exe freeldr.sys
356 #############################################
358 setupldr.sys
: $(ALL_OBJS
)
359 @echo
===================================================== LINKING
$@
360 @
$(LD
) $(LFLAGS
) -Map setupldr.map
-o setupldr.exe
$(S_OBJS
)
361 @
$(NM
) --numeric-sort setupldr.exe
> setupldr.sym
362 @
$(OBJCOPY
) -O binary setupldr.exe setupldr.sys
364 #############################################
367 @echo
===================================================== Compiling
$*
368 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
372 @echo
===================================================== Assembling
$*
373 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
377 @echo
===================================================== Assembling
$*
378 @
$(NASM_CMD
) $(NASMFLAGS
) -o
$@
$<
380 #############################################
382 # Include the automagically generated dependencies
383 -include $(ALL_OBJS
:%.o
=%.d
)
385 #############################################