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 #############################################
34 # COMPILER AND LINKER PROGRAMS
36 TOOLSDIR
= $(SRCDIR
)/..
/tools
43 CP
= $(TOOLSDIR
)/rcopy
44 MKDIR
= $(TOOLSDIR
)/rmkdir
45 RMDIR
= $(TOOLSDIR
)/rrmdir
48 DEPTOOL
= $(TOOLSDIR
)/deptool
49 HOSTTOOL
= $(TOOLSDIR
)/hosttype
50 TOOLS
= $(DEPTOOL
) $(HOSTTOOL
)
52 HOST
= $(shell $(HOSTTOOL
))
54 #-----------------------------------------------------------------------------------------------------
55 # TEST IF WE ARE IN THE TARGET DIRECTORY
56 # IF NOT WE WILL CHANGE TO THE TARGET DIRECTORY AND RUN MAKE FROM THERE
57 #-----------------------------------------------------------------------------------------------------
58 #ifeq (,$(filter $(CURDIR)/$(OUTPUT_DIR),$(notdir $(CURDIR))))
59 ifneq ($(CURDIR
), $(SRCDIR
)/$(OUTPUT_DIR
))
65 #############################################
66 # VARIABLE TO CHANGE TO TARGET DIRECTORY AND INVOKE MAKE FROM THERE
68 MAKETARGET
= $(MAKE
) --no-print-directory
-C
$(OUTPUT_DIR
) \
69 -f ..
/..
/Makefile SRCDIR
=$(CURDIR
) $(MAKECMDGOALS
)
71 .PHONY
: CHANGE_TO_TARGET
72 CHANGE_TO_TARGET setupldr
: BUILD_TOOLS
$(OBJDIR
) $(OBJDIR
)/$(TARGET
)
73 @echo Calculating source file dependencies...
78 @
$(MAKE
) --no-print-directory
-C
$(TOOLSDIR
)
81 @echo Creating directory
: $(OBJDIR
)
84 $(OBJDIR
)/$(TARGET
): $(OBJDIR
)
85 @echo Creating directory
: $(OBJDIR
)/$(TARGET
)
86 @
$(MKDIR
) $(OBJDIR
)/$(TARGET
)
93 #############################################
97 @
$(MAKE
) --no-print-directory
-C
$(TOOLSDIR
)
98 @echo Cleaning directory
$(OBJDIR
)/$(TARGET
)
99 @
-$(RM
) $(OBJDIR
)/$(TARGET
)/*
100 @echo Removing directory
$(OBJDIR
)/$(TARGET
)
101 @
-$(RMDIR
) $(OBJDIR
)/$(TARGET
)
103 @echo Clean ALL done.
105 #############################################
107 #-----------------------------------------------------------------------------------------------------
108 # END MAGIC TARGET DIRECTORY CHANGE STUFF
109 #-----------------------------------------------------------------------------------------------------
112 #############################################
113 # COMPILER COMMAND LINE OPTIONS
115 COMPILER_OPTIONS
= -Wall
-nostdlib
-nostdinc
-fno-builtin
-O1
-MD
116 # FreeLoader does not use any of the standard libraries, includes, or built-in functions
118 #############################################
122 COMPILER_DEBUG_DEFINES
= -DDEBUG
124 COMPILER_DEBUG_DEFINES
=
127 ifeq ($(MAKECMDGOALS
),setupldr
)
128 COMPILER_SETUPLDR_DEFINES
= -D__SETUPLDR__
130 COMPILER_SETUPLDR_DEFINES
=
133 COMPILER_DEFINES
= -D__
$(TARGET
)__
$(COMPILER_DEBUG_DEFINES
) $(COMPILER_SETUPLDR_DEFINES
)
135 #############################################
136 # INCLUDE DIRECTORY OPTIONS
138 COMPILER_INCLUDES
= -I
$(SRCDIR
)/include
140 #############################################
143 CFLAGS
= $(COMPILER_OPTIONS
) \
144 $(COMPILER_DEFINES
) \
147 #############################################
148 # LINKER COMMAND LINE OPTIONS
150 #LINKER_OPTIONS = -N -Ttext=0x8000 --oformat=binary -s
151 LINKER_OPTIONS
= -N
-Ttext
=0x8000
153 #############################################
156 LFLAGS
= $(LINKER_OPTIONS
)
158 #############################################
164 ifeq ($(HOST
), win32
)
171 #############################################
172 # LIST ALL THE OBJECT FILE GROUPS
174 # fathelp.o must come first in the link line because it contains bootsector helper code
175 # arch.o must come second in the link line because it contains the startup code
176 ARCH_OBJS
= fathelp.o \
189 RTL_OBJS
= memory.o \
205 REACTOS_OBJS
= reactos.o \
212 COMM_OBJS
= rs232.o \
222 CACHE_OBJS
= cache.o \
225 INIFILE_OBJS
= inifile.o \
229 VIDEO_OBJS
= video.o \
232 # libgcc2.o contains code (__udivdi3, __umoddi3) necessary to do
233 # 64-bit division on the i386 (and other 32-bit) architectures
234 # This code was taken from the GCC v3.1 source
235 MATH_OBJS
= libgcc2.o
237 FREELDR_OBJS
= freeldr.o \
248 #############################################
251 OBJS
= $(ARCH_OBJS
) \
265 #############################################
266 # SET THE VPATH SO MAKE CAN FIND THE SOURCE FILES
269 $(SRCDIR
)/arch
/$(TARGET
) \
283 #############################################
288 #############################################
290 freeldr.sys
: $(OBJS
)
291 @echo
===================================================== LINKING
$@
292 # @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o freeldr.sys $(OBJS)
293 @
$(LD
) $(LFLAGS
) -Map freeldr.map
-o freeldr.exe
$(OBJS
)
294 # @$(CC) -Wl,-Ttext=0x8000,-N,-Map,freeldr.map -o freeldr.exe $(OBJS)
295 @
$(NM
) --numeric-sort freeldr.exe
> freeldr.sym
296 @
$(OBJCOPY
) -O binary freeldr.exe freeldr.sys
298 #############################################
300 setupldr
: setupldr.sys
301 @echo Make SETUPLDR done.
303 #############################################
305 setupldr.sys
: $(OBJS
)
306 @echo
===================================================== LINKING
$@
307 # @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o setupldr.sys $(OBJS)
308 @
$(LD
) $(LFLAGS
) -Map setupldr.map
-o setupldr.exe
$(OBJS
)
309 @
$(NM
) --numeric-sort setupldr.exe
> setupldr.sym
310 @
$(OBJCOPY
) -O binary setupldr.exe setupldr.sys
312 #############################################
315 @echo
===================================================== Compiling
$*
316 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
320 @echo
===================================================== Assembling
$*
321 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
325 @echo
===================================================== Assembling
$*
326 @
$(NASM_CMD
) $(NASMFLAGS
) -o
$@
$<
328 #############################################
330 # Include the automagically generated dependencies
331 -include $(OBJS
:%.o
=%.d
)
333 #############################################