~ubuntu-branches/ubuntu/trusty/apex/trusty

« back to all changes in this revision

Viewing changes to scripts/Makefile.build

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2009-11-10 11:55:15 UTC
  • mfrom: (2.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091110115515-6jjsf6rc8py35awe
Tags: 1.6.10ubuntu1
* Merge from debian testing, remaining changes:
  - Move apex VMA address to 4MiB to leave enough space for the ubuntu
  kernel and not overwrite apex in ram when loading.
  - nslu2 configuration: set CONFIG_RAMDISK_SIZE=0x0055FFF0 instead of
  0x005FFFF0 to make enough room for ubuntu initramfs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
src := $(obj)
6
6
 
7
 
.PHONY: __build
 
7
PHONY := __build
8
8
__build:
9
9
 
10
 
# Read .config if it exist, otherwise ignore
11
 
-include .config
12
 
quote:="
13
 
# "
14
 
CONFIG_MACH:= $(subst $(quote),,$(CONFIG_MACH))
15
 
 
16
 
include $(if $(wildcard $(obj)/Kbuild), $(obj)/Kbuild, $(obj)/Makefile)
17
 
 
 
10
# Init all relevant variables used in kbuild files so
 
11
# 1) they have correct type
 
12
# 2) they do not inherit any value from the environment
 
13
obj-y :=
 
14
obj-m :=
 
15
lib-y :=
 
16
lib-m :=
 
17
always :=
 
18
targets :=
 
19
subdir-y :=
 
20
subdir-m :=
 
21
EXTRA_AFLAGS   :=
 
22
EXTRA_CFLAGS   :=
 
23
EXTRA_CPPFLAGS :=
 
24
EXTRA_LDFLAGS  :=
 
25
asflags-y  :=
 
26
ccflags-y  :=
 
27
cppflags-y :=
 
28
ldflags-y  :=
 
29
 
 
30
# Read auto.conf if it exists, otherwise ignore
 
31
-include include/config/auto.conf
 
32
 
 
33
include scripts/Kbuild.include
 
34
 
 
35
# For backward compatibility check that these variables do not change
 
36
save-cflags := $(CFLAGS)
 
37
 
 
38
# The filename Kbuild has precedence over Makefile
 
39
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
 
40
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
 
41
include $(kbuild-file)
 
42
 
 
43
# If the save-* variables changed error out
 
44
ifeq ($(KBUILD_NOPEDANTIC),)
 
45
        ifneq ("$(save-cflags)","$(CFLAGS)")
 
46
                $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use EXTRA_CFLAGS)
 
47
        endif
 
48
endif
18
49
include scripts/Makefile.lib
19
50
 
20
51
ifdef host-progs
24
55
endif
25
56
endif
26
57
 
27
 
# Do not include host rules unles needed
 
58
# Do not include host rules unless needed
28
59
ifneq ($(hostprogs-y)$(hostprogs-m),)
29
60
include scripts/Makefile.host
30
61
endif
38
69
_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
39
70
endif
40
71
 
41
 
 
42
 
ifdef EXTRA_TARGETS
43
 
$(warning kbuild: $(obj)/Makefile - Usage of EXTRA_TARGETS is obsolete in 2.6. Please fix!)
44
 
endif
45
 
 
46
 
ifdef build-targets
47
 
$(warning kbuild: $(obj)/Makefile - Usage of build-targets is obsolete in 2.6. Please fix!)
48
 
endif
49
 
 
50
 
ifdef export-objs
51
 
$(warning kbuild: $(obj)/Makefile - Usage of export-objs is obsolete in 2.6. Please fix!)
52
 
endif
53
 
 
54
 
ifdef O_TARGET
55
 
$(warning kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.6. Please fix!)
56
 
endif
57
 
 
58
 
ifdef L_TARGET
59
 
$(error kbuild: $(obj)/Makefile - Use of L_TARGET is replaced by lib-y in 2.6. Please fix!)
60
 
endif
61
 
 
62
 
ifdef list-multi
63
 
$(warning kbuild: $(obj)/Makefile - list-multi := $(list-multi) is obsolete in 2.6. Please fix!)
64
 
endif
65
 
 
66
72
ifndef obj
67
73
$(warning kbuild: Makefile.build is included improperly)
68
74
endif
77
83
builtin-target := $(obj)/built-in.o
78
84
endif
79
85
 
 
86
modorder-target := # $(obj)/modules.order
 
87
 
80
88
# We keep a list of all modules in $(MODVERDIR)
81
89
 
82
90
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
83
 
         $(if $(KBUILD_MODULES),$(obj-m)) \
 
