Browse Source

[makefile] Add support for multiple build platforms

Allow for the build CPU architecture and platform to be specified as part
of the make command goals.  For example:

  make bin/rtl8139.rom      # Standard i386 PC-BIOS build

  make bin-efi/rtl8139.efi  # i386 EFI build

The generic syntax is "bin[-[arch-]platform]", with the default
architecture being "i386" (regardless of the host architecture) and the
default platform being "pcbios".

Non-path targets such as "srcs" can be specified using e.g.

  make bin-efi srcs

Note that this changeset is merely Makefile restructuring to allow the
build architecture and platform to be determined by the make command
goals, and to export these to compiled code via the ARCH and PLATFORM
defines.  It doesn't actually introduce any new build platforms.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
a2588547f9
3 changed files with 378 additions and 219 deletions
  1. 68
    105
      src/Makefile
  2. 310
    103
      src/Makefile.housekeeping
  3. 0
    11
      src/arch/i386/Makefile

+ 68
- 105
src/Makefile View File

1
-# Location to place generated files
1
+###############################################################################
2
 #
2
 #
3
-BIN		:= bin
4
-
5
-# Initialise variables that get added to throughout the various Makefiles
3
+# Initialise various variables
6
 #
4
 #
7
-MAKEDEPS	:= Makefile .toolcheck .echocheck
8
-SRCDIRS		:=
9
-SRCS		:=
10
-NON_AUTO_SRCS	:=
11
-DRIVERS		:=
12
-ROMS		:=
13
-MEDIA		:=
14
-NON_AUTO_MEDIA	:=
15
 
5
 
16
-# Locations of utilities
6
+CLEANUP		:=
7
+CFLAGS		:=
8
+ASFLAGS		:=
9
+LDFLAGS		:=
10
+MAKEDEPS	:= Makefile
11
+
12
+###############################################################################
13
+#
14
+# Locations of tools
17
 #
15
 #
18
 HOST_CC		:= gcc
16
 HOST_CC		:= gcc
19
 RM		:= rm -f
17
 RM		:= rm -f
42
 ZBIN		:= ./util/zbin
40
 ZBIN		:= ./util/zbin
43
 DOXYGEN		:= doxygen
41
 DOXYGEN		:= doxygen
44
 
42
 
45
-# If invoked with no build target, print out a helpfully suggestive
46
-# message.
47
-#
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) '==========================================================='
70
-
71
-# If no architecture is specified in Config or on the command-line,
72
-# use that of the build machine.
73
-#
74
-ARCH		:= $(shell uname -m | sed -e 's,i[3456789]86,i386,')
75
-
76
-# Common flags
77
-#
78
-CFLAGS		+= -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
79
-CFLAGS		+= -Os -ffreestanding
80
-CFLAGS		+= -Wall -W
81
-CFLAGS		+= -g
82
-CFLAGS		+= $(EXTRA_CFLAGS)
83
-ASFLAGS		+= $(EXTRA_ASFLAGS)
84
-LDFLAGS		+= $(EXTRA_LDFLAGS)
85
-
86
-# Embedded image, if present
87
-#
88
-EMBEDDED_IMAGE	 = /dev/null
89
-
90
-ifneq ($(NO_WERROR),1)
91
-CFLAGS		+= -Werror
92
-endif
93
-
94
-# CFLAGS for specific object types
95
-#
96
-CFLAGS_c	+= 
97
-CFLAGS_S 	+= -DASSEMBLY
98
-
99
-# Base object name of the current target
43
+###############################################################################
100
 #
44
 #
101
-OBJECT		= $(firstword $(subst ., ,$(@F)))
102
-
103
-# CFLAGS for specific object files.  You can define
104
-# e.g. CFLAGS_rtl8139, and have those flags automatically used when
105
-# compiling bin/rtl8139.o.
106
-#
107
-OBJ_CFLAGS	= $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
108
-$(BIN)/%.flags :
109
-	@$(ECHO) $(OBJ_CFLAGS)
110
-
111
-# Rules for specific object types.
112
-#
113
-COMPILE_c	= $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
114
-RULE_c		= $(Q)$(COMPILE_c) -c $< -o $@
115
-RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
116
-RULE_c_to_c	= $(Q)$(COMPILE_c) -E -c $< > $@
117
-RULE_c_to_s	= $(Q)$(COMPILE_c) -S -g0 -c $< -o $@ 
118
-
119
-PREPROCESS_S	= $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
120
-ASSEMBLE_S	= $(AS) $(ASFLAGS)
121
-RULE_S		= $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
122
-RULE_S_to_s	= $(Q)$(PREPROCESS_S) $< > $@
123
-
124
-DEBUG_TARGETS	+= dbg%.o c s
125
-
126
 # SRCDIRS lists all directories containing source files.
