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
35 unexport MOD_LIST_NAME
48 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -S
$< -o
$@
51 $(CPP
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) $< > $@
54 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -c
-o
$@
$<
56 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
57 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
59 ) > $(dir $@
)/.
$(notdir $@
).flags
62 $(AS
) $(ASFLAGS
) $(EXTRA_CFLAGS
) -o
$@
$<
67 all_targets
: $(O_TARGET
) $(L_TARGET
)
70 # Rule to compile a set of .o files into one .o file
73 ALL_O
= $(OX_OBJS
) $(O_OBJS
)
76 ifneq "$(strip $(ALL_O))" ""
77 $(LD
) $(EXTRA_LDFLAGS
) -r
-o
$@
$(filter $(ALL_O
), $^
)
79 $(AR
) rcs
$@
$(filter $(ALL_O
), $^
)
82 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(ALL_O))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(ALL_O))))' ; \
83 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
85 ) > $(dir $@
)/.
$(notdir $@
).flags
89 # Rule to compile a set of .o files into one .a file
92 $(L_TARGET
): $(LX_OBJS
) $(L_OBJS
)
94 $(AR
) $(EXTRA_ARFLAGS
) rcs
$@
$(LX_OBJS
) $(L_OBJS
)
96 echo
'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(LX_OBJS) $(L_OBJS))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(LX_OBJS) $$(L_OBJS))))' ; \
97 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
99 ) > $(dir $@
)/.
$(notdir $@
).flags
103 # This make dependencies quickly
106 $(TOPDIR
)/scripts
/mkdep
$(wildcard *.
[chS
] local.h.master
) > .depend
108 $(MAKE
) $(patsubst %,_sfdep_
%,$(ALL_SUB_DIRS
)) _FASTDEP_ALL_SUB_DIRS
="$(ALL_SUB_DIRS)"
111 ifdef _FASTDEP_ALL_SUB_DIRS
112 $(patsubst %,_sfdep_
%,$(_FASTDEP_ALL_SUB_DIRS
)):
113 $(MAKE
) -C
$(patsubst _sfdep_
%,%,$@
) fastdep
118 # A rule to make subdirectories
120 sub_dirs
: dummy
$(patsubst %,_subdir_
%,$(SUB_DIRS
))
123 $(patsubst %,_subdir_
%,$(SUB_DIRS
)) : dummy
124 $(MAKE
) -C
$(patsubst _subdir_
%,%,$@
)
128 # A rule to make modules
130 ALL_MOBJS
= $(MX_OBJS
) $(M_OBJS
)
131 ifneq "$(strip $(ALL_MOBJS))" ""
132 PDWN
=$(shell $(CONFIG_SHELL
) $(TOPDIR
)/scripts
/pathdown.sh
)
136 $(patsubst %,_modsubdir_
%,$(MOD_SUB_DIRS
)) : dummy
137 $(MAKE
) -C
$(patsubst _modsubdir_
%,%,$@
) modules
140 ifdef MOD_IN_SUB_DIRS
141 $(patsubst %,_modinsubdir_
%,$(MOD_IN_SUB_DIRS
)) : dummy
142 $(MAKE
) -C
$(patsubst _modinsubdir_
%,%,$@
) modules
145 modules
: $(ALL_MOBJS
) $(MIX_OBJS
) $(MI_OBJS
) dummy \
146 $(patsubst %,_modsubdir_
%,$(MOD_SUB_DIRS
)) \
147 $(patsubst %,_modinsubdir_
%,$(MOD_IN_SUB_DIRS
))
148 ifneq "$(strip $(MOD_LIST_NAME))" ""
149 rm -f
$$TOPDIR/modules
/$(MOD_LIST_NAME
)
151 for i in
$(MOD_SUB_DIRS
); do \
152 echo
`basename $$i`.o
>> $$TOPDIR/modules
/$(MOD_LIST_NAME
); done
154 ifneq "$(strip $(ALL_MOBJS))" ""
155 echo
$(ALL_MOBJS
) >> $$TOPDIR/modules
/$(MOD_LIST_NAME
)
157 ifneq "$(strip $(MOD_TO_LIST))" ""
158 echo
$(MOD_TO_LIST
) >> $$TOPDIR/modules
/$(MOD_LIST_NAME
)
161 ifneq "$(strip $(ALL_MOBJS))" ""
163 cd
$$TOPDIR/modules
; for i in
$(ALL_MOBJS
); do \
164 ln
-sf ..
/$(PDWN
)/$$i $$i; done
168 # A rule to do nothing
173 # This is useful for testing
179 # This sets version suffixes on exported symbols
181 # Separate the object into "normal" objects and "exporting" objects
182 # Exporting objects are: all objects that define symbol tables
186 SYMTAB_OBJS
= $(LX_OBJS
) $(OX_OBJS
) $(MX_OBJS
) $(MIX_OBJS
)
188 ifdef CONFIG_MODVERSIONS
189 ifneq "$(strip $(SYMTAB_OBJS))" ""
191 MODINCL
= $(TOPDIR
)/include/linux
/modules
193 # The -w option (enable warnings) for genksyms will return here in 2.1
194 # So where has it gone?
196 # Added the SMP separator to stop module accidents between uniprocessor
197 # and SMP Intel boxes - AC - from bits by Michael Chastain
201 genksyms_smp_prefix
:= -p smp_
203 genksyms_smp_prefix
:=
206 $(MODINCL
)/%.ver
: %.c
207 @if
[ ! -r
$(MODINCL
)/$*.stamp
-o
$(MODINCL
)/$*.stamp
-ot
$< ]; then \
208 echo
'$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
209 echo
'| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
210 $(CC
) $(CFLAGS
) -E
-D__GENKSYMS__
$< \
211 |
$(GENKSYMS
) $(genksyms_smp_prefix
) -k
$(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
) > $@.tmp
; \
212 if
[ -r
$@
] && cmp
-s
$@
$@.tmp
; then echo
$@ is unchanged
; rm -f
$@.tmp
; \
213 else echo mv
$@.tmp
$@
; mv
-f
$@.tmp
$@
; fi
; \
214 fi
; touch
$(MODINCL
)/$*.stamp
216 $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
)): $(TOPDIR
)/include/linux
/autoconf.h
218 $(TOPDIR
)/include/linux
/modversions.h
: $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
))
219 @echo updating
$(TOPDIR
)/include/linux
/modversions.h
220 @
(echo
"#ifndef _LINUX_MODVERSIONS_H";\
221 echo
"#define _LINUX_MODVERSIONS_H"; \
222 echo
"#include <linux/modsetver.h>"; \
223 cd
$(TOPDIR
)/include/linux
/modules
; \
225 if
[ -f
$$f ]; then echo
"#include <linux/modules/$${f}>"; fi
; \
230 dep fastdep
: $(TOPDIR
)/include/linux
/modversions.h
234 $(M_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
236 $(O_OBJS
) $(L_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
241 $(TOPDIR
)/include/linux
/modversions.h
:
242 @echo
"#include <linux/modsetver.h>" > $@
244 endif # CONFIG_MODVERSIONS
246 ifneq "$(strip $(SYMTAB_OBJS))" ""
247 $(SYMTAB_OBJS
): $(SYMTAB_OBJS
:.o
=.c
) $(TOPDIR
)/include/linux
/modversions.h
248 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -DEXPORT_SYMTAB
-c
$(@
:.o
=.c
)
250 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
251 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
253 ) > $(dir $@
)/.
$(notdir $@
).flags
256 endif # CONFIG_MODULES
260 # include dependency files if they exist
262 ifneq ($(wildcard .depend
),)
266 ifneq ($(wildcard $(TOPDIR
)/.hdepend
),)
267 include $(TOPDIR
)/.hdepend
271 # Find files whose flags have changed and force recompilation.
272 # For safety, this works in the converse direction:
273 # every file is forced, except those whose flags are positively up-to-date.
275 FILES_FLAGS_UP_TO_DATE
:=
277 # For use in expunging commas from flags, which mung our checking.
280 FILES_FLAGS_EXIST
:= $(wildcard .
*.flags
)
281 ifneq ($(FILES_FLAGS_EXIST
),)
282 include $(FILES_FLAGS_EXIST
)
285 FILES_FLAGS_CHANGED
:= $(strip \
286 $(filter-out $(FILES_FLAGS_UP_TO_DATE
), \
287 $(O_TARGET
) $(O_OBJS
) $(OX_OBJS
) \
288 $(L_TARGET
) $(L_OBJS
) $(LX_OBJS
) \
289 $(M_OBJS
) $(MX_OBJS
) \
290 $(MI_OBJS
) $(MIX_OBJS
) \
293 # A kludge: .S files don't get flag dependencies (yet),
294 # because that will involve changing a lot of Makefiles.
295 FILES_FLAGS_CHANGED
:= $(strip \
296 $(filter-out $(patsubst %.S
, %.o
, $(wildcard *.S
)), \
297 $(FILES_FLAGS_CHANGED
)))
299 ifneq ($(FILES_FLAGS_CHANGED
),)
300 $(FILES_FLAGS_CHANGED
): dummy