1 # Location to place generated files
5 # Initialise variables that get added to throughout the various Makefiles
7 MAKEDEPS
:= Makefile .toolcheck .echocheck
16 # Locations of utilities
26 CC
:= $(CROSS_COMPILE
)gcc
27 CPP
:= $(CROSS_COMPILE
)gcc
-E
-Wp
,-Wall
28 AS
:= $(CROSS_COMPILE
)as
29 LD
:= $(CROSS_COMPILE
)ld
30 SIZE
:= $(CROSS_COMPILE
)size
31 AR
:= $(CROSS_COMPILE
)ar
32 RANLIB
:= $(CROSS_COMPILE
)ranlib
33 OBJCOPY
:= $(CROSS_COMPILE
)objcopy
34 NM
:= $(CROSS_COMPILE
)nm
35 OBJDUMP
:= $(CROSS_COMPILE
)objdump
36 PARSEROM
:= $(PERL
) .
/util
/parserom.pl
37 MAKEROM
:= $(PERL
) .
/util
/makerom.pl
38 MKCONFIG
:= $(PERL
) .
/util
/mkconfig.pl
39 SYMCHECK
:= $(PERL
) .
/util
/symcheck.pl
40 SORTOBJDUMP
:= $(PERL
) .
/util
/sortobjdump.pl
45 # If invoked with no build target, print out a helpfully suggestive
48 noargs
: blib
$(BIN
)/NIC
$(BIN
)/gpxe.dsk
$(BIN
)/gpxe.iso
$(BIN
)/gpxe.usb
$(BIN
)/undionly.kpxe
49 @
$(ECHO
) '==========================================================='
51 @
$(ECHO
) 'To create a bootable floppy, type'
52 @
$(ECHO
) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
53 @
$(ECHO
) 'where /dev/fd0 is your floppy drive. This will erase any'
54 @
$(ECHO
) 'data already on the disk.'
56 @
$(ECHO
) 'To create a bootable USB key, type'
57 @
$(ECHO
) ' cat $(BIN)/gpxe.usb > /dev/sdX'
58 @
$(ECHO
) 'where /dev/sdX is your USB key, and is *not* a real hard'
59 @
$(ECHO
) 'disk on your system. This will erase any data already on'
60 @
$(ECHO
) 'the USB key.'
62 @
$(ECHO
) 'To create a bootable CD-ROM, burn the ISO image '
63 @
$(ECHO
) '$(BIN)/gpxe.iso to a blank CD-ROM.'
65 @
$(ECHO
) 'These images contain drivers for all supported cards. You'
66 @
$(ECHO
) 'can build more customised images, and ROM images, using'
67 @
$(ECHO
) ' make bin/<rom-name>.<output-format>'
69 @
$(ECHO
) '==========================================================='
71 # If no architecture is specified in Config or on the command-line,
72 # use that of the build machine.
74 ARCH
:= $(shell uname
-m | sed
-e
's,i[3456789]86,i386,')
76 # handle x86_64 like i386, but set -m32 option for 32bit code only
81 LDFLAGS
+= -m elf_i386
84 # Drag in architecture-specific Config
86 MAKEDEPS
+= arch
/$(ARCH
)/Config
87 include arch
/$(ARCH
)/Config
91 CFLAGS
+= -I
include -I arch
/$(ARCH
)/include -I .
-DARCH
=$(ARCH
)
92 CFLAGS
+= -Os
-ffreestanding
95 CFLAGS
+= $(EXTRA_CFLAGS
)
96 ASFLAGS
+= $(EXTRA_ASFLAGS
)
97 LDFLAGS
+= $(EXTRA_LDFLAGS
)
99 # Embedded image, if present
101 EMBEDDED_IMAGE
= /dev
/null
103 ifneq ($(NO_WERROR
),1)
107 # CFLAGS for specific object types
110 CFLAGS_S
+= -DASSEMBLY
112 # Base object name of the current target
114 OBJECT
= $(firstword $(subst .
, ,$(@F
)))
116 # CFLAGS for specific object files. You can define
117 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
118 # compiling bin/rtl8139.o.
120 OBJ_CFLAGS
= $(CFLAGS_
$(OBJECT
)) -DOBJECT
=$(subst -,_
,$(OBJECT
))
122 @
$(ECHO
) $(OBJ_CFLAGS
)
124 # Rules for specific object types.
126 COMPILE_c
= $(CC
) $(CFLAGS
) $(CFLAGS_c
) $(OBJ_CFLAGS
)
127 RULE_c
= $(Q
)$(COMPILE_c
) -c
$< -o
$@
128 RULE_c_to_dbg
%.o
= $(Q
)$(COMPILE_c
) -Ddebug_
$(OBJECT
)=$* -c
$< -o
$@
129 RULE_c_to_c
= $(Q
)$(COMPILE_c
) -E
-c
$< > $@
130 RULE_c_to_s
= $(Q
)$(COMPILE_c
) -S
-g0
-c
$< -o
$@
132 PREPROCESS_S
= $(CPP
) $(CFLAGS
) $(CFLAGS_S
) $(OBJ_CFLAGS
)
133 ASSEMBLE_S
= $(AS
) $(ASFLAGS
)
134 RULE_S
= $(Q
)$(PREPROCESS_S
) $< |
$(ASSEMBLE_S
) -o
$@
135 RULE_S_to_s
= $(Q
)$(PREPROCESS_S
) $< > $@
137 DEBUG_TARGETS
+= dbg
%.o c s
139 # SRCDIRS lists all directories containing source files.
144 SRCDIRS
+= net net
/tcp net
/udp
146 SRCDIRS
+= drivers
/bus
147 SRCDIRS
+= drivers
/net
148 SRCDIRS
+= drivers
/net
/e1000
149 SRCDIRS
+= drivers
/net
/phantom
150 SRCDIRS
+= drivers
/block
151 SRCDIRS
+= drivers
/nvs
152 SRCDIRS
+= drivers
/bitbash
153 SRCDIRS
+= drivers
/infiniband
154 SRCDIRS
+= interface
/pxe
156 SRCDIRS
+= crypto crypto
/axtls crypto
/matrixssl
157 SRCDIRS
+= hci hci
/commands hci
/tui
158 SRCDIRS
+= hci
/mucurses hci
/mucurses
/widgets
161 # NON_AUTO_SRCS lists files that are excluded from the normal
162 # automatic build system.
164 NON_AUTO_SRCS
+= core
/elf_loader.c
165 NON_AUTO_SRCS
+= drivers
/net
/prism2.c
167 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
168 # the automatic build system and varies by target; it includes the
169 # "-p 0x1234,0x5678" string to set the PCI IDs.
171 FINALISE_rom
= $(MAKEROM
) $(MAKEROM_FLAGS
) $(TGT_MAKEROM_FLAGS
) \
174 # Some ROMs require specific flags to be passed to makerom.pl
176 MAKEROM_FLAGS_3c503
= -3
178 # Drag in architecture-specific Makefile
180 MAKEDEPS
+= arch
/$(ARCH
)/Makefile
181 include arch
/$(ARCH
)/Makefile
183 # Drag in the automatic build system and other housekeeping functions
184 MAKEDEPS
+= Makefile.housekeeping
185 include Makefile.housekeeping