45
 # SRCDIRS lists all directories containing source files.
127
 #
46
 #
47
+SRCDIRS		:=
128
 SRCDIRS		+= libgcc
48
 SRCDIRS		+= libgcc
129
 SRCDIRS		+= core
49
 SRCDIRS		+= core
130
 SRCDIRS		+= proto
50
 SRCDIRS		+= proto
148
 # NON_AUTO_SRCS lists files that are excluded from the normal
68
 # NON_AUTO_SRCS lists files that are excluded from the normal
149
 # automatic build system.
69
 # automatic build system.
150
 #
70
 #
151
-NON_AUTO_SRCS	+= core/elf_loader.c
71
+NON_AUTO_SRCS	:=
152
 NON_AUTO_SRCS	+= drivers/net/prism2.c
72
 NON_AUTO_SRCS	+= drivers/net/prism2.c
153
 
73
 
154
-# Rules for finalising files.  TGT_MAKEROM_FLAGS is defined as part of
155
-# the automatic build system and varies by target; it includes the
156
-# "-p 0x1234,0x5678" string to set the PCI IDs.
74
+###############################################################################
75
+#
76
+# Default build target: build the most common targets and print out a
77
+# helpfully suggestive message
78
+#
79
+all : bin/blib.a bin/gpxe.dsk bin/gpxe.iso bin/gpxe.usb bin/undionly.kpxe
80
+	@$(ECHO) '==========================================================='
81
+	@$(ECHO)
82
+	@$(ECHO) 'To create a bootable floppy, type'
83
+	@$(ECHO) '    cat bin/gpxe.dsk > /dev/fd0'
84
+	@$(ECHO) 'where /dev/fd0 is your floppy drive.  This will erase any'
85
+	@$(ECHO) 'data already on the disk.'
86
+	@$(ECHO)
87
+	@$(ECHO) 'To create a bootable USB key, type'
88
+	@$(ECHO) '    cat bin/gpxe.usb > /dev/sdX'
89
+	@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
90
+	@$(ECHO) 'disk on your system.  This will erase any data already on'
91
+	@$(ECHO) 'the USB key.'
92
+	@$(ECHO)
93
+	@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
94
+	@$(ECHO) 'bin/gpxe.iso to a blank CD-ROM.'
95
+	@$(ECHO)
96
+	@$(ECHO) 'These images contain drivers for all supported cards.  You'
97
+	@$(ECHO) 'can build more customised images, and ROM images, using'
98
+	@$(ECHO) '    make bin/<rom-name>.<output-format>'
99
+	@$(ECHO)
100
+	@$(ECHO) '==========================================================='
101
+
102
+###############################################################################
157
 #
103
 #
158
-FINALISE_rom	= $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
159
-		  -i$(IDENT) -s 0 $@
104
+# Build targets that do nothing but might be tried by users
105
+#
106
+configure :
107
+	@$(ECHO) "No configuration needed."
108
+
109
+install :
110
+	@$(ECHO) "No installation required."
160
 
111
 
161
-# Some ROMs require specific flags to be passed to makerom.pl
112
+###############################################################################
162
 #
113
 #
163
-MAKEROM_FLAGS_3c503 = -3
114
+# Version number calculations
115
+#
116
+VERSION_MAJOR	= 0
117
+VERSION_MINOR	= 9
118
+VERSION_PATCH	= 5
119
+EXTRAVERSION	= +
120
+MM_VERSION	= $(VERSION_MAJOR).$(VERSION_MINOR)
121
+VERSION		= $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
122
+CFLAGS		+= -DVERSION_MAJOR=$(VERSION_MAJOR) \
123
+		   -DVERSION_MINOR=$(VERSION_MINOR) \
124
+		   -DVERSION=\"$(VERSION)\"
125
+IDENT		= '$(@F) $(VERSION) (GPL) etherboot.org'
126
+version :
127
+	@$(ECHO) $(VERSION)
164
 
128
 
165
-# Drag in architecture-specific Makefile
129
+###############################################################################
130
+#
131
+# Drag in the bulk of the build system
166
 #
132
 #
167
-MAKEDEPS	+= arch/$(ARCH)/Makefile
168
-include arch/$(ARCH)/Makefile
169
 
