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.
21 #############################################
22 # CHANGE THESE FOR YOUR OUTPUT
25 # Debugging information on (bigger binary)
27 # Debugging information off (smaller binary)
31 OUTPUT_DIR
= $(OBJDIR
)/$(TARGET
)
33 BOOTCD_DIR
= ..
/..
/bootcd
35 #############################################
36 # COMPILER AND LINKER PROGRAMS
38 TOOLSDIR
= $(SRCDIR
)/..
/tools
45 CP
= $(TOOLSDIR
)/rcopy
46 MKDIR
= $(TOOLSDIR
)/rmkdir
47 RMDIR
= $(TOOLSDIR
)/rrmdir
50 DEPTOOL
= $(TOOLSDIR
)/deptool
51 HOSTTOOL
= $(TOOLSDIR
)/hosttype
52 TOOLS
= $(DEPTOOL
) $(HOSTTOOL
)
54 HOST
= $(shell $(HOSTTOOL
))
56 #-----------------------------------------------------------------------------------------------------
57 # TEST IF WE ARE IN THE TARGET DIRECTORY
58 # IF NOT WE WILL CHANGE TO THE TARGET DIRECTORY AND RUN MAKE FROM THERE
59 #-----------------------------------------------------------------------------------------------------
60 #ifeq (,$(filter $(CURDIR)/$(OUTPUT_DIR),$(notdir $(CURDIR))))
61 ifneq ($(CURDIR
), $(SRCDIR
)/$(OUTPUT_DIR
))
67 #############################################
68 # VARIABLE TO CHANGE TO TARGET DIRECTORY AND INVOKE MAKE FROM THERE
70 MAKETARGET
= $(MAKE
) --no-print-directory
-C
$(OUTPUT_DIR
) \
71 -f ..
/..
/Makefile SRCDIR
=$(CURDIR
) $(MAKECMDGOALS
)
73 .PHONY
: CHANGE_TO_TARGET
74 CHANGE_TO_TARGET setupldr
: BUILD_TOOLS
$(OBJDIR
) $(OBJDIR
)/$(TARGET
)
75 @echo Calculating source file dependencies...
80 @
$(MAKE
) --no-print-directory
-C
$(TOOLSDIR
)
83 @echo Creating directory
: $(OBJDIR
)
86 $(OBJDIR
)/$(TARGET
): $(OBJDIR
)
87 @echo Creating directory
: $(OBJDIR
)/$(TARGET
)
88 @
$(MKDIR
) $(OBJDIR
)/$(TARGET
)
95 #############################################
99 @
$(MAKE
) --no-print-directory
-C
$(TOOLSDIR
)
100 @echo Cleaning directory
$(OBJDIR
)/$(TARGET
)
101 @
-$(RM
) $(OBJDIR
)/$(TARGET
)/*
102 @echo Removing directory
$(OBJDIR
)/$(TARGET
)
103 @
-$(RMDIR
) $(OBJDIR
)/$(TARGET
)
105 @echo Clean ALL done.
107 #############################################
110 bootcd
: bootcd_dirs
$(OBJDIR
)/$(TARGET
)/setupldr.sys
111 $(CP
) $(OBJDIR
)/$(TARGET
)/setupldr.sys
$(BOOTCD_DIR
)/disk
/reactos
/setupldr.sys
116 $(MKDIR
) $(BOOTCD_DIR
)
117 $(MKDIR
) $(BOOTCD_DIR
)/disk
118 $(MKDIR
) $(BOOTCD_DIR
)/disk
/reactos
119 $(MKDIR
) $(BOOTCD_DIR
)/disk
/install
120 $(MKDIR
) $(BOOTCD_DIR
)/disk
/bootdisk
123 #############################################
125 #-----------------------------------------------------------------------------------------------------
126 # END MAGIC TARGET DIRECTORY CHANGE STUFF
127 #-----------------------------------------------------------------------------------------------------
130 #############################################
131 # COMPILER COMMAND LINE OPTIONS
133 COMPILER_OPTIONS
= -Wall
-nostdlib
-nostdinc
-fno-builtin
-O1
-MD
134 # FreeLoader does not use any of the standard libraries, includes, or built-in functions
136 #############################################
140 COMPILER_DEBUG_DEFINES
= -DDEBUG
142 COMPILER_DEBUG_DEFINES
=
145 COMPILER_DEFINES
= -D__
$(TARGET
)__
$(COMPILER_DEBUG_DEFINES
)
147 #############################################
148 # INCLUDE DIRECTORY OPTIONS
150 COMPILER_INCLUDES
= -I
$(SRCDIR
)/include
152 #############################################
155 CFLAGS
= $(COMPILER_OPTIONS
) \
156 $(COMPILER_DEFINES
) \
159 #############################################
160 # LINKER COMMAND LINE OPTIONS
162 #LINKER_OPTIONS = -N -Ttext=0x8000 --oformat=binary -s
163 LINKER_OPTIONS
= -N
-Ttext
=0x8000
165 #############################################
168 LFLAGS
= $(LINKER_OPTIONS
)
170 #############################################
176 ifeq ($(HOST
), win32
)
183 #############################################
184 # LIST ALL THE OBJECT FILE GROUPS
186 # fathelp.o must come first in the link line because it contains bootsector helper code
187 # arch.o must come second in the link line because it contains the startup code
188 ARCH_OBJS
= fathelp.o \
201 RTL_OBJS
= memory.o \
217 REACTOS_OBJS
= reactos.o \
223 COMM_OBJS
= rs232.o \
233 CACHE_OBJS
= cache.o \
236 INIFILE_OBJS
= inifile.o \
240 VIDEO_OBJS
= video.o \
243 # libgcc2.o contains code (__udivdi3, __umoddi3) necessary to do
244 # 64-bit division on the i386 (and other 32-bit) architectures
245 # This code was taken from the GCC v3.1 source
246 MATH_OBJS
= libgcc2.o
248 BASE_OBJS
= freeldr.o \
254 FREELDR_OBJS
= bootmgr.o \
260 SETUPLDR_OBJS
= setupldr.o
262 COMMON_OBJS
= $(ARCH_OBJS
) \
276 F_OBJS
= $(COMMON_OBJS
) \
279 S_OBJS
= $(COMMON_OBJS
) \
282 #############################################
285 ALL_OBJS
= $(COMMON_OBJS
) \
290 #############################################
291 # SET THE VPATH SO MAKE CAN FIND THE SOURCE FILES
294 $(SRCDIR
)/arch
/$(TARGET
) \
308 #############################################
310 all : freeldr.sys setupldr.sys
313 #############################################
315 freeldr.sys
: $(ALL_OBJS
)
316 @echo
===================================================== LINKING
$@
317 # @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o freeldr.sys $(F_OBJS)
318 @
$(LD
) $(LFLAGS
) -Map freeldr.map
-o freeldr.exe
$(F_OBJS
)
319 # @$(CC) -Wl,-Ttext=0x8000,-N,-Map,freeldr.map -o freeldr.exe $(F_OBJS)
320 @
$(NM
) --numeric-sort freeldr.exe
> freeldr.sym
321 @
$(OBJCOPY
) -O binary freeldr.exe freeldr.sys
323 #############################################
325 setupldr.sys
: $(ALL_OBJS
)
326 @echo
===================================================== LINKING
$@
327 # @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o setupldr.sys $(S_OBJS)
328 @
$(LD
) $(LFLAGS
) -Map setupldr.map
-o setupldr.exe
$(S_OBJS
)
329 @
$(NM
) --numeric-sort setupldr.exe
> setupldr.sym
330 @
$(OBJCOPY
) -O binary setupldr.exe setupldr.sys
332 #############################################
335 @echo
===================================================== Compiling
$*
336 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
340 @echo
===================================================== Assembling
$*
341 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
345 @echo
===================================================== Assembling
$*
346 @
$(NASM_CMD
) $(NASMFLAGS
) -o
$@
$<
348 #############################################
350 # Include the automagically generated dependencies
351 -include $(ALL_OBJS
:%.o
=%.d
)
353 #############################################