1 # Initialise variables that get added to throughout the various Makefiles
3 MAKEDEPS
:= Makefile .toolcheck
12 # Grab the central Config file.
17 # Location to place generated files
21 # If no architecture is specified in Config or on the command-line,
22 # use that of the build machine.
25 ARCH
:= $(shell uname
-m | sed
-e s
,i
[3456789]86,i386
,)
28 # handle x86_64 like i386, but set -m32 option for 32bit code only
33 LDFLAGS
+= -m elf_i386
36 # Drag in architecture-specific Config
38 MAKEDEPS
+= arch
/$(ARCH
)/Config
39 include arch
/$(ARCH
)/Config
41 # If invoked with no build target, print out a helpfully suggestive
44 noargs
: blib
$(BIN
)/NIC
$(BIN
)/gpxe.dsk
$(BIN
)/gpxe.iso
$(BIN
)/gpxe.usb
45 @
$(ECHO
) '==========================================================='
47 @
$(ECHO
) 'To create a bootable floppy, type'
48 @
$(ECHO
) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
49 @
$(ECHO
) 'where /dev/fd0 is your floppy drive. This will erase any'
50 @
$(ECHO
) 'data already on the disk.'
52 @
$(ECHO
) 'To create a bootable USB key, type'
53 @
$(ECHO
) ' cat $(BIN)/gpxe.usb > /dev/sdX'
54 @
$(ECHO
) 'where /dev/sdX is your USB key, and is *not* a real hard'
55 @
$(ECHO
) 'disk on your system. This will erase any data already on'
56 @
$(ECHO
) 'the USB key.'
58 @
$(ECHO
) 'To create a bootable CD-ROM, burn the ISO image '
59 @
$(ECHO
) '$(BIN)/gpxe.iso to a blank CD-ROM.'
61 @
$(ECHO
) 'These images contain drivers for all supported cards. You'
62 @
$(ECHO
) 'can build more customised images, and ROM images, using'
63 @
$(ECHO
) ' make bin/<rom-name>.<output-format>'
65 @
$(ECHO
) '==========================================================='
67 # Locations of utilities
71 CPP ?
= gcc
-E
-Wp
,-Wall
77 CC ?
= $(CROSS_COMPILE
)gcc
78 AS ?
= $(CROSS_COMPILE
)as
79 LD ?
= $(CROSS_COMPILE
)ld
80 SIZE ?
= $(CROSS_COMPILE
)size
81 AR ?
= $(CROSS_COMPILE
)ar
82 RANLIB ?
= $(CROSS_COMPILE
)ranlib
83 OBJCOPY ?
= $(CROSS_COMPILE
)objcopy
84 NM ?
= $(CROSS_COMPILE
)nm
85 OBJDUMP ?
= $(CROSS_COMPILE
)objdump
86 PARSEROM ?
= $(PERL
) .
/util
/parserom.pl
87 MAKEROM ?
= $(PERL
) .
/util
/makerom.pl
88 MKCONFIG ?
= $(PERL
) .
/util
/mkconfig.pl
89 SYMCHECK ?
= $(PERL
) .
/util
/symcheck.pl
90 SORTOBJDUMP ?
= $(PERL
) .
/util
/sortobjdump.pl
97 CFLAGS
+= -I
include -I arch
/$(ARCH
)/include -I .
-DARCH
=$(ARCH
)
98 CFLAGS
+= -Os
-ffreestanding
101 CFLAGS
+= $(EXTRA_CFLAGS
)
102 ASFLAGS
+= $(EXTRA_ASFLAGS
)
103 LDFLAGS
+= $(EXTRA_LDFLAGS
)
105 ifneq ($(NO_WERROR
),1)
109 # CFLAGS for specific object types
112 CFLAGS_S
+= -DASSEMBLY
114 # Base object name of the current target
116 OBJECT
= $(firstword $(subst .
, ,$(@F
)))
118 # CFLAGS for specific object files. You can define
119 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
120 # compiling bin/rtl8139.o.
122 OBJ_CFLAGS
= $(CFLAGS_
$(OBJECT
)) -DOBJECT
=$(subst -,_
,$(OBJECT
))
124 @
$(ECHO
) $(OBJ_CFLAGS
)
126 # Rules for specific object types.
128 COMPILE_c
= $(CC
) $(CFLAGS
) $(CFLAGS_c
) $(OBJ_CFLAGS
)
129 RULE_c
= $(Q
)$(COMPILE_c
) -c
$< -o
$@
130 RULE_c_to_dbg
%.o
= $(Q
)$(COMPILE_c
) -Ddebug_
$(OBJECT
)=$* -c
$< -o
$@
131 RULE_c_to_c
= $(Q
)$(COMPILE_c
) -E
-c
$< > $@
132 RULE_c_to_s
= $(Q
)$(COMPILE_c
) -S
-g0
-c
$< -o
$@
134 PREPROCESS_S
= $(CPP
) $(CFLAGS
) $(CFLAGS_S
) $(OBJ_CFLAGS
)
135 ASSEMBLE_S
= $(AS
) $(ASFLAGS
)
136 RULE_S
= $(Q
)$(PREPROCESS_S
) $< |
$(ASSEMBLE_S
) -o
$@
137 RULE_S_to_s
= $(Q
)$(PREPROCESS_S
) $< > $@
139 DEBUG_TARGETS
+= dbg
%.o c s
141 # SRCDIRS lists all directories containing source files.
146 SRCDIRS
+= net net
/tcp net
/udp
148 SRCDIRS
+= drivers
/bus
149 SRCDIRS
+= drivers
/net
150 SRCDIRS
+= drivers
/net
/e1000
151 SRCDIRS
+= drivers
/block
152 SRCDIRS
+= drivers
/scsi
153 SRCDIRS
+= drivers
/ata
154 SRCDIRS
+= drivers
/nvs
155 SRCDIRS
+= drivers
/bitbash
156 SRCDIRS
+= drivers
/infiniband
157 SRCDIRS
+= interface
/pxe
159 SRCDIRS
+= crypto crypto
/axtls crypto
/matrixssl
160 SRCDIRS
+= hci hci
/commands hci
/tui
161 SRCDIRS
+= hci
/mucurses hci
/mucurses
/widgets
164 # NON_AUTO_SRCS lists files that are excluded from the normal
165 # automatic build system.
167 NON_AUTO_SRCS
+= core
/elf_loader.c
168 NON_AUTO_SRCS
+= drivers
/net
/prism2.c
170 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
171 # the automatic build system and varies by target; it includes the
172 # "-p 0x1234,0x5678" string to set the PCI IDs.
174 FINALISE_rom
= $(MAKEROM
) $(MAKEROM_FLAGS
) $(TGT_MAKEROM_FLAGS
) \
177 # Some ROMs require specific flags to be passed to makerom.pl
179 MAKEROM_FLAGS_3c503
= -3
181 # Drag in architecture-specific Makefile
183 MAKEDEPS
+= arch
/$(ARCH
)/Makefile
184 include arch
/$(ARCH
)/Makefile
186 # Drag in the automatic build system and other housekeeping functions
187 MAKEDEPS
+= Makefile.housekeeping
188 include Makefile.housekeeping