ia64/linux-2.6.18-xen.hg

view scripts/Makefile.lib @ 562:66faefe721eb

pvSCSI backend driver

Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
Signed-off-by: Jun Kamada <kama@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 02 09:58:27 2008 +0100 (2008-06-02)
parents 50477b1b3016
children
line source
1 # Backward compatibility - to be removed...
2 extra-y += $(EXTRA_TARGETS)
3 # Figure out what we need to build from the various variables
4 # ===========================================================================
6 # When an object is listed to be built compiled-in and modular,
7 # only build the compiled-in version
9 obj-m := $(filter-out $(obj-y),$(obj-m))
11 # Libraries are always collected in one lib file.
12 # Filter out objects already built-in
14 lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
16 # Remove objects forcibly disabled
18 obj-y := $(filter-out $(disabled-obj-y),$(obj-y))
19 obj-m := $(filter-out $(disabled-obj-y),$(obj-m))
20 lib-y := $(filter-out $(disabled-obj-y),$(lib-y))
23 # Handle objects in subdirs
24 # ---------------------------------------------------------------------------
25 # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o
26 # and add the directory to the list of dirs to descend into: $(subdir-y)
27 # o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
28 # and add the directory to the list of dirs to descend into: $(subdir-m)
30 __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
31 subdir-y += $(__subdir-y)
32 __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
33 subdir-m += $(__subdir-m)
34 obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
35 obj-m := $(filter-out %/, $(obj-m))
37 # Subdirectories we need to descend into
39 subdir-ym := $(sort $(subdir-y) $(subdir-m))
41 # if $(foo-objs) exists, foo.o is a composite object
42 multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
43 multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
44 multi-used := $(multi-used-y) $(multi-used-m)
45 single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
47 # Build list of the parts of our composite objects, our composite
48 # objects depend on those (obviously)
49 multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
50 multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
51 multi-objs := $(multi-objs-y) $(multi-objs-m)
53 # $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
54 # in the local directory
55 subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
57 # $(obj-dirs) is a list of directories that contain object files
58 obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
60 # Replace multi-part objects by their individual parts, look at local dir only
61 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
62 real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
64 # Add subdir path
66 extra-y := $(addprefix $(obj)/,$(extra-y))
67 always := $(addprefix $(obj)/,$(always))
68 targets := $(addprefix $(obj)/,$(targets))
69 obj-y := $(addprefix $(obj)/,$(obj-y))
70 obj-m := $(addprefix $(obj)/,$(obj-m))
71 lib-y := $(addprefix $(obj)/,$(lib-y))
72 subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
73 real-objs-y := $(addprefix $(obj)/,$(real-objs-y))
74 real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
75 single-used-m := $(addprefix $(obj)/,$(single-used-m))
76 multi-used-y := $(addprefix $(obj)/,$(multi-used-y))
77 multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
78 multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
79 multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
80 subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
81 obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
83 # These flags are needed for modversions and compiling, so we define them here
84 # already
85 # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
86 # end up in (or would, if it gets compiled in)
87 # Note: It's possible that one object gets potentially linked into more
88 # than one module. In that case KBUILD_MODNAME will be set to foo_bar,
89 # where foo and bar are the name of the modules.
90 name-fix = $(subst $(comma),_,$(subst -,_,$1))
91 basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
92 modname_flags = $(if $(filter 1,$(words $(modname))),\
93 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
95 _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
96 _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
97 _cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
99 # If building the kernel in a separate objtree expand all occurrences
100 # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
102 ifeq ($(KBUILD_SRC),)
103 __c_flags = $(_c_flags)
104 __a_flags = $(_a_flags)
105 __cpp_flags = $(_cpp_flags)
106 else
108 # -I$(obj) locates generated .h files
109 # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
110 # and locates generated .h files
111 # FIXME: Replace both with specific CFLAGS* statements in the makefiles
112 __c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags)
113 __a_flags = $(call flags,_a_flags)
114 __cpp_flags = $(call flags,_cpp_flags)
115 endif
117 c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
118 $(__c_flags) $(modkern_cflags) \
119 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
121 a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
122 $(__a_flags) $(modkern_aflags)
124 cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
126 ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS)
128 # Finds the multi-part object the current object will be linked into
129 modname-multi = $(sort $(foreach m,$(multi-used),\
130 $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
132 # Shipped files
133 # ===========================================================================
135 quiet_cmd_shipped = SHIPPED $@
136 cmd_shipped = cat $< > $@
138 $(obj)/%:: $(src)/%_shipped
139 $(call cmd,shipped)
141 # Commands useful for building a boot image
142 # ===========================================================================
143 #
144 # Use as following:
145 #
146 # target: source(s) FORCE
147 # $(if_changed,ld/objcopy/gzip)
148 #
149 # and add target to EXTRA_TARGETS so that we know we have to
150 # read in the saved command line
152 # Linking
153 # ---------------------------------------------------------------------------
155 quiet_cmd_ld = LD $@
156 cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \
157 $(filter-out FORCE,$^) -o $@
159 # Objcopy
160 # ---------------------------------------------------------------------------
162 quiet_cmd_objcopy = OBJCOPY $@
163 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
165 # Gzip
166 # ---------------------------------------------------------------------------
168 quiet_cmd_gzip = GZIP $@
169 cmd_gzip = gzip -f -9 < $< > $@