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
$@
$<
77 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -g
-c
-o
$*.o
$<
78 $(TOPDIR
)/scripts
/makelst
$* $(TOPDIR
) $(OBJDUMP
)
82 all_targets
: $(O_TARGET
) $(L_TARGET
)
85 # Rule to compile a set of .o files into one .o file
88 ALL_O
= $(OX_OBJS
) $(O_OBJS
)
91 ifneq "$(strip $(ALL_O))" ""
92 $(LD
) $(EXTRA_LDFLAGS
) -r
-o
$@
$(filter $(ALL_O
), $^
)
94 $(AR
) rcs
$@
$(filter $(ALL_O
), $^
)
97 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(ALL_O))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(ALL_O))))' ; \
98 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
100 ) > $(dir $@
)/.
$(notdir $@
).flags
104 # Rule to compile a set of .o files into one .a file
107 $(L_TARGET
): $(LX_OBJS
) $(L_OBJS
)
109 $(AR
) $(EXTRA_ARFLAGS
) rcs
$@
$(LX_OBJS
) $(L_OBJS
)
111 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(LX_OBJS) $(L_OBJS))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(LX_OBJS) $$(L_OBJS))))' ; \
112 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
114 ) > $(dir $@
)/.
$(notdir $@
).flags
118 # This make dependencies quickly
121 $(TOPDIR
)/scripts
/mkdep
$(wildcard *.
[chS
] local.h.master
) > .depend
123 $(MAKE
) $(patsubst %,_sfdep_
%,$(ALL_SUB_DIRS
)) _FASTDEP_ALL_SUB_DIRS
="$(ALL_SUB_DIRS)"
126 ifdef _FASTDEP_ALL_SUB_DIRS
127 $(patsubst %,_sfdep_
%,$(_FASTDEP_ALL_SUB_DIRS
)):
128 $(MAKE
) -C
$(patsubst _sfdep_
%,%,$@
) fastdep
133 # A rule to make subdirectories
135 sub_dirs
: dummy
$(patsubst %,_subdir_
%,$(SUB_DIRS
))
138 $(patsubst %,_subdir_
%,$(SUB_DIRS
)) : dummy
139 $(MAKE
) -C
$(patsubst _subdir_
%,%,$@
)
143 # A rule to make modules
145 ALL_MOBJS
= $(MX_OBJS
) $(M_OBJS
)
146 ifneq "$(strip $(ALL_MOBJS))" ""
147 PDWN
=$(shell $(CONFIG_SHELL
) $(TOPDIR
)/scripts
/pathdown.sh
)
151 MOD_DIRS
:= $(MOD_SUB_DIRS
) $(MOD_IN_SUB_DIRS
)
152 ifneq "$(strip $(MOD_DIRS))" ""
153 .PHONY
: $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
154 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
)) : dummy
155 $(MAKE
) -C
$(patsubst _modsubdir_
%,%,$@
) modules
157 .PHONY
: $(patsubst %,_modinst_
%,$(MOD_DIRS
))
158 $(patsubst %,_modinst_
%,$(MOD_DIRS
)) : dummy
159 $(MAKE
) -C
$(patsubst _modinst_
%,%,$@
) modules_install
163 modules
: $(ALL_MOBJS
) $(MIX_OBJS
) $(MI_OBJS
) dummy \
164 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
168 ifneq "$(strip $(ALL_MOBJS))" ""
169 mkdir
-p
$(MODLIB
)/kernel
/$(PDWN
)
170 cp
$(ALL_MOBJS
) $(MODLIB
)/kernel
/$(PDWN
)
173 .PHONY
: modules_install
174 modules_install
: _modinst__ \
175 $(patsubst %,_modinst_
%,$(MOD_DIRS
))
178 # A rule to do nothing
183 # This is useful for testing
189 # This sets version suffixes on exported symbols
191 # Separate the object into "normal" objects and "exporting" objects
192 # Exporting objects are: all objects that define symbol tables
196 SYMTAB_OBJS
= $(LX_OBJS
) $(OX_OBJS
) $(MX_OBJS
) $(MIX_OBJS
)
198 ifdef CONFIG_MODVERSIONS
199 ifneq "$(strip $(SYMTAB_OBJS))" ""
201 MODINCL
= $(TOPDIR
)/include/linux
/modules
203 # The -w option (enable warnings) for genksyms will return here in 2.1
204 # So where has it gone?
206 # Added the SMP separator to stop module accidents between uniprocessor
207 # and SMP Intel boxes - AC - from bits by Michael Chastain
211 genksyms_smp_prefix
:= -p smp_
213 genksyms_smp_prefix
:=
216 $(MODINCL
)/%.ver
: %.c
217 @if
[ ! -r
$(MODINCL
)/$*.stamp
-o
$(MODINCL
)/$*.stamp
-ot
$< ]; then \
218 echo
'$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
219 echo
'| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
220 $(CC
) $(CFLAGS
) -E
-D__GENKSYMS__
$< \
221 |
$(GENKSYMS
) $(genksyms_smp_prefix
) -k
$(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
) > $@.tmp
; \
222 if
[ -r
$@
] && cmp
-s
$@
$@.tmp
; then echo
$@ is unchanged
; rm -f
$@.tmp
; \
223 else echo mv
$@.tmp
$@
; mv
-f
$@.tmp
$@
; fi
; \
224 fi
; touch
$(MODINCL
)/$*.stamp
226 $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
)): $(TOPDIR
)/include/linux
/autoconf.h
228 # updates .ver files but not modversions.h
229 fastdep
: $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
))
231 # updates .ver files and modversions.h like before (is this needed?)
232 dep
: fastdep update-modverfile
236 # update modversions.h, but only if it would change
238 @
(echo
"#ifndef _LINUX_MODVERSIONS_H";\
239 echo
"#define _LINUX_MODVERSIONS_H"; \
240 echo
"#include <linux/modsetver.h>"; \
241 cd
$(TOPDIR
)/include/linux
/modules
; \
243 if
[ -f
$$f ]; then echo
"#include <linux/modules/$${f}>"; fi
; \
246 ) > $(TOPDIR
)/include/linux
/modversions.h.tmp
247 @if
[ -r
$(TOPDIR
)/include/linux
/modversions.h
] && cmp
-s
$(TOPDIR
)/include/linux
/modversions.h
$(TOPDIR
)/include/linux
/modversions.h.tmp
; then \
248 echo
$(TOPDIR
)/include/linux
/modversions.h was not updated
; \
249 rm -f
$(TOPDIR
)/include/linux
/modversions.h.tmp
; \
251 echo
$(TOPDIR
)/include/linux
/modversions.h was updated
; \
252 mv
-f
$(TOPDIR
)/include/linux
/modversions.h.tmp
$(TOPDIR
)/include/linux
/modversions.h
; \
255 $(M_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
257 $(O_OBJS
) $(L_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
262 $(TOPDIR
)/include/linux
/modversions.h
:
263 @echo
"#include <linux/modsetver.h>" > $@
265 endif # CONFIG_MODVERSIONS
267 ifneq "$(strip $(SYMTAB_OBJS))" ""
268 $(SYMTAB_OBJS
): $(SYMTAB_OBJS
:.o
=.c
) $(TOPDIR
)/include/linux
/modversions.h
269 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -DEXPORT_SYMTAB
-c
$(@
:.o
=.c
)
271 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
272 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
274 ) > $(dir $@
)/.
$(notdir $@
).flags
277 endif # CONFIG_MODULES
281 # include dependency files if they exist
283 ifneq ($(wildcard .depend
),)
287 ifneq ($(wildcard $(TOPDIR
)/.hdepend
),)
288 include $(TOPDIR
)/.hdepend
292 # Find files whose flags have changed and force recompilation.
293 # For safety, this works in the converse direction:
294 # every file is forced, except those whose flags are positively up-to-date.
296 FILES_FLAGS_UP_TO_DATE
:=
298 # For use in expunging commas from flags, which mung our checking.
301 FILES_FLAGS_EXIST
:= $(wildcard .
*.flags
)
302 ifneq ($(FILES_FLAGS_EXIST
),)
303 include $(FILES_FLAGS_EXIST
)
306 FILES_FLAGS_CHANGED
:= $(strip \
307 $(filter-out $(FILES_FLAGS_UP_TO_DATE
), \
308 $(O_TARGET
) $(O_OBJS
) $(OX_OBJS
) \
309 $(L_TARGET
) $(L_OBJS
) $(LX_OBJS
) \
310 $(M_OBJS
) $(MX_OBJS
) \
311 $(MI_OBJS
) $(MIX_OBJS
) \
314 # A kludge: .S files don't get flag dependencies (yet),
315 # because that will involve changing a lot of Makefiles. Also
316 # suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
317 # This allows handling of assembly files that get translated into
318 # multiple object files (see arch/ia64/lib/idiv.S, for example).
319 FILES_FLAGS_CHANGED
:= $(strip \
320 $(filter-out $(patsubst %.S
, %.o
, $(wildcard *.S
) $(IGNORE_FLAGS_OBJS
)), \
321 $(FILES_FLAGS_CHANGED
)))
323 ifneq ($(FILES_FLAGS_CHANGED
),)
324 $(FILES_FLAGS_CHANGED
): dummy