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
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 # Grab the central Config file.
76 # If no architecture is specified in Config or on the command-line,
77 # use that of the build machine.
79 ARCH ?= $(shell uname -m | sed -e s,i[3456789]86,i386,)
81 # handle x86_64 like i386, but set -m32 option for 32bit code only
86 LDFLAGS += -m elf_i386
89 # Drag in architecture-specific Config
91 MAKEDEPS += arch/$(ARCH)/Config
92 include arch/$(ARCH)/Config
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 # Embedded image, if present
106 EMBEDDED_IMAGE ?= /dev/null
108 ifneq ($(NO_WERROR),1)
112 # CFLAGS for specific object types
115 CFLAGS_S += -DASSEMBLY
117 # Base object name of the current target
119 OBJECT = $(firstword $(subst ., ,$(@F)))
121 # CFLAGS for specific object files. You can define
122 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
123 # compiling bin/rtl8139.o.
125 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
127 @$(ECHO) $(OBJ_CFLAGS)
129 # Rules for specific object types.
131 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
132 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
133 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
134 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
135 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
137 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
138 ASSEMBLE_S = $(AS) $(ASFLAGS)
139 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
140 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
142 DEBUG_TARGETS += dbg%.o c s
144 # SRCDIRS lists all directories containing source files.
149 SRCDIRS += net net/tcp net/udp
151 SRCDIRS += drivers/bus
152 SRCDIRS += drivers/net
153 SRCDIRS += drivers/net/e1000
154 SRCDIRS += drivers/block
155 SRCDIRS += drivers/scsi
156 SRCDIRS += drivers/ata
157 SRCDIRS += drivers/nvs
158 SRCDIRS += drivers/bitbash
159 SRCDIRS += drivers/infiniband
160 SRCDIRS += interface/pxe
162 SRCDIRS += crypto crypto/axtls crypto/matrixssl
163 SRCDIRS += hci hci/commands hci/tui
164 SRCDIRS += hci/mucurses hci/mucurses/widgets
167 # NON_AUTO_SRCS lists files that are excluded from the normal
168 # automatic build system.
170 NON_AUTO_SRCS += core/elf_loader.c
171 NON_AUTO_SRCS += drivers/net/prism2.c
173 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
174 # the automatic build system and varies by target; it includes the
175 # "-p 0x1234,0x5678" string to set the PCI IDs.
177 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
180 # Some ROMs require specific flags to be passed to makerom.pl
182 MAKEROM_FLAGS_3c503 = -3
184 # Drag in architecture-specific Makefile
186 MAKEDEPS += arch/$(ARCH)/Makefile
187 include arch/$(ARCH)/Makefile
189 # Drag in the automatic build system and other housekeeping functions
190 MAKEDEPS += Makefile.housekeeping
191 include Makefile.housekeeping