1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
|
#
# This file contains rules which are shared between multiple Makefiles.
#
# It's a stripped and modified version of /usr/src/linux/Rules.make. [--jk]
#
MODCURDIR = $(subst $(MAINSRCDIR)/,,$(shell /bin/pwd))
ifdef NEW_KBUILD
ifdef KBUILD_MODULES
# clean obsolete definitions
export-objs :=
# apply patches beforehand
.PHONY: cleanup
cleanup:
rm -f *.[oas] *.ko .*.cmd .*.d .*.tmp *.mod.c $(clean-files)
@for d in $(patsubst %/,%,$(filter %/, $(obj-y))) \
$(patsubst %/,%,$(filter %/, $(obj-m))) DUMMY; do \
if [ $$d != DUMMY ]; then $(MAKE) -C $$d cleanup; fi; \
done
else # ! KBUILD_MODULES
first_rule: modules
include $(MAINSRCDIR)/Rules.make1
%.c: %.patch
@SND_TOPDIR="$(MAINSRCDIR)" $(SND_TOPDIR)/utils/patch-alsa $@
# apply patches beforehand
.PHONY: prepare
prepare: $(clean-files)
@for d in $(ALL_SUB_DIRS) DUMMY; do \
if [ $$d != DUMMY ]; then $(MAKE) -C $$d prepare; fi; \
done
modules:
$(MAKE) prepare
$(MAKE) -C $(CONFIG_SND_KERNELDIR) SUBDIRS=$(MAINSRCDIR) $(MAKE_ADDS) SND_TOPDIR=$(MAINSRCDIR) modules
$(SND_TOPDIR)/utils/link-modules $(MODCURDIR)
ALL_MOBJS := $(filter-out $(obj-y), $(obj-m))
ALL_MOBJS := $(filter-out %/, $(ALL_MOBJS))
modules_install:
ifneq "$(strip $(ALL_MOBJS))" ""
mkdir -p $(DESTDIR)$(moddir)/$(MODCURDIR)
cp $(sort $(ALL_MOBJS:.o=.ko)) $(DESTDIR)$(moddir)/$(MODCURDIR)
endif
@for d in $(ALL_SUB_DIRS) DUMMY; do \
if [ $$d != DUMMY ]; then $(MAKE) -C $$d modules_install; fi; \
done
endif # KBUILD_MODULES
else # ! NEW_KBUILD
TOPDIR = $(MAINSRCDIR)
comma = ,
#
# False targets.
#
.PHONY: dummy
#
# Get things started.
#
first_rule: modules
include $(TOPDIR)/Rules.make1
ifndef O_TARGET
ifndef L_TARGET
O_TARGET := built-in.o
endif
endif
#
# Common rules
#
%.s: %.c
$(CC) -D__KERNEL__ $(CFLAGS) $(EXTRA_CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -S $< -o $@
%.i: %.c
$(CPP) -D__KERNEL__ $(CFLAGS) $(EXTRA_CFLAGS) -D"KBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) $(CFLAGS_$@) $< > $@
%.o: %.c
$(CC) -D__KERNEL__ $(CFLAGS) $(EXTRA_CFLAGS) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) $(CFLAGS_$@) -c -o $@ $<
%.o: %.s
$(AS) -D__KERNEL__ $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
# Old makefiles define their own rules for compiling .S files,
# but these standard rules are available for any Makefile that
# wants to use them. Our plan is to incrementally convert all
# the Makefiles to these standard rules. -- rmk, mec
ifdef USE_STANDARD_AS_RULE
%.s: %.S
$(CPP) -D__KERNEL__ $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) $< > $@
%.o: %.S
$(CC) -D__KERNEL__ $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) -c -o $@ $<
endif
%.c: %.patch
@xtmp=`echo $(MODCURDIR) | sed -e 's/^acore/core/'`/$@;\
echo "copying file alsa-kernel/$$xtmp";\
cp "$(TOPDIR)/alsa-kernel/$$xtmp" $@;\
patch -p0 -i $<
%.isapnp: %.c
ifeq (y,$(CONFIG_ISAPNP))
$(CPP) -C -D__KERNEL__ $(CFLAGS) $(EXTRA_CFLAGS) -D__isapnp_now__ -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) $(CFLAGS_$@) $< | awk -f $(TOPDIR)/utils/convert_isapnp_ids > $@
else
rm -f $@
touch $@
endif
#
#
#
all_targets: $(isapnp-files) $(O_TARGET) $(L_TARGET)
#
# Rule to compile a set of .o files into one .o file
#
ifdef O_TARGET
$(O_TARGET): $(obj-y)
touch $@
endif # O_TARGET
#
# Rule to compile a set of .o files into one .a file
#
ifdef L_TARGET
$(L_TARGET): $(obj-y)
touch $@
endif
#
# Rule to link composite objects
#
__obj-m = $(filter-out export.o,$(obj-m))
ld-multi-used-m := $(sort $(foreach m,$(__obj-m),$(patsubst %,$(m),$($(basename $(m))-objs))))
ld-multi-objs-m := $(foreach m, $(ld-multi-used-m), $($(basename $(m))-objs) $(extra-$(basename $(m))-objs))
depend-objs := $(foreach m,$(__obj-m),$($(basename $(m))-objs))
depend-files := $(patsubst %.o,%.c,$(depend-objs))
$(ld-multi-used-m) : %.o: $(ld-multi-objs-m)
rm -f $@
$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $($(basename $@)-objs) $(extra-$(basename $@)-objs), $^)
#
# This make dependencies quickly
#
fastdep: $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) update-sndversions $(depend-files)
ifneq "$(strip $(depend-files))" ""
$(CC) -M -D__KERNEL__ -D__isapnp_now__ $(CPPFLAGS) $(EXTRA_CFLAGS) $(depend-files) > .depend
endif
ifneq "$(strip $(ALL_SUB_DIRS))" ""
$(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)):
$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
endif
#
# A rule to make subdirectories
#
subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
sub_dirs: dummy $(subdir-list)
ifdef SUB_DIRS
$(subdir-list) : dummy
$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif
#
# A rule to make modules
#
ALL_MOBJS = $(filter-out $(obj-y), $(obj-m))
MOD_DIRS := $(MOD_SUB_DIRS) $(MOD_IN_SUB_DIRS)
ifneq "$(strip $(MOD_DIRS))" ""
.PHONY: $(patsubst %,_modsubdir_%,$(MOD_DIRS))
$(patsubst %,_modsubdir_%,$(MOD_DIRS)) : dummy
$(MAKE) -C $(patsubst _modsubdir_%,%,$@) modules
.PHONY: $(patsubst %,_modinst_%,$(MOD_DIRS))
$(patsubst %,_modinst_%,$(MOD_DIRS)) : dummy
$(MAKE) -C $(patsubst _modinst_%,%,$@) modules_install
endif
.PHONY: modules
modules: $(isapnp-files) $(ALL_MOBJS) dummy \
$(patsubst %,_modsubdir_%,$(MOD_DIRS))
.PHONY: _modinst__
_modinst__: dummy
ifneq "$(strip $(ALL_MOBJS))" ""
ifeq ($(moddir_tree),y)
mkdir -p $(DESTDIR)$(moddir)/$(MODCURDIR)
cp $(sort $(ALL_MOBJS)) $(DESTDIR)$(moddir)/$(MODCURDIR)
else
mkdir -p $(DESTDIR)$(moddir)
cp $(sort $(ALL_MOBJS)) $(DESTDIR)$(moddir)
endif
endif
.PHONY: modules_install
modules_install: _modinst__ \
$(patsubst %,_modinst_%,$(MOD_DIRS))
#
# This sets version suffixes on exported symbols
# Separate the object into "normal" objects and "exporting" objects
# Exporting objects are: all objects that define symbol tables
#
ifdef CONFIG_MODULES
ifeq (y,$(CONFIG_SND_MVERSION))
ifneq "$(strip $(export-objs))" ""
MODINCL = $(TOPDIR)/include/modules
MODPREFIX = $(subst /,-,$(MODCURDIR))__
# The -w option (enable warnings) for genksyms will return here in 2.1
# So where has it gone?
#
# Added the SMP separator to stop module accidents between uniprocessor
# and SMP Intel boxes - AC - from bits by Michael Chastain
#
ifdef $(msmp)
genksyms_smp_prefix := -p smp_
else
genksyms_smp_prefix :=
endif
$(MODINCL)/$(MODPREFIX)%.ver: %.c update-sndvers
@if [ ! -r $(MODINCL)/$(MODPREFIX)$*.stamp -o $(MODINCL)/$(MODPREFIX)$*.stamp -ot $< ]; then \
if [ ! -f $(CONFIG_SND_KERNELDIR)/include/linux/modules/$*.stamp ]; then \
echo '$(CC) -D__KERNEL__ $(CPPFLAGS) $(EXTRA_CFLAGS) -E -D__GENKSYMS__ $<'; \
echo '| $(GENKSYMS) $(genksyms_smp_prefix) > $@.tmp'; \
$(CC) -D__KERNEL__ $(CPPFLAGS) $(EXTRA_CFLAGS) -E -D__GENKSYMS__ $< \
| $(GENKSYMS) $(genksyms_smp_prefix) > $@.tmp; \
if [ -r $@ ] && cmp -s $@ $@.tmp; then echo $@ is unchanged; rm -f $@.tmp; \
else echo mv $@.tmp $@; mv -f $@.tmp $@; fi; \
elif [ ! -r $@ ]; then touch $@; \
fi; \
fi; touch $(MODINCL)/$(MODPREFIX)$*.stamp
$(addprefix $(MODINCL)/$(MODPREFIX),$(export-objs:.o=.ver)): $(TOPDIR)/include/config.h $(TOPDIR)/include/config1.h
# updates .ver files but not modversions.h
fastdep: $(addprefix $(MODINCL)/$(MODPREFIX),$(export-objs:.o=.ver))
endif # export-objs
define update-sndvers
(tmpfile=`echo $(SNDVERSIONS).tmp`; \
(echo "#ifndef _LINUX_SNDVERSIONS_H"; \
echo "#define _LINUX_SNDVERSIONS_H"; \
echo "#include <linux/modsetver.h>"; \
cd $(TOPDIR)/include/modules; \
for f in *.ver; do \
if [ -f $$f ]; then echo "#include \"modules/$${f}\""; fi; \
done; \
echo "#endif"; \
) > $${tmpfile}; \
if [ -r $(SNDVERSIONS) ] && cmp -s $(SNDVERSIONS) $${tmpfile}; then \
echo $(SNDVERSIONS) was not updated; \
rm -f $${tmpfile}; \
else \
echo $(SNDVERSIONS) was updated; \
mv -f $${tmpfile} $(SNDVERSIONS); \
fi)
endef
$(SNDVERSIONS):
$(update-sndvers)
$(active-objs): $(SNDVERSIONS)
else # !CONFIG_SND_MVERSION
define update-sndvers
@echo "" > $(SNDVERSIONS)
endef
$(SNDVERSIONS):
$(update-sndvers)
endif # CONFIG_SND_MVERSION
$(ld-multi-used-m): $(addprefix $(TOPDIR)/modules/,$(ld-multi-used-m))
$(TOPDIR)/modules/%.o: dummy
@if ! test -L $@; then \
echo "ln -sf ../$(MODCURDIR)/$(notdir $@) $(TOPDIR)/modules/$(notdir $@)" ; \
ln -sf ../$(MODCURDIR)/$(notdir $@) $(TOPDIR)/modules/$(notdir $@) ; \
fi
.PHONY: update-sndversions
update-sndversions: dummy
$(update-sndvers)
ifneq "$(strip $(export-objs))" ""
ifeq (y,$(CONFIG_SND_MVERSION))
$(export-objs): $(addprefix $(MODINCL)/$(MODPREFIX),$(export-objs:.o=.ver)) $(export-objs:.o=.c)
else
$(export-objs): $(export-objs:.o=.c)
endif
$(CC) -D__KERNEL__ $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
endif
endif # CONFIG_MODULES
#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif
ifneq ($(wildcard $(TOPDIR)/.hdepend),)
include $(TOPDIR)/.hdepend
endif
endif # NEW_KBUILD
|