2 # This file contains rules which are shared between multiple Makefiles.
11 # Special variables which should not be exported
15 unexport EXTRA_LDFLAGS
16 unexport EXTRA_ARFLAGS
40 both-m
:= $(filter $(mod-subdirs
), $(subdir-y
))
41 SUB_DIRS
:= $(subdir-y
)
42 MOD_SUB_DIRS
:= $(sort $(subdir-m
) $(both-m
))
43 ALL_SUB_DIRS
:= $(sort $(subdir-y
) $(subdir-m
) $(subdir-n
) $(subdir-
))
51 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -S
$< -o
$@
54 $(CPP
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) $< > $@
57 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -c
-o
$@
$<
59 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
60 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
62 ) > $(dir $@
)/.
$(notdir $@
).flags
65 $(AS
) $(AFLAGS
) $(EXTRA_CFLAGS
) -o
$@
$<
67 # Old makefiles define their own rules for compiling .S files,
68 # but these standard rules are available for any Makefile that
69 # wants to use them. Our plan is to incrementally convert all
70 # the Makefiles to these standard rules. -- rmk, mec
71 ifdef USE_STANDARD_AS_RULE
74 $(CPP
) $(AFLAGS
) $(EXTRA_AFLAGS
) $(AFLAGS_
$@
) $< > $@
77 $(CC
) $(AFLAGS
) $(EXTRA_AFLAGS
) $(AFLAGS_
$@
) -c
-o
$@
$<
82 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -g
-c
-o
$*.o
$<
83 $(TOPDIR
)/scripts
/makelst
$* $(TOPDIR
) $(OBJDUMP
)
87 all_targets
: $(O_TARGET
) $(L_TARGET
)
90 # Rule to compile a set of .o files into one .o file
95 ifneq "$(strip $(obj-y))" ""
96 $(LD
) $(EXTRA_LDFLAGS
) -r
-o
$@
$(filter $(obj-y
), $^
)
101 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
102 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
104 ) > $(dir $@
)/.
$(notdir $@
).flags
108 # Rule to compile a set of .o files into one .a file
111 $(L_TARGET
): $(obj-y
)
113 $(AR
) $(EXTRA_ARFLAGS
) rcs
$@
$(obj-y
)
115 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \
116 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
118 ) > $(dir $@
)/.
$(notdir $@
).flags
123 # This make dependencies quickly
126 $(TOPDIR
)/scripts
/mkdep
$(wildcard *.
[chS
] local.h.master
) > .depend
128 $(MAKE
) $(patsubst %,_sfdep_
%,$(ALL_SUB_DIRS
)) _FASTDEP_ALL_SUB_DIRS
="$(ALL_SUB_DIRS)"
131 ifdef _FASTDEP_ALL_SUB_DIRS
132 $(patsubst %,_sfdep_
%,$(_FASTDEP_ALL_SUB_DIRS
)):
133 $(MAKE
) -C
$(patsubst _sfdep_
%,%,$@
) fastdep
138 # A rule to make subdirectories
140 subdir-list
= $(sort $(patsubst %,_subdir_
%,$(SUB_DIRS
)))
141 sub_dirs
: dummy
$(subdir-list
)
144 $(subdir-list
) : dummy
145 $(MAKE
) -C
$(patsubst _subdir_
%,%,$@
)
149 # A rule to make modules
151 ALL_MOBJS
= $(filter-out $(obj-y
), $(obj-m
))
152 ifneq "$(strip $(ALL_MOBJS))" ""
153 PDWN
=$(shell $(CONFIG_SHELL
) $(TOPDIR
)/scripts
/pathdown.sh
)
157 MOD_DIRS
:= $(MOD_SUB_DIRS
) $(MOD_IN_SUB_DIRS
)
158 ifneq "$(strip $(MOD_DIRS))" ""
159 .PHONY
: $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
160 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
)) : dummy
161 $(MAKE
) -C
$(patsubst _modsubdir_
%,%,$@
) modules
163 .PHONY
: $(patsubst %,_modinst_
%,$(MOD_DIRS
))
164 $(patsubst %,_modinst_
%,$(MOD_DIRS
)) : dummy
165 $(MAKE
) -C
$(patsubst _modinst_
%,%,$@
) modules_install
169 modules
: $(ALL_MOBJS
) dummy \
170 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
174 ifneq "$(strip $(ALL_MOBJS))" ""
175 mkdir
-p
$(MODLIB
)/kernel
/$(PDWN
)
176 cp
$(ALL_MOBJS
) $(MODLIB
)/kernel
/$(PDWN
)
179 .PHONY
: modules_install
180 modules_install
: _modinst__ \
181 $(patsubst %,_modinst_
%,$(MOD_DIRS
))
184 # A rule to do nothing
189 # This is useful for testing
195 # This sets version suffixes on exported symbols
196 # Separate the object into "normal" objects and "exporting" objects
197 # Exporting objects are: all objects that define symbol tables
201 multi-used
:= $(filter $(list-multi
), $(obj-y
) $(obj-m
))
202 multi-objs
:= $(foreach m
, $(multi-used
), $($(basename $(m
))-objs
))
203 active-objs
:= $(sort $(multi-objs
) $(obj-y
) $(obj-m
))
205 ifdef CONFIG_MODVERSIONS
206 ifneq "$(strip $(export-objs))" ""
208 MODINCL
= $(TOPDIR
)/include/linux
/modules
210 # The -w option (enable warnings) for genksyms will return here in 2.1
211 # So where has it gone?
213 # Added the SMP separator to stop module accidents between uniprocessor
214 # and SMP Intel boxes - AC - from bits by Michael Chastain
218 genksyms_smp_prefix
:= -p smp_
220 genksyms_smp_prefix
:=
223 $(MODINCL
)/%.ver
: %.c
224 @if
[ ! -r
$(MODINCL
)/$*.stamp
-o
$(MODINCL
)/$*.stamp
-ot
$< ]; then \
225 echo
'$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
226 echo
'| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
227 $(CC
) $(CFLAGS
) -E
-D__GENKSYMS__
$< \
228 |
$(GENKSYMS
) $(genksyms_smp_prefix
) -k
$(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
) > $@.tmp
; \
229 if
[ -r
$@
] && cmp
-s
$@
$@.tmp
; then echo
$@ is unchanged
; rm -f
$@.tmp
; \
230 else echo mv
$@.tmp
$@
; mv
-f
$@.tmp
$@
; fi
; \
231 fi
; touch
$(MODINCL
)/$*.stamp
233 $(addprefix $(MODINCL
)/,$(export-objs
:.o
=.ver
)): $(TOPDIR
)/include/linux
/autoconf.h
235 # updates .ver files but not modversions.h
236 fastdep
: $(addprefix $(MODINCL
)/,$(export-objs
:.o
=.ver
))
238 # updates .ver files and modversions.h like before (is this needed?)
239 dep
: fastdep update-modverfile
243 # update modversions.h, but only if it would change
245 @
(echo
"#ifndef _LINUX_MODVERSIONS_H";\
246 echo
"#define _LINUX_MODVERSIONS_H"; \
247 echo
"#include <linux/modsetver.h>"; \
248 cd
$(TOPDIR
)/include/linux
/modules
; \
250 if
[ -f
$$f ]; then echo
"#include <linux/modules/$${f}>"; fi
; \
253 ) > $(TOPDIR
)/include/linux
/modversions.h.tmp
254 @if
[ -r
$(TOPDIR
)/include/linux
/modversions.h
] && cmp
-s
$(TOPDIR
)/include/linux
/modversions.h
$(TOPDIR
)/include/linux
/modversions.h.tmp
; then \
255 echo
$(TOPDIR
)/include/linux
/modversions.h was not updated
; \
256 rm -f
$(TOPDIR
)/include/linux
/modversions.h.tmp
; \
258 echo
$(TOPDIR
)/include/linux
/modversions.h was updated
; \
259 mv
-f
$(TOPDIR
)/include/linux
/modversions.h.tmp
$(TOPDIR
)/include/linux
/modversions.h
; \
262 $(active-objs
): $(TOPDIR
)/include/linux
/modversions.h
266 $(TOPDIR
)/include/linux
/modversions.h
:
267 @echo
"#include <linux/modsetver.h>" > $@
269 endif # CONFIG_MODVERSIONS
271 ifneq "$(strip $(export-objs))" ""
272 $(export-objs
): $(export-objs
:.o
=.c
) $(TOPDIR
)/include/linux
/modversions.h
273 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -DEXPORT_SYMTAB
-c
$(@
:.o
=.c
)
275 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
276 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
278 ) > $(dir $@
)/.
$(notdir $@
).flags
281 endif # CONFIG_MODULES
285 # include dependency files if they exist
287 ifneq ($(wildcard .depend
),)
291 ifneq ($(wildcard $(TOPDIR
)/.hdepend
),)
292 include $(TOPDIR
)/.hdepend
296 # Find files whose flags have changed and force recompilation.
297 # For safety, this works in the converse direction:
298 # every file is forced, except those whose flags are positively up-to-date.
300 FILES_FLAGS_UP_TO_DATE
:=
302 # For use in expunging commas from flags, which mung our checking.
305 FILES_FLAGS_EXIST
:= $(wildcard .
*.flags
)
306 ifneq ($(FILES_FLAGS_EXIST
),)
307 include $(FILES_FLAGS_EXIST
)
310 FILES_FLAGS_CHANGED
:= $(strip \
311 $(filter-out $(FILES_FLAGS_UP_TO_DATE
), \
312 $(O_TARGET
) $(L_TARGET
) $(active-objs
) \
315 # A kludge: .S files don't get flag dependencies (yet),
316 # because that will involve changing a lot of Makefiles. Also
317 # suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
318 # This allows handling of assembly files that get translated into
319 # multiple object files (see arch/ia64/lib/idiv.S, for example).
320 FILES_FLAGS_CHANGED
:= $(strip \
321 $(filter-out $(patsubst %.S
, %.o
, $(wildcard *.S
) $(IGNORE_FLAGS_OBJS
)), \
322 $(FILES_FLAGS_CHANGED
)))
324 ifneq ($(FILES_FLAGS_CHANGED
),)
325 $(FILES_FLAGS_CHANGED
): dummy