2 # This file contains rules which are shared between multiple Makefiles.
11 # Special variables which should not be exported
13 unexport EXTRA_ASFLAGS
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
) $(ASFLAGS
) $(EXTRA_CFLAGS
) -o
$@
$<
65 all_targets
: $(O_TARGET
) $(L_TARGET
)
68 # Rule to compile a set of .o files into one .o file
71 ALL_O
= $(OX_OBJS
) $(O_OBJS
)
74 ifneq "$(strip $(ALL_O))" ""
75 $(LD
) $(EXTRA_LDFLAGS
) -r
-o
$@
$(filter $(ALL_O
), $^
)
77 $(AR
) rcs
$@
$(filter $(ALL_O
), $^
)
80 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(ALL_O))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(ALL_O))))' ; \
81 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
83 ) > $(dir $@
)/.
$(notdir $@
).flags
87 # Rule to compile a set of .o files into one .a file
90 $(L_TARGET
): $(LX_OBJS
) $(L_OBJS
)
92 $(AR
) $(EXTRA_ARFLAGS
) rcs
$@
$(LX_OBJS
) $(L_OBJS
)
94 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(LX_OBJS) $(L_OBJS))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(LX_OBJS) $$(L_OBJS))))' ; \
95 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
97 ) > $(dir $@
)/.
$(notdir $@
).flags
101 # This make dependencies quickly
104 $(TOPDIR
)/scripts
/mkdep
$(wildcard *.
[chS
] local.h.master
) > .depend
106 $(MAKE
) $(patsubst %,_sfdep_
%,$(ALL_SUB_DIRS
)) _FASTDEP_ALL_SUB_DIRS
="$(ALL_SUB_DIRS)"
109 ifdef _FASTDEP_ALL_SUB_DIRS
110 $(patsubst %,_sfdep_
%,$(_FASTDEP_ALL_SUB_DIRS
)):
111 $(MAKE
) -C
$(patsubst _sfdep_
%,%,$@
) fastdep
116 # A rule to make subdirectories
118 sub_dirs
: dummy
$(patsubst %,_subdir_
%,$(SUB_DIRS
))
121 $(patsubst %,_subdir_
%,$(SUB_DIRS
)) : dummy
122 $(MAKE
) -C
$(patsubst _subdir_
%,%,$@
)
126 # A rule to make modules
128 ALL_MOBJS
= $(MX_OBJS
) $(M_OBJS
)
129 ifneq "$(strip $(ALL_MOBJS))" ""
130 PDWN
=$(shell $(CONFIG_SHELL
) $(TOPDIR
)/scripts
/pathdown.sh
)
134 MOD_DIRS
:= $(MOD_SUB_DIRS
) $(MOD_IN_SUB_DIRS
)
135 ifneq "$(strip $(MOD_DIRS))" ""
136 .PHONY
: $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
137 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
)) : dummy
138 $(MAKE
) -C
$(patsubst _modsubdir_
%,%,$@
) modules
140 .PHONY
: $(patsubst %,_modinst_
%,$(MOD_DIRS
))
141 $(patsubst %,_modinst_
%,$(MOD_DIRS
)) : dummy
142 $(MAKE
) -C
$(patsubst _modinst_
%,%,$@
) modules_install
146 modules
: $(ALL_MOBJS
) $(MIX_OBJS
) $(MI_OBJS
) dummy \
147 $(patsubst %,_modsubdir_
%,$(MOD_DIRS
))
151 ifneq "$(strip $(ALL_MOBJS))" ""
152 mkdir
-p
$(MODLIB
)/kernel
/$(PDWN
)
153 cp
$(ALL_MOBJS
) $(MODLIB
)/kernel
/$(PDWN
)
156 .PHONY
: modules_install
157 modules_install
: _modinst__ \
158 $(patsubst %,_modinst_
%,$(MOD_DIRS
))
161 # A rule to do nothing
166 # This is useful for testing
172 # This sets version suffixes on exported symbols
174 # Separate the object into "normal" objects and "exporting" objects
175 # Exporting objects are: all objects that define symbol tables
179 SYMTAB_OBJS
= $(LX_OBJS
) $(OX_OBJS
) $(MX_OBJS
) $(MIX_OBJS
)
181 ifdef CONFIG_MODVERSIONS
182 ifneq "$(strip $(SYMTAB_OBJS))" ""
184 MODINCL
= $(TOPDIR
)/include/linux
/modules
186 # The -w option (enable warnings) for genksyms will return here in 2.1
187 # So where has it gone?
189 # Added the SMP separator to stop module accidents between uniprocessor
190 # and SMP Intel boxes - AC - from bits by Michael Chastain
194 genksyms_smp_prefix
:= -p smp_
196 genksyms_smp_prefix
:=
199 $(MODINCL
)/%.ver
: %.c
200 @if
[ ! -r
$(MODINCL
)/$*.stamp
-o
$(MODINCL
)/$*.stamp
-ot
$< ]; then \
201 echo
'$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
202 echo
'| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
203 $(CC
) $(CFLAGS
) -E
-D__GENKSYMS__
$< \
204 |
$(GENKSYMS
) $(genksyms_smp_prefix
) -k
$(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
) > $@.tmp
; \
205 if
[ -r
$@
] && cmp
-s
$@
$@.tmp
; then echo
$@ is unchanged
; rm -f
$@.tmp
; \
206 else echo mv
$@.tmp
$@
; mv
-f
$@.tmp
$@
; fi
; \
207 fi
; touch
$(MODINCL
)/$*.stamp
209 $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
)): $(TOPDIR
)/include/linux
/autoconf.h
211 $(TOPDIR
)/include/linux
/modversions.h
: $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
))
212 @echo updating
$(TOPDIR
)/include/linux
/modversions.h
213 @
(echo
"#ifndef _LINUX_MODVERSIONS_H";\
214 echo
"#define _LINUX_MODVERSIONS_H"; \
215 echo
"#include <linux/modsetver.h>"; \
216 cd
$(TOPDIR
)/include/linux
/modules
; \
218 if
[ -f
$$f ]; then echo
"#include <linux/modules/$${f}>"; fi
; \
223 dep fastdep
: $(TOPDIR
)/include/linux
/modversions.h
227 $(M_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
229 $(O_OBJS
) $(L_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
234 $(TOPDIR
)/include/linux
/modversions.h
:
235 @echo
"#include <linux/modsetver.h>" > $@
237 endif # CONFIG_MODVERSIONS
239 ifneq "$(strip $(SYMTAB_OBJS))" ""
240 $(SYMTAB_OBJS
): $(SYMTAB_OBJS
:.o
=.c
) $(TOPDIR
)/include/linux
/modversions.h
241 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -DEXPORT_SYMTAB
-c
$(@
:.o
=.c
)
243 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
244 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
246 ) > $(dir $@
)/.
$(notdir $@
).flags
249 endif # CONFIG_MODULES
253 # include dependency files if they exist
255 ifneq ($(wildcard .depend
),)
259 ifneq ($(wildcard $(TOPDIR
)/.hdepend
),)
260 include $(TOPDIR
)/.hdepend
264 # Find files whose flags have changed and force recompilation.
265 # For safety, this works in the converse direction:
266 # every file is forced, except those whose flags are positively up-to-date.
268 FILES_FLAGS_UP_TO_DATE
:=
270 # For use in expunging commas from flags, which mung our checking.
273 FILES_FLAGS_EXIST
:= $(wildcard .
*.flags
)
274 ifneq ($(FILES_FLAGS_EXIST
),)
275 include $(FILES_FLAGS_EXIST
)
278 FILES_FLAGS_CHANGED
:= $(strip \
279 $(filter-out $(FILES_FLAGS_UP_TO_DATE
), \
280 $(O_TARGET
) $(O_OBJS
) $(OX_OBJS
) \
281 $(L_TARGET
) $(L_OBJS
) $(LX_OBJS
) \
282 $(M_OBJS
) $(MX_OBJS
) \
283 $(MI_OBJS
) $(MIX_OBJS
) \
286 # A kludge: .S files don't get flag dependencies (yet),
287 # because that will involve changing a lot of Makefiles. Also
288 # suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
289 # This allows handling of assembly files that get translated into
290 # multiple object files (see arch/ia64/lib/idiv.S, for example).
291 FILES_FLAGS_CHANGED
:= $(strip \
292 $(filter-out $(patsubst %.S
, %.o
, $(wildcard *.S
) $(IGNORE_FLAGS_OBJS
)), \
293 $(FILES_FLAGS_CHANGED
)))
295 ifneq ($(FILES_FLAGS_CHANGED
),)
296 $(FILES_FLAGS_CHANGED
): dummy