91
         $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
84
92
         $(subdir-ym) $(always)
85
93
        @:
86
94
 
95
103
  endif
96
104
endif
97
105
 
 
106
# Do section mismatch analysis for each module/built-in.o
 
107
ifdef CONFIG_DEBUG_SECTION_MISMATCH
 
108
  cmd_secanalysis = ; scripts/mod/modpost $@
 
109
endif
98
110
 
99
111
# Compile C sources (.c)
100
112
# ---------------------------------------------------------------------------
116
128
$(obj-m)              : quiet_modtag := [M]
117
129
 
118
130
# Default for not multi-part modules
119
 
modname = $(*F)
 
131
modname = $(basetarget)
120
132
 
121
133
$(multi-objs-m)         : modname = $(modname-multi)
122
134
$(multi-objs-m:.o=.i)   : modname = $(modname-multi)
128
140
$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
129
141
 
130
142
quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
131
 
cmd_cc_s_c       = $(CC) $(c_flags) -S -o $@ $< 
 
143
cmd_cc_s_c       = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
132
144
 
133
 
%.s: %.c FORCE
 
145
$(obj)/%.s: $(src)/%.c FORCE
134
146
        $(call if_changed_dep,cc_s_c)
135
147
 
136
148
quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@
137
149
cmd_cc_i_c       = $(CPP) $(c_flags)   -o $@ $<
138
150
 
139
 
%.i: %.c FORCE
 
151
$(obj)/%.i: $(src)/%.c FORCE
140
152
        $(call if_changed_dep,cc_i_c)
141
153
 
 
154
quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
 
155
cmd_cc_symtypes_c          = \
 
156
                $(CPP) -D__GENKSYMS__ $(c_flags) $<                     \
 
157
                | $(GENKSYMS) -T $@ >/dev/null;                         \
 
158
                test -s $@ || rm -f $@
 
159
 
 
160
$(obj)/%.symtypes : $(src)/%.c FORCE
 
161
        $(call if_changed_dep,cc_symtypes_c)
 
162
 
142
163
# C (.c) files
143
164
# The C file is compiled and updated dependency information is generated.
144
165
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
165
186
cmd_modversions =                                                       \
166
187
        if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then     \
167
188
                $(CPP) -D__GENKSYMS__ $(c_flags) $<                     \
168
 
                | $(GENKSYMS)                                           \
 
189
                | $(GENKSYMS) $(if $(KBUILD_SYMTYPES),                  \
 
190
                              -T $(@D)/$(@F:.o=.symtypes)) -a $(ARCH)   \
169
191
                > $(@D)/.tmp_$(@F:.o=.ver);                             \
170
192
                                                                        \
171
193
                $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F)              \
172
194
                        -T $(@D)/.tmp_$(@F:.o=.ver);                    \
173
195
                rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver);        \
174
196
        else                                                            \
175
 
                mv $(@D)/.tmp_$(@F) $@;                                 \
 
197
                mv -f $(@D)/.tmp_$(@F) $@;                              \
176
198
        fi;
177
199
endif
178
200
 
179
201
define rule_cc_o_c
180
 
        $(if $($(quiet)cmd_checksrc),echo '  $($(quiet)cmd_checksrc)';)   \
181
 
        $(cmd_checksrc)                                                   \
182
 
        $(if $($(quiet)cmd_cc_o_c),echo '  $($(quiet)cmd_cc_o_c)';)       \
183
 
        $(cmd_cc_o_c);                                                    \
 
202
        $(call echo-cmd,checksrc) $(cmd_checksrc)                         \
 
203
        $(call echo-cmd,cc_o_c) $(cmd_cc_o_c);                            \
184
204
        $(cmd_modversions)                                                \
185
 
        scripts/basic/fixdep $(depfile) $@ '$(cmd_cc_o_c)' > $(@D)/.$(@F).tmp;  \
 
205
        scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' >    \
 
206
                                                      $(dot-target).tmp;  \
186
207
        rm -f $(depfile);                                                 \
187
 
        mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
 
208
        mv -f $(dot-target).tmp $(dot-target).cmd
188
209
endef
189
210
 
190
211
# Built-in and composite module parts
191
 
 
192
 
%.o: %.c FORCE
 
212
$(obj)/%.o: $(src)/%.c FORCE
193
213
        $(call cmd,force_checksrc)
194
214
        $(call if_changed_rule,cc_o_c)
195
215
 
196
216
# Single-part modules are special since we need to mark them in $(MODVERDIR)
197
217
 
198
 