133
 
170
-# Drag in the automatic build system and other housekeeping functions
171
 MAKEDEPS	+= Makefile.housekeeping
134
 MAKEDEPS	+= Makefile.housekeeping
172
 include Makefile.housekeeping
135
 include Makefile.housekeeping

+ 310
- 103
src/Makefile.housekeeping View File

1
 # -*- makefile -*- : Force emacs to use Makefile mode
1
 # -*- makefile -*- : Force emacs to use Makefile mode
2
-
2
+#
3
 # This file contains various boring housekeeping functions that would
3
 # This file contains various boring housekeeping functions that would
4
 # otherwise seriously clutter up the main Makefile.
4
 # otherwise seriously clutter up the main Makefile.
5
 
5
 
6
-# Objects to be removed by "make clean"
7
-#
8
-CLEANUP	:= $(BIN)/*.* # *.* to avoid catching the "CVS" directory
9
-
10
-# Version number calculations 
6
+###############################################################################
11
 #
7
 #
12
-VERSION_MAJOR	= 0
13
-VERSION_MINOR	= 9
14
-VERSION_PATCH	= 5
15
-EXTRAVERSION	= +
16
-MM_VERSION	= $(VERSION_MAJOR).$(VERSION_MINOR)
17
-VERSION		= $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
18
-CFLAGS		+= -DVERSION_MAJOR=$(VERSION_MAJOR) \
19
-		   -DVERSION_MINOR=$(VERSION_MINOR) \
20
-		   -DVERSION=\"$(VERSION)\"
21
-IDENT		= '$(@F) $(VERSION) (GPL) etherboot.org'
22
-version :
23
-	@$(ECHO) $(VERSION)
24
-
25
-configure : 
26
-	@$(ECHO) "No configuration needed."
27
-
28
-install :
29
-	@$(ECHO) "No installation required. Generated images will be placed in the" $(BIN) "directory."
30
-
31
-# Check for tools that can cause failed builds
32
-#
33
-.toolcheck : Makefile
34
-	@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
35
-		$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
36
-		$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
37
-		exit 1; \
38
-	fi
39
-	@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
40
-		$(ECHO) 'Your Perl version has a Unicode handling bug'; \
41
-		$(ECHO) 'Execute this command before compiling Etherboot:'; \
42
-		$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
43
-		exit 1; \
44
-	fi
45
-	@$(TOUCH) $@
46
-VERYCLEANUP	+= .toolcheck
47
-
48
 # Find a usable "echo -e" substitute.
8
 # Find a usable "echo -e" substitute.
49
 #
9
 #
50
 TAB 			:= $(shell $(PRINTF) '\t')
10
 TAB 			:= $(shell $(PRINTF) '\t')
86
 	@$(ECHO) "No usable \"echo -e\" substitute found"
46
 	@$(ECHO) "No usable \"echo -e\" substitute found"
87
 	@exit 1
47
 	@exit 1
88
 endif
48
 endif
49
+MAKEDEPS	+= .echocheck
89
 VERYCLEANUP	+= .echocheck
50
 VERYCLEANUP	+= .echocheck
90
 
51
 
91
 echo :
52
 echo :
92
 	@$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
53
 	@$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
93
 
54
 
94
-# Build verbosity
55
+###############################################################################
56
+#
57
+# Check for tools that can cause failed builds
58
+#
59
+.toolcheck :
60
+	@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
61
+		$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
62
+		$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
63
+		exit 1; \
64
+	fi
65
+	@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
66
+		$(ECHO) 'Your Perl version has a Unicode handling bug'; \
67
+		$(ECHO) 'Execute this command before compiling Etherboot:'; \
68
+		$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
69
+		exit 1; \
70
+	fi
71
+	@$(TOUCH) $@
72
+MAKEDEPS	+= .toolcheck
73
+VERYCLEANUP	+= .toolcheck
74
+
75
+###############################################################################
76
+#
77
+# Check for various tool workarounds
95
 #
78
 #
96
-ifeq ($(V),1)
97
-Q = 
98
-QM = @\#
99
-else
100
-Q = @
101
-QM = @
102
-endif
103
 
79
 
104
 # Check for an old version of gas (binutils 2.9.1)
80
 # Check for an old version of gas (binutils 2.9.1)
105
 #
81
 #
117
 SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
93
 SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
118
 CFLAGS	+= $(SP_FLAGS)
94
 CFLAGS	+= $(SP_FLAGS)
119
 
95
 
120
-# compiler.h is needed for our linking and debugging system
96
+###############################################################################
97
+#
98
+# Build verbosity
99
+#
100
+ifeq ($(V),1)
101
+Q :=
102
+QM := @\#
103
+else
104
+Q := @
105
+QM := @
106
+endif
107
+
108
+###############################################################################
109
+#
110
+# Set BIN according to whatever was specified on the command line as
111
+# the build target.
121
 #
112
 #
122
-CFLAGS	+= -include compiler.h
123
 
113
 
114
+# Determine how many different BIN directories are mentioned in the
115
+# make goals.
116
+#
117
+BIN_GOALS	:= $(filter bin/% bin-%,$(MAKECMDGOALS))
118
+BIN_GOAL_BINS	:= $(foreach BG,$(BIN_GOALS),$(firstword $(subst /, ,$(BG))))
119
+NUM_BINS	:= $(words $(sort $(BIN_GOAL_BINS)))
120
+
121
+ifeq ($(NUM_BINS),0)
122
+
123
+# No BIN directory was specified.  Set BIN to "bin" as a sensible
124
+# default.
125
+
126
+BIN		:= bin
127
+
128
+else # NUM_BINS == 0
129
+
130
+ifeq ($(NUM_BINS),1)
131
+
132
+# If exactly one BIN directory was specified, set BIN to match this
133
+# directory.
134
+#
135
+BIN		:= $(firstword $(BIN_GOAL_BINS))
136
+
137
+else # NUM_BINS == 1
138
+
139
+# More than one BIN directory was specified.  We cannot handle the
140
+# latter case within a single make invocation, so set up recursive
141
+# targets for each BIN directory.
142
+#
143
+# Leave $(BIN) undefined.  This has implications for any target that
144
+# depends on $(BIN); such targets should be made conditional upon the
145
+# existence of $(BIN).
146
+#
147
+$(BIN_GOALS) : % : BIN_RECURSE
148
+	$(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) $@
149
+.PHONY : BIN_RECURSE
150
+
151
+endif # NUM_BINS == 1
152
+endif # NUM_BINS == 0
153
+
154
+ifdef BIN
155
+
156
+# Create $(BIN) directory if it doesn't exist yet
157
+#
158
+ifeq ($(wildcard $(BIN)),)
159
+$(shell $(MKDIR) -p $(BIN))
160
+endif
161
+
162
+# Target to allow e.g. "make bin-efi arch"
163
+#
164
+$(BIN) :
165
+	@# Do nothing, silently
166
+.PHONY : $(BIN)
167
+
168
+# Remove everything in $(BIN) for a "make clean"
169
+#
170
+CLEANUP	+= $(BIN)/*.* # Avoid picking up directories
171
+
172
+endif # defined(BIN)
173
+
174
+# Determine whether or not we need to include the dependency files
175
+#
176
+NO_DEP_TARGETS	:= $(BIN) clean veryclean
177
+ifeq ($(MAKECMDGOALS),)
178
+NEED_DEPS	:= 1
179
+endif
180
+ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
181
+NEED_DEPS	:= 1
182
+endif
183
+
184
+###############################################################################
185
+#
186
+# Select build architecture and platform based on $(BIN)
187
+#
188
+# BIN has the form bin[-[arch-]platform]
189
+
190
+ARCHS		:= $(patsubst arch/%,%,$(wildcard arch/*))
191
+PLATFORMS	:= $(patsubst config/defaults/%.h,%,\
192
+		     $(wildcard config/defaults/*.h))
193
+archs :
194
+	@$(ECHO) $(ARCHS)
195
+
196
+platforms :
197
+	@$(ECHO) $(PLATFORMS)
198
+
199
+ifdef BIN
200
+
201
+# Determine architecture portion of $(BIN), if present
202
+BIN_ARCH	:= $(strip $(foreach A,$(ARCHS),\
203
+			     $(patsubst bin-$(A)-%,$(A),\
204
+			       $(filter bin-$(A)-%,$(BIN)))))
205
+
206
+# Determine platform portion of $(BIN), if present
207
+ifeq ($(BIN_ARCH),)
208
+BIN_PLATFORM	:= $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
209
+else
210
+BIN_PLATFORM	:= $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
211
+endif
212
+
213
+# Determine build architecture
214
+DEFAULT_ARCH	:= i386
215
+ARCH		:= $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
216
+CFLAGS		+= -DARCH=$(ARCH)
217
+arch :
218
+	@$(ECHO) $(ARCH)
219
+.PHONY : arch
220
+
221
+# Determine build platform
222
+DEFAULT_PLATFORM := pcbios
223
+PLATFORM	:= $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
224
+CFLAGS		+= -DPLATFORM=$(PLATFORM)
225
+platform :
226
+	@$(ECHO) $(PLATFORM)
227
+
228
+endif # defined(BIN)
229
+
230
+# Include architecture-specific Makefile
231
+ifdef ARCH
232
+include arch/$(ARCH)/Makefile
233
+endif
234
+
235
+###############################################################################
236
+#
124
 # config/%.h files are generated from config.h using mkconfig.pl
237
 # config/%.h files are generated from config.h using mkconfig.pl
238
+#
125
 config/%.h : config*.h
239
 config/%.h : config*.h
126
 	$(MKCONFIG) config.h
240
 	$(MKCONFIG) config.h
127
 CLEANUP	+= config/*.h
241
 CLEANUP	+= config/*.h
128
 
242
 
243
+###############################################################################
244
+#
245
+# Source file handling
246
+
129
 # SRCDIRS lists all directories containing source files.
247
 # SRCDIRS lists all directories containing source files.
130
 srcdirs :
248
 srcdirs :
131
 	@$(ECHO) $(SRCDIRS)
249
 	@$(ECHO) $(SRCDIRS)
145
 autosrcs :
263
 autosrcs :
146
 	@$(ECHO) $(AUTO_SRCS)
264
 	@$(ECHO) $(AUTO_SRCS)
147
 
265
 
266
+# Just about everything else in this section depends upon having
267
+# $(BIN) set
268
+
269
+ifdef BIN
270
+
271
+# Common flags
272
+#
273
+CFLAGS		+= -I include -I arch/$(ARCH)/include -I .
274
+CFLAGS		+= -Os -ffreestanding
275
+CFLAGS		+= -Wall -W
276
+CFLAGS		+= -g
277
+CFLAGS		+= $(EXTRA_CFLAGS)
278
+ASFLAGS		+= $(EXTRA_ASFLAGS)
279
+LDFLAGS		+= $(EXTRA_LDFLAGS)
280
+
281
+# Embedded image, if present
282
+#
283
+EMBEDDED_IMAGE	= /dev/null
284
+
285
+# Inhibit -Werror if NO_WERROR is specified on make command line
286
+#
287
+ifneq ($(NO_WERROR),1)
288
+CFLAGS		+= -Werror
289
+endif
290
+
291
+# compiler.h is needed for our linking and debugging system
292
+#
293
+CFLAGS		+= -include compiler.h
294
+
295
+# CFLAGS for specific object types
296
+#
297
+CFLAGS_c	+=
298
+CFLAGS_S 	+= -DASSEMBLY
299
+
300
+# Base object name of the current target
301
+#
302
+OBJECT		= $(firstword $(subst ., ,$(@F)))
303
+
304
+# CFLAGS for specific object files.  You can define
305
+# e.g. CFLAGS_rtl8139, and have those flags automatically used when
306
+# compiling bin/rtl8139.o.
307
+#
308
+OBJ_CFLAGS	= $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
309
+$(BIN)/%.flags :
310
+	@$(ECHO) $(OBJ_CFLAGS)
311
+
312
+# Rules for specific object types.
313
+#
314
+COMPILE_c	= $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
315
+RULE_c		= $(Q)$(COMPILE_c) -c $< -o $@
316
+RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
317
+RULE_c_to_c	= $(Q)$(COMPILE_c) -E -c $< > $@
318
+RULE_c_to_s	= $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
319
+
320
+PREPROCESS_S	= $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
321
+ASSEMBLE_S	= $(AS) $(ASFLAGS)
322
+RULE_S		= $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
323
+RULE_S_to_s	= $(Q)$(PREPROCESS_S) $< > $@
324
+
325
+DEBUG_TARGETS	+= dbg%.o c s
326
+
148
 # We automatically generate rules for any file mentioned in AUTO_SRCS
327
 # We automatically generate rules for any file mentioned in AUTO_SRCS
149
 # using the following set of templates.  It would be cleaner to use
328
 # using the following set of templates.  It would be cleaner to use
150
 # $(eval ...), but this function exists only in GNU make >= 3.80.
329
 # $(eval ...), but this function exists only in GNU make >= 3.80.
158
 #
337
 #
159
 define src_template
338
 define src_template
160
 
339
 
161
-	@$(ECHO) "Generating Makefile rules for $(1)"
340
+	@$(ECHO) "  [DEPS] $(1)"
162
 	@$(MKDIR) -p $(dir $(2))
341
 	@$(MKDIR) -p $(dir $(2))
163
 	@$(RM) $(2)
342
 	@$(RM) $(2)
164
 	@$(TOUCH) $(2)
343
 	@$(TOUCH) $(2)
183
 		-Wno-error -MM $(1) -MT "$(4)_DEPS" -MG -MP | \
362
 		-Wno-error -MM $(1) -MT "$(4)_DEPS" -MG -MP | \
184
 		sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
363
 		sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
185
 	@$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
364
 	@$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
186
-		 '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"\n' \
365
+		 '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
187
 		 '\n\t$$(RULE_$(3))\n' \
366
 		 '\n\t$$(RULE_$(3))\n' \
188
 		 '\nBOBJS += $$(BIN)/$(4).o\n' \
367
 		 '\nBOBJS += $$(BIN)/$(4).o\n' \
189
 		 $(foreach TGT,$(DEBUG_TARGETS), \
368
 		 $(foreach TGT,$(DEBUG_TARGETS), \
190
 		    $(if $(RULE_$(3)_to_$(TGT)), \
369
 		    $(if $(RULE_$(3)_to_$(TGT)), \
191
 		    '\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
370
 		    '\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
192
-		    '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"\n' \
371
+		    '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"' \
193
 		    '\n\t$$(RULE_$(3)_to_$(TGT))\n' \
372
 		    '\n\t$$(RULE_$(3)_to_$(TGT))\n' \
194
 		    '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
373
 		    '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
195
 		 '\n$(2) : $$($(4)_DEPS)\n' \
374
 		 '\n$(2) : $$($(4)_DEPS)\n' \
206
 # Calculate and include the list of Makefile rules files
385
 # Calculate and include the list of Makefile rules files
207
 #
386
 #
208
 AUTO_DEPS	= $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
387
 AUTO_DEPS	= $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
388
+ifdef NEED_DEPS
209
 -include $(AUTO_DEPS)
389
 -include $(AUTO_DEPS)
390
+endif
210
 autodeps :
391
 autodeps :
211
 	@$(ECHO) $(AUTO_DEPS)
392
 	@$(ECHO) $(AUTO_DEPS)
212
 VERYCLEANUP	+= $(BIN)/deps
393
 VERYCLEANUP	+= $(BIN)/deps
238
 	     'it is only for rom-o-matic' >> $@
419
 	     'it is only for rom-o-matic' >> $@
239
 	@$(ECHO) >> $@
420
 	@$(ECHO) >> $@
240
 	@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
421
 	@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
241
-CLEANUP		+= $(BIN)/NIC
422
+CLEANUP		+= $(BIN)/NIC	# Doesn't match the $(BIN)/*.* pattern
242
 
423
 
243
 # Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
424
 # Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
244
 # derive the variables:
425
 # derive the variables:
343
 # in order to correctly rebuild blib whenever the list of objects
524
 # in order to correctly rebuild blib whenever the list of objects
344
 # changes.
525
 # changes.
345
 #
526
 #
346
-BLIB_LIST	= $(BIN)/.blib.list
347
-ifneq ($(shell cat $(BLIB_LIST)),$(BLIB_OBJS))
527
+BLIB_LIST	:= $(BIN)/.blib.list
528
+ifeq ($(wildcard $(BLIB_LIST)),)
529
+BLIB_LIST_OBJS	:=
530
+else
531
+BLIB_LIST_OBJS	:= $(shell cat $(BLIB_LIST))
532
+endif
533
+ifneq ($(BLIB_LIST_OBJS),$(BLIB_OBJS))
348
 $(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
534
 $(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
349
 endif
535
 endif
350
 
536
 
397
 	$(QM)$(ECHO) "  [ZBIN] $@"
583
 	$(QM)$(ECHO) "  [ZBIN] $@"
398
 	$(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
584
 	$(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
399
 
585
 
400
-# Build bochs symbol table
401
-$(BIN)/%.bxs : $(BIN)/%.tmp
402
-	$(NM) $< | cut -d" " -f1,3 > $@
403
-
404
 # Rules for each media format.  These are generated and placed in an
586
 # Rules for each media format.  These are generated and placed in an
405
 # external Makefile fragment.  We could do this via $(eval ...), but
587
 # external Makefile fragment.  We could do this via $(eval ...), but
406
 # that would require make >= 3.80.
588
 # that would require make >= 3.80.
436
 #
618
 #
437
 define media_template
619
 define media_template
438
 
620
 
439
-	@$(ECHO) "Generating Makefile rules for $(1) media"
621
+	@$(ECHO) "  [MEDIADEPS] $(1)"
440
 	@$(MKDIR) -p $(dir $(2))
622
 	@$(MKDIR) -p $(dir $(2))
441
 	@$(RM) $(2)
623
 	@$(RM) $(2)
442
 	@$(TOUCH) $(2)
624
 	@$(TOUCH) $(2)
460
 MEDIA_DEPS		= $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
642
 MEDIA_DEPS		= $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
461
 mediadeps :
643
 mediadeps :
462
 	@$(ECHO) $(MEDIA_DEPS)
644
 	@$(ECHO) $(MEDIA_DEPS)
645
+ifdef NEED_DEPS
463
 -include $(MEDIA_DEPS)
646
 -include $(MEDIA_DEPS)
647
+endif
648
+
649
+# Wrap up binary blobs (for embedded images)
650
+#
651
+$(BIN)/%.o : payload/%.img
652
+	$(QM)echo "  [WRAP] $@"
653
+	$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
654
+		--defsym obj_$*=0
655
+
656
+BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
464
 
657
 
465
 # The "allXXXs" targets for each suffix
658
 # The "allXXXs" targets for each suffix
466
 #
659
 #
473
 $(BIN)/etherboot.% : $(BIN)/gpxe.%
666
 $(BIN)/etherboot.% : $(BIN)/gpxe.%
474
 	ln -sf $(notdir $<) $@
667
 	ln -sf $(notdir $<) $@
475
 
668
 
476
-# Wrap up binary blobs
669
+endif # defined(BIN)
670
+
671
+###############################################################################
477
 #
672
 #
478
-$(BIN)/%.o : payload/%.img
479
-	$(QM)echo "  [WRAP] $@"
480
-	$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
481
-		--defsym obj_$*=0
673
+# Rules for finalising files.  TGT_MAKEROM_FLAGS is defined as part of
674
+# the automatic build system and varies by target; it includes the
675
+# "-p 0x1234,0x5678" string to set the PCI IDs.
676
+#
677
+FINALISE_rom	= $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
678
+		  -i$(IDENT) -s 0 $@
482
 
679
 
483
-BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
680
+# Some ROMs require specific flags to be passed to makerom.pl
681
+#
682
+MAKEROM_FLAGS_3c503 = -3
484
 
683
 
684
+###############################################################################
685
+#
485
 # The compression utilities
686
 # The compression utilities
486
 #
687
 #
487
 $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
688
 $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
495
 	$(Q)$(HOST_CC) -O2 -o $@ $<
696
 	$(Q)$(HOST_CC) -O2 -o $@ $<
496
 CLEANUP += $(ZBIN)
697
 CLEANUP += $(ZBIN)
497
 
698
 
699
+###############################################################################
700
+#
498
 # Auto-incrementing build serial number.  Append "bs" to your list of
701
 # Auto-incrementing build serial number.  Append "bs" to your list of
499
 # build targets to get a serial number printed at the end of the
702
 # build targets to get a serial number printed at the end of the
500
 # build.  Enable -DBUILD_SERIAL in order to see it when the code runs.
703
 # build.  Enable -DBUILD_SERIAL in order to see it when the code runs.
518
 	@$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
721
 	@$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
519
 	@$(ECHO) "Build serial number is $(shell cat $<)"
722
 	@$(ECHO) "Build serial number is $(shell cat $<)"
520
 
723
 
521
-# List of available architectures
724
+###############################################################################
522
 #
725
 #
523
-ARCHS	= $(filter-out CVS,$(patsubst arch/%,%,$(wildcard arch/*)))
524
-archs :
525
-	@$(ECHO) $(ARCHS)
726
+# Build the TAGS file(s) for emacs
727
+#
728
+TAGS :
729
+	ctags -e -R -f $@ --exclude=bin
526
 
730
 
527
-OTHER_ARCHS	= $(filter-out $(ARCH),$(ARCHS))
528
-otherarchs :
529
-	@$(ECHO) $(OTHER_ARCHS)
731
+CLEANUP	+= TAGS
530
 
732
 
531
-# Build the TAGS file for emacs
733
+###############################################################################
532
 #
734
 #
533
-TAGS : TAGS.$(ARCH)
534
-
535
-TAGS.$(ARCH) : 
536
-	ctags -e -R -f $@ --exclude=bin \
537
-		$(foreach ARCH,$(OTHER_ARCHS),--exclude=arch/$(ARCH))
538
-CLEANUP	+= TAGS*
735
+# Force rebuild for any given target
736
+#
737
+%.rebuild :
738
+	rm -f $*
739
+	$(Q)$(MAKE) $*
539
 
740
 
741
+###############################################################################
742
+#
540
 # Symbol table checks
743
 # Symbol table checks
541
 #
744
 #
745
+
746
+ifdef BIN
747
+
542
 SYMTAB	= $(BIN)/symtab
748
 SYMTAB	= $(BIN)/symtab
543
 $(SYMTAB) : $(BLIB)
749
 $(SYMTAB) : $(BLIB)
544
 	$(OBJDUMP) -w -t $< > $@
750
 	$(OBJDUMP) -w -t $< > $@
548
 symcheck : $(SYMTAB)
754
 symcheck : $(SYMTAB)
549
 	$(SYMCHECK) $<
755
 	$(SYMCHECK) $<
550
 
756
 
551
-# Force rebuild for any given target
757
+endif # defined(BIN)
758
+
759
+###############################################################################
552
 #
760
 #
553
-$(BIN)/%.rebuild :
554
-	rm -f $(BIN)/$*
555
-	$(MAKE) $(MAKEFLAGS) $(BIN)/$*
761
+# Build bochs symbol table
762
+#
763
+
764
+ifdef BIN
556
 
765
 
766
+$(BIN)/%.bxs : $(BIN)/%.tmp
767
+	$(NM) $< | cut -d" " -f1,3 > $@
768
+
769
+endif # defined(BIN)
770
+
771
+###############################################################################
772
+#
557
 # Documentation
773
 # Documentation
558
 #
774
 #
775
+
776
+ifdef BIN
777
+
559
 $(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
778
 $(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
560
 	$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
779
 	$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
561
 		-e  's{\@BIN\@}{$(BIN)}; ' \
780
 		-e  's{\@BIN\@}{$(BIN)}; ' \
579
 		$(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
798
 		$(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
580
 	fi
799
 	fi
581
 
800
 
801
+endif # defined(BIN)
802
+
803
+###############################################################################
804
+#
582
 # Clean-up
805
 # Clean-up
583
 #
806
 #
584
 clean :
807
 clean :
586
 
809
 
587
 veryclean : clean
810
 veryclean : clean
588
 	$(RM) -r $(VERYCLEANUP)
811
 	$(RM) -r $(VERYCLEANUP)
589
-
590
-# Make clean tarballs for release
591
-
592
-tarball : ../VERSION
593
-	($(ECHO) -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
594
-	$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
595
-	mkdir -p /tmp/$(USER)/gpxe-$(VERSION)
596
-	cp -rP .. /tmp/$(USER)/gpxe-$(VERSION)
597
-	( cd /tmp/$(USER)/gpxe-$(VERSION)/src ; $(MAKE) veryclean ; $(RM) -r bin/deps )
598
-	( cd /tmp/$(USER); tar cf /tmp/$(USER)/gpxe-$(VERSION).tar --exclude ".git*" --exclude "#*" \
599
-	  --exclude "*~" gpxe-$(VERSION) )
600
-	bzip2 -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.bz2
601
-	gzip -9 < /tmp/$(USER)/gpxe-$(VERSION).tar > /tmp/$(USER)/gpxe-$(VERSION).tar.gz
602
-	$(RM) -r /tmp/$(USER)/gpxe-$(VERSION)
603
-	$(RM) /tmp/$(USER)/gpxe-$(VERSION).tar
604
-	( cd /tmp/$(USER) ; tar -zxf /tmp/$(USER)/gpxe-$(VERSION).tar.gz )

+ 0
- 11
src/arch/i386/Makefile View File

144
 # output of "make"
144
 # output of "make"
145
 #
145
 #
146
 MEDIA		+= $(NON_AUTO_MEDIA)
146
 MEDIA		+= $(NON_AUTO_MEDIA)
147
-
148
-# Shortcut to allow typing just
149
-#   make bin-kir/%
150
-# rather than
151
-#   make -f arch/i386/kir-Makefile bin-kir/%
152
-# for building a KEEP_IT_REAL flavour.
153
-#
154
-$(BIN)-kir/% : kir-target
155
-	$(MAKE) -f arch/i386/kir-Makefile $(MAKECMDGOALS)
156
-
157
-.PHONY : kir-target

Loading…
Cancel
Save