[release] Update version to 0.9.5+ post release
[gpxe.git] / src / Makefile
blob6c42da6aa51cdeab5be444679b1e88b1b9cd57b8
1 # Location to place generated files
3 BIN := bin
5 # Initialise variables that get added to throughout the various Makefiles
7 MAKEDEPS := Makefile .toolcheck .echocheck
8 SRCDIRS :=
9 SRCS :=
10 NON_AUTO_SRCS :=
11 DRIVERS :=
12 ROMS :=
13 MEDIA :=
14 NON_AUTO_MEDIA :=
16 # Locations of utilities
18 HOST_CC := gcc
19 RM := rm -f
20 TOUCH := touch
21 MKDIR := mkdir
22 CP := cp
23 ECHO := echo
24 PRINTF := printf
25 PERL := /usr/bin/perl
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
41 NRV2B := ./util/nrv2b
42 ZBIN := ./util/zbin
43 DOXYGEN := doxygen
45 # If invoked with no build target, print out a helpfully suggestive
46 # message.
48 noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb $(BIN)/undionly.kpxe
49 @$(ECHO) '==========================================================='
50 @$(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.'
55 @$(ECHO)
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.'
61 @$(ECHO)
62 @$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
63 @$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
64 @$(ECHO)
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>'
68 @$(ECHO)
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
77 ifeq ($(ARCH),x86_64)
78 ARCH := i386
79 CFLAGS += -m32
80 ASFLAGS += --32
81 LDFLAGS += -m elf_i386
82 endif
84 # Drag in architecture-specific Config
86 MAKEDEPS += arch/$(ARCH)/Config
87 include arch/$(ARCH)/Config
89 # Common flags
91 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
92 CFLAGS += -Os -ffreestanding
93 CFLAGS += -Wall -W
94 CFLAGS += -g
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)
104 CFLAGS += -Werror
105 endif
107 # CFLAGS for specific object types
109 CFLAGS_c +=
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))
121 $(BIN)/%.flags :
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.
141 SRCDIRS += libgcc
142 SRCDIRS += core
143 SRCDIRS += proto
144 SRCDIRS += net net/tcp net/udp
145 SRCDIRS += image
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
155 SRCDIRS += tests
156 SRCDIRS += crypto crypto/axtls crypto/matrixssl
157 SRCDIRS += hci hci/commands hci/tui
158 SRCDIRS += hci/mucurses hci/mucurses/widgets
159 SRCDIRS += usr
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) \
172 -i$(IDENT) -s 0 $@
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