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
-fno-builtin
-O1
-MD
117 #############################################
121 COMPILER_DEBUG_DEFINES
= -DDEBUG
123 COMPILER_DEBUG_DEFINES
=
126 ifeq ($(MAKECMDGOALS
),setupldr
)
127 COMPILER_SETUPLDR_DEFINES
= -D__SETUPLDR__
129 COMPILER_SETUPLDR_DEFINES
=
132 COMPILER_DEFINES
= -D__
$(TARGET
)__
$(COMPILER_DEBUG_DEFINES
) $(COMPILER_SETUPLDR_DEFINES
)
134 #############################################
135 # INCLUDE DIRECTORY OPTIONS
137 COMPILER_INCLUDES
= -I
$(SRCDIR
)/include
139 #############################################
142 CFLAGS
= $(COMPILER_OPTIONS
) \
143 $(COMPILER_DEFINES
) \
146 #############################################
147 # LINKER COMMAND LINE OPTIONS
149 #LINKER_OPTIONS = -N -Ttext=0x8000 --oformat=binary -s
150 LINKER_OPTIONS
= -N
-Ttext
=0x8000
152 #############################################
155 LFLAGS
= $(LINKER_OPTIONS
)
157 #############################################
163 ifeq ($(HOST
), win32
)
170 #############################################
171 # LIST ALL THE OBJECT FILE GROUPS
173 # fathelp.o must come first in the link line because it contains bootsector helper code
174 # arch.o must come second in the link line because it contains the startup code
175 ARCH_OBJS
= fathelp.o \
187 RTL_OBJS
= memory.o \
202 REACTOS_OBJS
= reactos.o \
209 COMM_OBJS
= rs232.o \
219 CACHE_OBJS
= cache.o \
222 INIFILE_OBJS
= inifile.o \
226 VIDEO_OBJS
= video.o \
229 FREELDR_OBJS
= freeldr.o \
239 #############################################
242 OBJS
= $(ARCH_OBJS
) \
255 #############################################
256 # SET THE VPATH SO MAKE CAN FIND THE SOURCE FILES
259 $(SRCDIR
)/arch
/$(TARGET
) \
272 #############################################
277 #############################################
279 freeldr.sys
: $(OBJS
)
280 @echo
===================================================== LINKING
$@
281 # @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o freeldr.sys $(OBJS)
282 @
$(LD
) $(LFLAGS
) -Map freeldr.map
-o freeldr.exe
$(OBJS
)
283 @
$(NM
) --numeric-sort freeldr.exe
> freeldr.sym
284 @
$(OBJCOPY
) -O binary freeldr.exe freeldr.sys
286 #############################################
288 setupldr
: setupldr.sys
289 @echo Make SETUPLDR done.
291 #############################################
293 setupldr.sys
: $(OBJS
)
294 @echo
===================================================== LINKING
$@
295 # @$(LD) -N -Ttext=0x8000 --oformat=binary -s -o setupldr.sys $(OBJS)
296 @
$(LD
) $(LFLAGS
) -Map setupldr.map
-o setupldr.exe
$(OBJS
)
297 @
$(NM
) --numeric-sort setupldr.exe
> setupldr.sym
298 @
$(OBJCOPY
) -O binary setupldr.exe setupldr.sys
300 #############################################
303 @echo
===================================================== Compiling
$*
304 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
308 @echo
===================================================== Assembling
$*
309 @
$(CC
) $(CFLAGS
) -o
$@
-c
$<
313 @echo
===================================================== Assembling
$*
314 @
$(NASM_CMD
) $(NASMFLAGS
) -o
$@
$<
316 #############################################
318 # Include the automagically generated dependencies
319 -include $(OBJS
:%.o
=%.d
)
321 #############################################