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
25 # intermediate objects that form part of a module
28 # objects that export symbol tables
46 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -S
$< -o
$@
49 $(CPP
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) $< > $@
52 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -c
-o
$@
$<
54 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
55 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
57 ) > $(dir $@
)/.
$(notdir $@
).flags
60 $(AS
) $(AFLAGS
) $(EXTRA_CFLAGS
) -o
$@
$<
62 # Old makefiles define their own rules for compiling .S files,
63 # but these standard rules are available for any Makefile that
64 # wants to use them. Our plan is to incrementally convert all
65 # the Makefiles to these standard rules. -- rmk, mec
66 ifdef USE_STANDARD_AS_RULE
69 $(CPP
) $(AFLAGS
) $(EXTRA_AFLAGS
) $(AFLAGS_
$@
) $< > $@
72 $(CC
) $(AFLAGS
) $(EXTRA_AFLAGS
) $(AFLAGS_
$@
) -c
-o
$@
$<
79 all_targets
: $(O_TARGET
) $(L_TARGET
)
82 # Rule to compile a set of .o files into one .o file
85 ALL_O
= $(OX_OBJS
) $(O_OBJS
)
88 ifneq "$(strip $(ALL_O))" ""
89 $(LD
) $(EXTRA_LDFLAGS
) -r
-o
$@
$(filter $(ALL_O
), $^
)
91 $(AR
) rcs
$@
$(filter $(ALL_O
), $^
)
94 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(ALL_O))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(ALL_O))))' ; \
95 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
97 ) > $(dir $@
)/.
$(notdir $@
).flags
101 # Rule to compile a set of .o files into one .a file
104 $(L_TARGET
): $(LX_OBJS
) $(L_OBJS
)
106 $(AR
) $(EXTRA_ARFLAGS
) rcs
$@
$(LX_OBJS
) $(L_OBJS
)
108 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(LX_OBJS) $(L_OBJS))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(LX_OBJS) $$(L_OBJS))))' ; \
109 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
111 ) > $(dir $@
)/.
$(notdir $@
).flags
115 # This make dependencies quickly
118 $(TOPDIR
)/scripts
/mkdep
$(wildcard *.
[chS
] local.h.master
) > .depend
120 $(MAKE
) $(patsubst %,_sfdep_
%,$(ALL_SUB_DIRS
)) _FASTDEP_ALL_SUB_DIRS
="$(ALL_SUB_DIRS)"
123 ifdef _FASTDEP_ALL_SUB_DIRS
124 $(patsubst %,_sfdep_
%,$(_FASTDEP_ALL_SUB_DIRS
)):
125 $(MAKE
) -C
$(patsubst _sfdep_
%,%,$@
) fastdep
130 # A rule to make subdirectories
132 sub_dirs
: dummy
$(patsubst %,_subdir_
%,$(SUB_DIRS
))
135 $(patsubst %,_subdir_
%,$(SUB_DIRS
)) : dummy
136 $(MAKE
) -C
$(patsubst _subdir_
%,%,$@
)
140 # A rule to make modules
142 ALL_MOBJS
= $(MX_OBJS
) $(M_OBJS
)
143 ifneq "$(strip $(ALL_MOBJS))" ""
144 PDWN
=$(shell $(CONFIG_SHELL
) $(TOPDIR
)/scripts
/pathdown.sh
)
148 MOD_DIRS
:= $(MOD_SUB_DIRS
) $(MOD_IN_SUB_DIRS
)
149 ifneq "$(strip $(MOD_DIRS))" ""
150 .PHONY
: $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
151 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
)) : dummy
152 $(MAKE
) -C
$(patsubst _modsubdir_
%,%,$@
) modules
154 .PHONY
: $(patsubst %,_modinst_
%,$(MOD_DIRS
))
155 $(patsubst %,_modinst_
%,$(MOD_DIRS
)) : dummy
156 $(MAKE
) -C
$(patsubst _modinst_
%,%,$@
) modules_install
160 modules
: $(ALL_MOBJS
) $(MIX_OBJS
) $(MI_OBJS
) dummy \
161 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
165 ifneq "$(strip $(ALL_MOBJS))" ""
166 mkdir
-p
$(MODLIB
)/kernel
/$(PDWN
)
167 cp
$(ALL_MOBJS
) $(MODLIB
)/kernel
/$(PDWN
)
170 .PHONY
: modules_install
171 modules_install
: _modinst__ \
172 $(patsubst %,_modinst_
%,$(MOD_DIRS
))
175 # A rule to do nothing
180 # This is useful for testing
186 # This sets version suffixes on exported symbols
188 # Separate the object into "normal" objects and "exporting" objects
189 # Exporting objects are: all objects that define symbol tables
193 SYMTAB_OBJS
= $(LX_OBJS
) $(OX_OBJS
) $(MX_OBJS
) $(MIX_OBJS
)
195 ifdef CONFIG_MODVERSIONS
196 ifneq "$(strip $(SYMTAB_OBJS))" ""
198 MODINCL
= $(TOPDIR
)/include/linux
/modules
200 # The -w option (enable warnings) for genksyms will return here in 2.1
201 # So where has it gone?
203 # Added the SMP separator to stop module accidents between uniprocessor
204 # and SMP Intel boxes - AC - from bits by Michael Chastain
208 genksyms_smp_prefix
:= -p smp_
210 genksyms_smp_prefix
:=
213 $(MODINCL
)/%.ver
: %.c
214 @if
[ ! -r
$(MODINCL
)/$*.stamp
-o
$(MODINCL
)/$*.stamp
-ot
$< ]; then \
215 echo
'$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
216 echo
'| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
217 $(CC
) $(CFLAGS
) -E
-D__GENKSYMS__
$< \
218 |
$(GENKSYMS
) $(genksyms_smp_prefix
) -k
$(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
) > $@.tmp
; \
219 if
[ -r
$@
] && cmp
-s
$@
$@.tmp
; then echo
$@ is unchanged
; rm -f
$@.tmp
; \
220 else echo mv
$@.tmp
$@
; mv
-f
$@.tmp
$@
; fi
; \
221 fi
; touch
$(MODINCL
)/$*.stamp
223 $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
)): $(TOPDIR
)/include/linux
/autoconf.h
225 # updates .ver files but not modversions.h
226 fastdep
: $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
))
228 # updates .ver files and modversions.h like before (is this needed?)
229 dep
: fastdep update-modverfile
233 # update modversions.h, but only if it would change
235 @
(echo
"#ifndef _LINUX_MODVERSIONS_H";\
236 echo
"#define _LINUX_MODVERSIONS_H"; \
237 echo
"#include <linux/modsetver.h>"; \
238 cd
$(TOPDIR
)/include/linux
/modules
; \
240 if
[ -f
$$f ]; then echo
"#include <linux/modules/$${f}>"; fi
; \
243 ) > $(TOPDIR
)/include/linux
/modversions.h.tmp
244 @if
[ -r
$(TOPDIR
)/include/linux
/modversions.h
] && cmp
-s
$(TOPDIR
)/include/linux
/modversions.h
$(TOPDIR
)/include/linux
/modversions.h.tmp
; then \
245 echo
$(TOPDIR
)/include/linux
/modversions.h was not updated
; \
246 rm -f
$(TOPDIR
)/include/linux
/modversions.h.tmp
; \
248 echo
$(TOPDIR
)/include/linux
/modversions.h was updated
; \
249 mv
-f
$(TOPDIR
)/include/linux
/modversions.h.tmp
$(TOPDIR
)/include/linux
/modversions.h
; \
252 $(M_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
254 $(O_OBJS
) $(L_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
259 $(TOPDIR
)/include/linux
/modversions.h
:
260 @echo
"#include <linux/modsetver.h>" > $@
262 endif # CONFIG_MODVERSIONS
264 ifneq "$(strip $(SYMTAB_OBJS))" ""
265 $(SYMTAB_OBJS
): $(SYMTAB_OBJS
:.o
=.c
) $(TOPDIR
)/include/linux
/modversions.h
266 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -DEXPORT_SYMTAB
-c
$(@
:.o
=.c
)
268 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
269 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
271 ) > $(dir $@
)/.
$(notdir $@
).flags
274 endif # CONFIG_MODULES
278 # include dependency files if they exist
280 ifneq ($(wildcard .depend
),)
284 ifneq ($(wildcard $(TOPDIR
)/.hdepend
),)
285 include $(TOPDIR
)/.hdepend
289 # Find files whose flags have changed and force recompilation.
290 # For safety, this works in the converse direction:
291 # every file is forced, except those whose flags are positively up-to-date.
293 FILES_FLAGS_UP_TO_DATE
:=
295 # For use in expunging commas from flags, which mung our checking.
298 FILES_FLAGS_EXIST
:= $(wildcard .
*.flags
)
299 ifneq ($(FILES_FLAGS_EXIST
),)
300 include $(FILES_FLAGS_EXIST
)
303 FILES_FLAGS_CHANGED
:= $(strip \
304 $(filter-out $(FILES_FLAGS_UP_TO_DATE
), \
305 $(O_TARGET
) $(O_OBJS
) $(OX_OBJS
) \
306 $(L_TARGET
) $(L_OBJS
) $(LX_OBJS
) \
307 $(M_OBJS
) $(MX_OBJS
) \
308 $(MI_OBJS
) $(MIX_OBJS
) \
311 # A kludge: .S files don't get flag dependencies (yet),
312 # because that will involve changing a lot of Makefiles. Also
313 # suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
314 # This allows handling of assembly files that get translated into
315 # multiple object files (see arch/ia64/lib/idiv.S, for example).
316 FILES_FLAGS_CHANGED
:= $(strip \
317 $(filter-out $(patsubst %.S
, %.o
, $(wildcard *.S
) $(IGNORE_FLAGS_OBJS
)), \
318 $(FILES_FLAGS_CHANGED
)))
320 ifneq ($(FILES_FLAGS_CHANGED
),)
321 $(FILES_FLAGS_CHANGED
): dummy