Merge branch 'master' of /pub/scm/gpxe
[gpxe.git] / src / Makefile
blob2dd2a8d72d936f8d13c099eef811ebf69883133e
1 # Initialise variables that get added to throughout the various Makefiles
3 MAKEDEPS := Makefile .toolcheck
4 SRCDIRS :=
5 SRCS :=
6 NON_AUTO_SRCS :=
7 DRIVERS :=
8 ROMS :=
9 MEDIA :=
10 NON_AUTO_MEDIA :=
12 # Grab the central Config file.
14 MAKEDEPS += Config
15 include Config
17 # If no architecture is specified in Config or on the command-line,
18 # use that of the build machine.
20 ifndef ARCH
21 ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
22 endif
24 # Drag in architecture-specific Config
26 MAKEDEPS += arch/$(ARCH)/Config
27 include arch/$(ARCH)/Config
29 # If invoked with no build target, print out a helpfully suggestive
30 # message.
32 noargs :
33 @echo '===================================================='
34 @echo
35 @echo ' *** WARNING: THE INSTRUCTIONS BELOW DO NOT FULLY WORK YET !!! ***'
36 @echo ' *** PLEASE STAY TUNED ***'
37 @echo
38 @echo 'No target specified. To specify a target, do: '
39 @echo
40 @echo ' make bin/<rom-name>.<output-format> '
41 @echo
42 @echo 'where <output-format> is one of {$(MEDIA) }'
43 @echo
44 @echo 'or: '
45 @echo
46 @echo ' make all<output-format>s'
47 @echo
48 @echo 'to generate all possible images of format <output-format>'
49 @echo
50 @echo 'For example, '
51 @echo
52 @echo ' make allzroms '
53 @echo
54 @echo 'will generate all possible .zrom (rom burnable) images, and'
55 @echo
56 @echo ' make allzdsks'
57 @echo
58 @echo 'will generate all possible .zdsk (bootable floppy) images, or'
59 @echo
60 @echo '===================================================='
61 @exit 1
63 # Locations of utilities
65 HOST_CC ?= gcc
66 CPP ?= gcc -E -Wp,-Wall
67 RM ?= rm -f
68 TOUCH ?= touch
69 MKDIR ?= mkdir
70 PERL ?= /usr/bin/perl
71 CC ?= $(CROSS_COMPILE)gcc
72 AS ?= $(CROSS_COMPILE)as
73 LD ?= $(CROSS_COMPILE)ld
74 SIZE ?= $(CROSS_COMPILE)size
75 AR ?= $(CROSS_COMPILE)ar
76 RANLIB ?= $(CROSS_COMPILE)ranlib
77 OBJCOPY ?= $(CROSS_COMPILE)objcopy
78 NM ?= $(CROSS_COMPILE)nm
79 OBJDUMP ?= $(CROSS_COMPILE)objdump
80 PARSEROM ?= $(PERL) ./util/parserom.pl
81 MAKEROM ?= $(PERL) ./util/makerom.pl
82 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
83 SYMCHECK ?= $(PERL) ./util/symcheck.pl
84 SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
85 NRV2B ?= ./util/nrv2b
86 DOXYGEN ?= doxygen
88 # Location to place generated files
90 BIN ?= bin
92 # Common flags
94 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
95 CFLAGS += -Os -ffreestanding
96 CFLAGS += -Wall -W
97 CFLAGS += -g
98 CFLAGS += $(EXTRA_CFLAGS)
99 ASFLAGS += $(EXTRA_ASFLAGS)
100 LDFLAGS += $(EXTRA_LDFLAGS)
102 # CFLAGS for specific object types
104 CFLAGS_c +=
105 CFLAGS_S += -DASSEMBLY
107 # Base object name of the current target
109 OBJECT = $(firstword $(subst ., ,$(@F)))
111 # CFLAGS for specific object files. You can define
112 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
113 # compiling bin/rtl8139.o.
115 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
116 $(BIN)/%.flags :
117 @echo $(OBJ_CFLAGS)
119 # Rules for specific object types.
121 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
122 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
123 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
124 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
125 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
127 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
128 ASSEMBLE_S = $(AS) $(ASFLAGS)
129 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
130 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
132 DEBUG_TARGETS += dbg%.o c s
134 # SRCDIRS lists all directories containing source files.
136 SRCDIRS += core
137 SRCDIRS += proto
138 SRCDIRS += net net/tcp net/udp
139 SRCDIRS += image
140 SRCDIRS += drivers/bus
141 SRCDIRS += drivers/net
142 SRCDIRS += drivers/block
143 SRCDIRS += drivers/scsi
144 SRCDIRS += drivers/ata
145 SRCDIRS += drivers/nvs
146 SRCDIRS += drivers/bitbash
147 SRCDIRS += interface/pxe
148 SRCDIRS += tests
149 SRCDIRS += crypto crypto/axtls crypto/matrixssl
150 SRCDIRS += hci hci/commands hci/tui
151 SRCDIRS += hci/mucurses hci/mucurses/widgets
152 SRCDIRS += usr
154 # NON_AUTO_SRCS lists files that are excluded from the normal
155 # automatic build system.
157 NON_AUTO_SRCS += core/elf_loader.c
158 NON_AUTO_SRCS += drivers/net/prism2.c
160 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
161 # the automatic build system and varies by target; it includes the
162 # "-p 0x1234,0x5678" string to set the PCI IDs.
164 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
165 -i$(IDENT) $@
167 # Some ROMs require specific flags to be passed to makerom.pl
169 MAKEROM_FLAGS_3c503 = -3
171 # Drag in architecture-specific Makefile
173 MAKEDEPS += arch/$(ARCH)/Makefile
174 include arch/$(ARCH)/Makefile
176 # Drag in the automatic build system and other housekeeping functions
177 MAKEDEPS += Makefile.housekeeping
178 include Makefile.housekeeping