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 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -E
$< > $@
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
$@
$(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 set
-e
; for i in
$(ALL_SUB_DIRS
); do
$(MAKE
) -C
$$i fastdep
; done
112 # A rule to make subdirectories
116 set
-e
; for i in
$(SUB_DIRS
); do
$(MAKE
) -C
$$i; done
120 # A rule to make modules
122 ALL_MOBJS
= $(MX_OBJS
) $(M_OBJS
)
123 ifneq "$(strip $(ALL_MOBJS))" ""
124 PDWN
=$(shell $(CONFIG_SHELL
) $(TOPDIR
)/scripts
/pathdown.sh
)
126 modules
: $(ALL_MOBJS
) $(MIX_OBJS
) $(MI_OBJS
) dummy
128 set
-e
; for i in
$(MOD_SUB_DIRS
); do
$(MAKE
) -C
$$i modules
; done
130 ifdef MOD_IN_SUB_DIRS
131 set
-e
; for i in
$(MOD_IN_SUB_DIRS
); do
$(MAKE
) -C
$$i modules
; done
133 ifneq "$(strip $(MOD_LIST_NAME))" ""
134 rm -f
$$TOPDIR/modules
/$(MOD_LIST_NAME
)
136 for i in
$(MOD_SUB_DIRS
); do \
137 echo
`basename $$i`.o
>> $$TOPDIR/modules
/$(MOD_LIST_NAME
); done
139 ifneq "$(strip $(ALL_MOBJS))" ""
140 echo
$(ALL_MOBJS
) >> $$TOPDIR/modules
/$(MOD_LIST_NAME
)
142 ifneq "$(strip $(MOD_TO_LIST))" ""
143 echo
$(MOD_TO_LIST
) >> $$TOPDIR/modules
/$(MOD_LIST_NAME
)
146 ifneq "$(strip $(ALL_MOBJS))" ""
148 cd
$$TOPDIR/modules
; for i in
$(ALL_MOBJS
); do \
149 ln
-sf ..
/$(PDWN
)/$$i $$i; done
153 # A rule to do nothing
158 # This is useful for testing
164 # This sets version suffixes on exported symbols
166 # Separate the object into "normal" objects and "exporting" objects
167 # Exporting objects are: all objects that define symbol tables
171 SYMTAB_OBJS
= $(LX_OBJS
) $(OX_OBJS
) $(MX_OBJS
) $(MIX_OBJS
)
173 ifdef CONFIG_MODVERSIONS
174 ifneq "$(strip $(SYMTAB_OBJS))" ""
176 MODINCL
= $(TOPDIR
)/include/linux
/modules
178 # The -w option (enable warnings) for genksyms will return here in 2.1
179 # So where has it gone?
181 # Added the SMP separator to stop module accidents between uniprocessor
182 # and SMP Intel boxes - AC - from bits by Michael Chastain
186 genksyms_smp_prefix
:= -p smp_
188 genksyms_smp_prefix
:=
191 $(MODINCL
)/%.ver
: %.c
192 @if
[ ! -r
$(MODINCL
)/$*.stamp
-o
$(MODINCL
)/$*.stamp
-ot
$< ]; then \
193 echo
'$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
194 echo
'| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
195 $(CC
) $(CFLAGS
) -E
-D__GENKSYMS__
$< \
196 |
$(GENKSYMS
) $(genksyms_smp_prefix
) -k
$(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
) > $@.tmp
; \
197 if
[ -r
$@
] && cmp
-s
$@
$@.tmp
; then echo
$@ is unchanged
; rm -f
$@.tmp
; \
198 else echo mv
$@.tmp
$@
; mv
-f
$@.tmp
$@
; fi
; \
199 fi
; touch
$(MODINCL
)/$*.stamp
201 $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
)): $(TOPDIR
)/include/linux
/autoconf.h
203 $(TOPDIR
)/include/linux
/modversions.h
: $(addprefix $(MODINCL
)/,$(SYMTAB_OBJS
:.o
=.ver
))
204 @echo updating
$(TOPDIR
)/include/linux
/modversions.h
205 @
(echo
"#ifndef _LINUX_MODVERSIONS_H";\
206 echo
"#define _LINUX_MODVERSIONS_H"; \
207 echo
"#include <linux/modsetver.h>"; \
208 cd
$(TOPDIR
)/include/linux
/modules
; \
210 if
[ -f
$$f ]; then echo
"#include <linux/modules/$${f}>"; fi
; \
215 dep fastdep
: $(TOPDIR
)/include/linux
/modversions.h
219 $(M_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
221 $(O_OBJS
) $(L_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
226 $(TOPDIR
)/include/linux
/modversions.h
:
227 @echo
"#include <linux/modsetver.h>" > $@
229 endif # CONFIG_MODVERSIONS
231 ifneq "$(strip $(SYMTAB_OBJS))" ""
232 $(SYMTAB_OBJS
): $(TOPDIR
)/include/linux
/modversions.h
$(SYMTAB_OBJS
:.o
=.c
)
233 $(CC
) $(CFLAGS
) $(EXTRA_CFLAGS
) $(CFLAGS_
$@
) -DEXPORT_SYMTAB
-c
$(@
:.o
=.c
)
235 echo
'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
236 echo
'FILES_FLAGS_UP_TO_DATE += $@' ; \
238 ) > $(dir $@
)/.
$(notdir $@
).flags
241 endif # CONFIG_MODULES
245 # include dependency files if they exist
247 ifneq ($(wildcard .depend
),)
251 ifneq ($(wildcard $(TOPDIR
)/.hdepend
),)
252 include $(TOPDIR
)/.hdepend
256 # Find files whose flags have changed and force recompilation.
257 # For safety, this works in the converse direction:
258 # every file is forced, except those whose flags are positively up-to-date.
260 FILES_FLAGS_UP_TO_DATE
:=
262 # For use in expunging commas from flags, which mung our checking.
265 FILES_FLAGS_EXIST
:= $(wildcard .
*.flags
)
266 ifneq ($(FILES_FLAGS_EXIST
),)
267 include $(FILES_FLAGS_EXIST
)
270 FILES_FLAGS_CHANGED
:= $(strip \
271 $(filter-out $(FILES_FLAGS_UP_TO_DATE
), \
272 $(O_TARGET
) $(O_OBJS
) $(OX_OBJS
) \
273 $(L_TARGET
) $(L_OBJS
) $(LX_OBJS
) \
274 $(M_OBJS
) $(MX_OBJS
) \
275 $(MI_OBJS
) $(MIX_OBJS
) \
278 # A kludge: .S files don't get flag dependencies (yet),
279 # because that will involve changing a lot of Makefiles.
280 FILES_FLAGS_CHANGED
:= $(strip \
281 $(filter-out $(patsubst %.S
, %.o
, $(wildcard *.S
)), \
282 $(FILES_FLAGS_CHANGED
)))
284 ifneq ($(FILES_FLAGS_CHANGED
),)
285 $(FILES_FLAGS_CHANGED
): dummy