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'
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
70 CPP ?= gcc -E -Wp,-Wall
76 CC ?= $(CROSS_COMPILE)gcc
77 AS ?= $(CROSS_COMPILE)as
78 LD ?= $(CROSS_COMPILE)ld
79 SIZE ?= $(CROSS_COMPILE)size
80 AR ?= $(CROSS_COMPILE)ar
81 RANLIB ?= $(CROSS_COMPILE)ranlib
82 OBJCOPY ?= $(CROSS_COMPILE)objcopy
83 NM ?= $(CROSS_COMPILE)nm
84 OBJDUMP ?= $(CROSS_COMPILE)objdump
85 PARSEROM ?= $(PERL) ./util/parserom.pl
86 MAKEROM ?= $(PERL) ./util/makerom.pl
87 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
88 SYMCHECK ?= $(PERL) ./util/symcheck.pl
89 SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
96 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
97 CFLAGS += -Os -ffreestanding
100 CFLAGS += $(EXTRA_CFLAGS)
101 ASFLAGS += $(EXTRA_ASFLAGS)
102 LDFLAGS += $(EXTRA_LDFLAGS)
104 ifneq ($(NO_WERROR),1)
108 # CFLAGS for specific object types
111 CFLAGS_S += -DASSEMBLY
113 # Base object name of the current target
115 OBJECT = $(firstword $(subst ., ,$(@F)))
117 # CFLAGS for specific object files. You can define
118 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
119 # compiling bin/rtl8139.o.
121 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
125 # Rules for specific object types.
127 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
128 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
129 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
130 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
131 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
133 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
134 ASSEMBLE_S = $(AS) $(ASFLAGS)
135 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
136 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
138 DEBUG_TARGETS += dbg%.o c s
140 # SRCDIRS lists all directories containing source files.
145 SRCDIRS += net net/tcp net/udp
147 SRCDIRS += drivers/bus
148 SRCDIRS += drivers/net
149 SRCDIRS += drivers/block
150 SRCDIRS += drivers/scsi
151 SRCDIRS += drivers/ata
152 SRCDIRS += drivers/nvs
153 SRCDIRS += drivers/bitbash
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