$(single-used-m): %.o: %.c FORCE
 
218
$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE
199
219
        $(call cmd,force_checksrc)
200
220
        $(call if_changed_rule,cc_o_c)
201
221
        @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)
203
223
quiet_cmd_cc_lst_c = MKLST   $@
204
224
      cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
205
225
                     $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
206
 
                                     apex.map $(OBJDUMP) > $@
 
226
                                     System.map $(OBJDUMP) > $@
207
227
 
208
 
%.lst: %.c FORCE
 
228
$(obj)/%.lst: $(src)/%.c FORCE
209
229
        $(call if_changed_dep,cc_lst_c)
210
230
 
211
231
# Compile assembler sources (.S)
219
239
quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
220
240
cmd_as_s_S       = $(CPP) $(a_flags)   -o $@ $< 
221
241
 
222
 
%.s: %.S FORCE
 
242
$(obj)/%.s: $(src)/%.S FORCE
223
243
        $(call if_changed_dep,as_s_S)
224
244
 
225
245
quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
226
246
cmd_as_o_S       = $(CC) $(a_flags) -c -o $@ $<
227
247
 
228
 
%.o: %.S FORCE
 
248
$(obj)/%.o: $(src)/%.S FORCE
229
249
        $(call if_changed_dep,as_o_S)
230
250
 
231
251
targets += $(real-objs-y) $(real-objs-m) $(lib-y)
236
256
quiet_cmd_cpp_lds_S = LDS     $@
237
257
      cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $<
238
258
 
239
 
%.lds: %.lds.S FORCE
 
259
$(obj)/%.lds: $(src)/%.lds.S FORCE
240
260
        $(call if_changed_dep,cpp_lds_S)
241
261
 
242
262
# Build the compiled-in targets
252
272
quiet_cmd_link_o_target = LD      $@
253
273
# If the list of objects to link is empty, just create an empty built-in.o
254
274
cmd_link_o_target = $(if $(strip $(obj-y)),\
255
 
                      $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
 
275
                      $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
 
276
                      $(cmd_secanalysis),\
256
277
                      rm -f $@; $(AR) rcs $@)
257
278
 
258
279
$(builtin-target): $(obj-y) FORCE
262
283
endif # builtin-target
263
284
 
264
285
#
 
286
# Rule to create modules.order file
 
287
#
 
288
# Create commands to either record .ko file or cat modules.order from
 
289
# a subdirectory
 
290
modorder-cmds =                                         \
 
291
        $(foreach m, $(modorder),                       \
 
292
                $(if $(filter %/modules.order, $m),     \
 
293
                        cat $m;, echo kernel/$m;))
 
294
 
 
295
$(modorder-target): $(subdir-ym) FORCE
 
296
        $(Q)(cat /dev/null; $(modorder-cmds)) > $@
 
297
 
 
298
#
265
299
# Rule to compile a set of .o files into one .a file
266
300
#
267
301
ifdef lib-target
268
302
quiet_cmd_link_l_target = AR      $@
269
 
cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(lib-y)
 
303
cmd_link_l_target = rm -f $@; $(AR) rcs $@ $(lib-y)
270
304
 
271
305
$(lib-target): $(lib-y) FORCE
272
306
        $(call if_changed,link_l_target)
287
321
$($(subst $(obj)/,,$(@:.o=-y)))), $^)
288
322
 
289
323
quiet_cmd_link_multi-y = LD      $@
290
 
cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
 
324
cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
291
325
 
292
326
quiet_cmd_link_multi-m = LD [M]  $@
293
 
cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
 
327
cmd_link_multi-m = $(cmd_link_multi-y)
294
328
 
295
329
# We would rather have a list of rules like
296
330
#       foo.o: $(foo-objs)
309
343
# Descending
310
344
# ---------------------------------------------------------------------------
311
345
 
312
 
.PHONY: $(subdir-ym)
 
346
PHONY += $(subdir-ym)
313
347
$(subdir-ym):
314
348
        $(Q)$(MAKE) $(build)=$@
315
349
 
316
350
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
317
351
# ---------------------------------------------------------------------------
318
352
 
319
 
.PHONY: FORCE
 
353
PHONY += FORCE
320
354
 
321
355
FORCE:
322
356
 
331
365
ifneq ($(cmd_files),)
332
366
  include $(cmd_files)
333
367
endif
 
368
 
 
369
 
 
370
# Declare the contents of the .PHONY variable as phony.  We keep that
 
371
# information in a variable se we can use it in if_changed and friends.
 
372
 
 
373
.PHONY: $(PHONY)