1 # Initialise variables that get added to throughout the various Makefiles
3 MAKEDEPS := Makefile .toolcheck
12 # Find a usable "echo -e".
14 ifeq ($(shell echo '\0101'),A)
16 else ifeq ($(shell echo -e '\0101'),A)
18 else ifeq ($(shell /bin/echo '\0101'),A)
20 else ifeq ($(shell /bin/echo -e '\0101'),A)
24 # Grab the central Config file.
29 # Location to place generated files
33 # If no architecture is specified in Config or on the command-line,
34 # use that of the build machine.
37 ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
40 # handle x86_64 like i386, but set -m32 option for 32bit code only
45 LDFLAGS += -m elf_i386
48 # Drag in architecture-specific Config
50 MAKEDEPS += arch/$(ARCH)/Config
51 include arch/$(ARCH)/Config
53 # If invoked with no build target, print out a helpfully suggestive
56 noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb
57 @$(ECHO) '==========================================================='
59 @$(ECHO) 'To create a bootable floppy, type'
60 @$(ECHO) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
61 @$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
62 @$(ECHO) 'data already on the disk.'
64 @$(ECHO) 'To create a bootable USB key, type'
65 @$(ECHO) ' cat $(BIN)/gpxe.usb > /dev/sdX'
66 @$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
67 @$(ECHO) 'disk on your system. This will erase any data already on'
68 @$(ECHO) 'the USB key.'
70 @$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
71 @$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
73 @$(ECHO) 'These images contain drivers for all supported cards. You'
74 @$(ECHO) 'can build more customised images, and ROM images, using'
75 @$(ECHO) ' make bin/<rom-name>.<output-format>'
77 @$(ECHO) '==========================================================='
79 # Locations of utilities
82 CPP ?= gcc -E -Wp,-Wall
88 CC ?= $(CROSS_COMPILE)gcc
89 AS ?= $(CROSS_COMPILE)as
90 LD ?= $(CROSS_COMPILE)ld
91 SIZE ?= $(CROSS_COMPILE)size
92 AR ?= $(CROSS_COMPILE)ar
93 RANLIB ?= $(CROSS_COMPILE)ranlib
94 OBJCOPY ?= $(CROSS_COMPILE)objcopy
95 NM ?= $(CROSS_COMPILE)nm
96 OBJDUMP ?= $(CROSS_COMPILE)objdump
97 PARSEROM ?= $(PERL) ./util/parserom.pl
98 MAKEROM ?= $(PERL) ./util/makerom.pl
99 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
100 SYMCHECK ?= $(PERL) ./util/symcheck.pl
101 SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
102 NRV2B ?= ./util/nrv2b
108 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
109 CFLAGS += -Os -ffreestanding
112 CFLAGS += $(EXTRA_CFLAGS)
113 ASFLAGS += $(EXTRA_ASFLAGS)
114 LDFLAGS += $(EXTRA_LDFLAGS)
116 ifneq ($(NO_WERROR),1)
120 # CFLAGS for specific object types
123 CFLAGS_S += -DASSEMBLY
125 # Base object name of the current target
127 OBJECT = $(firstword $(subst ., ,$(@F)))
129 # CFLAGS for specific object files. You can define
130 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
131 # compiling bin/rtl8139.o.
133 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
135 @$(ECHO) $(OBJ_CFLAGS)
137 # Rules for specific object types.
139 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
140 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
141 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
142 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
143 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
145 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
146 ASSEMBLE_S = $(AS) $(ASFLAGS)
147 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
148 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
150 DEBUG_TARGETS += dbg%.o c s
152 # SRCDIRS lists all directories containing source files.
157 SRCDIRS += net net/tcp net/udp
159 SRCDIRS += drivers/bus
160 SRCDIRS += drivers/net
161 SRCDIRS += drivers/net/e1000
162 SRCDIRS += drivers/block
163 SRCDIRS += drivers/scsi
164 SRCDIRS += drivers/ata
165 SRCDIRS += drivers/nvs
166 SRCDIRS += drivers/bitbash
167 SRCDIRS += drivers/infiniband
168 SRCDIRS += interface/pxe
170 SRCDIRS += crypto crypto/axtls crypto/matrixssl
171 SRCDIRS += hci hci/commands hci/tui
172 SRCDIRS += hci/mucurses hci/mucurses/widgets
175 # NON_AUTO_SRCS lists files that are excluded from the normal
176 # automatic build system.
178 NON_AUTO_SRCS += core/elf_loader.c
179 NON_AUTO_SRCS += drivers/net/prism2.c
181 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
182 # the automatic build system and varies by target; it includes the
183 # "-p 0x1234,0x5678" string to set the PCI IDs.
185 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
188 # Some ROMs require specific flags to be passed to makerom.pl
190 MAKEROM_FLAGS_3c503 = -3
192 # Drag in architecture-specific Makefile
194 MAKEDEPS += arch/$(ARCH)/Makefile
195 include arch/$(ARCH)/Makefile
197 # Drag in the automatic build system and other housekeeping functions
198 MAKEDEPS += Makefile.housekeeping
199 include Makefile.housekeeping