File: Makefile

package info (click to toggle)
alsa-driver 1.0.23%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,448 kB
  • ctags: 77,491
  • sloc: ansic: 473,525; sh: 3,307; makefile: 2,661; python: 1,527; perl: 1,316; awk: 66
file content (340 lines) | stat: -rw-r--r-- 9,723 bytes parent folder | download
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
340
#
# Makefile for ALSA driver
# Copyright (c) 1994-98 by Jaroslav Kysela <perex@perex.cz>
#

ifneq ($(KERNELRELEASE),)
# call from 2.6 kernel build system

obj-m += acore/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ sparc/ parisc/ sh/ pcmcia/ aoa/ soc/ misc/

else

ifndef IGROUP
IGROUP = root
endif
ifndef IUSER
IUSER = root
endif
ALSAKERNELFILE = alsa-kernel/sound_core.c

ifeq (Makefile.conf,$(wildcard Makefile.conf))
include Makefile.conf
include toplevel.config
else
.PHONY: dummy1
dummy1:
	$(MAKE) all-deps
	@echo
	@echo "Please, run the configure script as first..."
	@echo
MAINSRCDIR := $(shell /bin/pwd)
endif

SND_TOPDIR   = $(MAINSRCDIR)
export SND_TOPDIR

ifeq (,$(wildcard acinclude.m4))
.PHONY: dummy2
dummy2:
	$(MAKE) all-deps
	@echo
	@echo "Please, run the configure script as first..."
	@echo
endif

ifdef NEW_KBUILD
ifdef V
  ifeq ("$(origin V)", "command line")
    KBUILD_VERBOSE = $(V)
  endif
endif
ifndef KBUILD_VERBOSE
  KBUILD_VERBOSE = 0
endif
ifdef C
  ifeq ("$(origin C)", "command line")
    KBUILD_CHECKSRC = $(C)
  endif
endif
ifndef KBUILD_CHECKSRC
  KBUILD_CHECKSRC = 0
endif
export KBUILD_VERBOSE KBUILD_CHECKSRC
endif

SUBDIRS  = include acore i2c drivers isa synth pci aoa soc
CSUBDIRS =

ifndef NEW_KBUILD
SUBDIRS += support
endif

ifeq (y,$(CONFIG_ARM))
SUBDIRS  += arm
endif
ifeq (y,$(CONFIG_PPC))
SUBDIRS  += ppc
endif
ifeq (y,$(CONFIG_SPARC32))
SUBDIRS  += sparc
else
ifeq (y,$(CONFIG_SPARC64))
SUBDIRS  += sparc
endif
endif
ifeq (y,$(CONFIG_MIPS))
SUBDIRS  += mips
endif
ifeq (y,$(CONFIG_SGI))
SUBDIRS  += hal2
endif
ifeq (y,$(CONFIG_USB))
SUBDIRS  += usb
endif
ifeq (y,$(CONFIG_PCMCIA))
SUBDIRS  += pcmcia
endif
ifeq (y,$(CONFIG_PARISC))
SUBDIRS  += parisc
endif
ifeq (y,$(CONFIG_SUPERH))
SUBDIRS  += sh
endif
ifeq (m,$(CONFIG_AC97_BUS))
SUBDIRS  += misc
endif
CSUBDIRS += test utils

KCONFIG_FILES = $(shell find $(SND_TOPDIR) -name Kconfig) $(shell find $(SND_TOPDIR)/alsa-kernel/ -name Kconfig)

.PHONY: all
all: compile

$(ALSAKERNELFILE):
	{ \
	rm -rf alsa-kernel ; \
	if [ ! -z "$(ALSAKERNELDIR)" ]; then \
		if [ -f $(ALSAKERNELDIR)/kernel/sched.c ]; then \
			# whole linux kernel source tree \
			mkdir alsa-kernel; \
			for i in $(ALSAKERNELDIR)/sound/* ; do \
				ln -sf $$i alsa-kernel ; \
			done ; \
			ln -sf $(ALSAKERNELDIR)/include/sound \
						alsa-kernel/include ; \
			ln -sf $(ALSAKERNELDIR)/Documentation/sound/alsa \
						alsa-kernel/Documentation ; \
		else \
			# alsa-kmirror tree \
			ln -sf $(ALSAKERNELDIR) alsa-kernel ; \
		fi; \
		ln -sf alsa-kernel sound ; \
	fi \
	}

# to use newalsakernel target:
# ALSAKERNELDIR=yourlinuxtree_or_kmirrortree make newalsakernel
.PHONY: newalsakernel
newalsakernel: $(ALSAKERNELFILE) clean
	rm -rf alsa-kernel
	$(MAKE) $(ALSAKERNELFILE)

utils/mod-deps: utils/mod-deps.c
	gcc utils/mod-deps.c -o utils/mod-deps

toplevel.config.in: $(KCONFIG_FILES) $(ALSAKERNELFILE) utils/mod-deps kconfig-vers
	utils/mod-deps --basedir $(SND_TOPDIR)/alsa-kernel --hiddendir $(SND_TOPDIR) --versiondep $(SND_TOPDIR)/kconfig-vers --makeconf > toplevel.config.in

acinclude.m4: $(KCONFIG_FILES) $(ALSAKERNELFILE) utils/mod-deps kconfig-vers
	utils/mod-deps --basedir $(SND_TOPDIR)/alsa-kernel --hiddendir $(SND_TOPDIR) --versiondep $(SND_TOPDIR)/kconfig-vers --acinclude > acinclude.m4

include/config1.h.in: $(KCONFIG_FILES) $(ALSAKERNELFILE) utils/mod-deps kconfig-vers
	utils/mod-deps --basedir $(SND_TOPDIR)/alsa-kernel --hiddendir $(SND_TOPDIR) --versiondep $(SND_TOPDIR)/kconfig-vers --include > include/config1.h.in

all-deps: toplevel.config.in acinclude.m4 include/config1.h.in

include/sndversions.h:
	$(MAKE) dep

.PHONY: compile
compile: include/sndversions.h
ifdef NEW_KBUILD
	$(MAKE) -C $(CONFIG_SND_KERNELDIR) SUBDIRS=$(MAINSRCDIR) $(MAKE_ADDS) CPP="$(CPP)" CC="$(CC)" modules
	utils/link-modules $(SND_TOPDIR)
else
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d; then exit 1; fi; done
endif
	@echo
	@echo "ALSA modules were successfully compiled."
	@echo

.PHONY: dep
dep:
ifdef NEW_KBUILD
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d prepare; then exit 1; fi; done
else
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d fastdep; then exit 1; fi; done
endif

.PHONY: map
map:
	awk "{ if ( length( $$1 ) != 0 ) print $$1 }" snd.map | sort -o snd.map1
	mv -f snd.map1 snd.map

.PHONY: install
install: install-headers install-modules install-scripts check-snd-prefix
	@if [ -L /dev/snd ]; then \
		echo "The ALSA devices were removed from /proc/asound/dev directory." ; \
		echo "Creating static device entries in /dev/snd." ; \
		$(SND_TOPDIR)/snddevices ; \
	fi
	cat WARNING

.PHONY: install-headers
install-headers:
	if [ -L $(DESTDIR)$(prefix)/include/sound ]; then \
		rm -f $(DESTDIR)$(prefix)/include/sound; \
		ln -sf $(MAINSRCDIR)/include/sound $(DESTDIR)$(prefix)/include/sound; \
	else \
		rm -rf $(DESTDIR)$(prefix)/include/sound; \
		install -d -m 755 -g $(IGROUP) -o $(IUSER) $(DESTDIR)$(prefix)/include/sound; \
		for f in include/sound/*.h; do \
			install -m 644 -g $(IGROUP) -o $(IUSER) $$f $(DESTDIR)$(prefix)/include/sound; \
		done \
	fi

ifeq ($(CONFIG_SND_KERNELDIR)/System.map,$(wildcard $(CONFIG_SND_KERNELDIR)/System.map))
SYSTEM_MAP_OPT = -F $(CONFIG_SND_KERNELDIR)/System.map
endif

.PHONY: install-modules
install-modules:
ifeq ($(moddir_tree),y)
	find $(DESTDIR)$(moddir) -name 'snd*.*o' | xargs rm -f
	find $(DESTDIR)$(moddir) -name 'snd*.*o.gz' | xargs rm -f
	find $(DESTDIR)$(moddir) -name 'ac97_bus.*o' | xargs rm -f
	find $(DESTDIR)$(moddir) -name 'ac97_bus.*o.gz' | xargs rm -f
else
	rm -f $(DESTDIR)$(moddir)/snd*.*o $(DESTDIR)$(moddir)/persist.o $(DESTDIR)$(moddir)/isapnp.o
	rm -f $(DESTDIR)$(moddir)/snd*.*o.gz $(DESTDIR)$(moddir)/persist.o.gz $(DESTDIR)$(moddir)/isapnp.o.gz
endif
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d modules_install; then exit 1; fi; done
#ifeq ($(DESTDIR),)
#	-/sbin/depmod -a $(kaversion) $(SYSTEM_MAP_OPT)
#else
#	@echo "*** This is a \`staged' install using the prefix"
#	@echo "***	\"$(DESTDIR)\"."
#	@echo "***"
#	@echo "*** Once the modules have been moved to their final destination you must run the command"
#	@echo "***	\"/sbin/depmod -a $(kaversion) $(SYSTEM_MAP_OPT)\"."
#	@echo "***"
#	@echo "*** Alternatively, if you build a package (e.g. rpm), include the"
#	@echo "*** depmode command above in the post-(un)install procedure."
#endif

.PHONY: install-scripts
install-scripts:
	@for d in /sbin/init.d /etc/rc.d/init.d /etc/init.d; do \
	 if [ -d $(DESTDIR)$$d ]; then \
	   if [ -f $(DESTDIR)$$d/alsasound ]; then \
	     cmp -s utils/alsasound $(DESTDIR)$$d/alsasound || \
	       install -m 755 -g $(IGROUP) -o $(IUSER) utils/alsasound $(DESTDIR)$$d/alsasound.new; \	     break; \
	   fi; \
	   install -m 755 -g root -o root utils/alsasound $(DESTDIR)$$d/alsasound; \
	   break; \
	fi; done

.PHONY: check-snd-prefix
check-snd-prefix:
	@ if [ x"$(DESTDIR)" = x -a -f /etc/modules.conf ]; then \
	  if grep -s -q snd_ /etc/modules.conf; then \
	    echo;\
	    echo "             ===== WARNING =====";\
	    echo;\
	    echo "The options for ALSA modules on your system still include snd_ prefix,";\
	    echo "which is obsoleted now.  Please fix /etc/modules.conf.";\
	    echo "For convenience, you can use utils/module-options script to convert";\
	    echo "the snd_ prefix automatically.";\
	    echo;\
	fi; fi

.PHONY: clean1
clean1:
	rm -f .depend *.o snd.map*
ifdef DEXPORT
	rm -f $(DEXPORT)/*.ver
endif
	rm -f modules/*.o modules/*.ko

.PHONY: clean
clean: clean1
ifdef NEW_KBUILD
	rm -rf .tmp_versions
endif
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d clean; then exit 1; fi; done
	@for d in $(CSUBDIRS); do if ! $(MAKE) -C $$d clean; then exit 1; fi; done

.PHONY: mrproper
mrproper: clean1
	@for d in $(SUBDIRS); do if ! $(MAKE) -C $$d mrproper; then exit 1; fi; done
	@for d in $(CSUBDIRS); do if ! $(MAKE) -C $$d mrproper; then exit 1; fi; done
	rm -f *~ out.txt *.orig *.rej .#* .gdb_history
	rm -f doc/*~
	-rm -f config.cache config.log config.status Makefile.conf
	rm -f utils/alsa-driver.spec
	rm -f `find alsa-kernel -name "*~"`
	rm -f `find alsa-kernel -name "*.orig"`
	rm -f `find alsa-kernel -name "*.rej"`
	rm -f `find alsa-kernel -name ".#*"`
	rm -f `find alsa-kernel -name "out.txt"`
	rm -rf autom4te.cache

.PHONY: cvsclean hgclean gitclean
gitclean: mrproper
	rm -f configure snddevices aclocal.m4 acinclude.m4 include/config.h include/config1.h \
	  include/config1.h.in toplevel.config toplevel.config.in \
	  sound
	rm -rf include/linux alsa-kernel
hgclean: gitclean
cvsclean: gitclean

.PHONY: pack
pack: $(ALSAKERNELFILE) mrproper
	chmod 755 utils/alsasound
	# big note: use always '--bzip2 -p' where -p is fake argument
	# it seems that some older tar has wrong getopt list
	{ \
		cd .. ; \
		rm -rf alsa-driver/alsa-kernel ; \
		mv alsa-kmirror alsa-driver/alsa-kernel ; \
		mv alsa-driver alsa-driver-$(CONFIG_SND_VERSION) ; \
		tar --exclude=CVS --exclude=kchanges --exclude=.cvsignore \
                    --exclude='.hg*' --exclude=.gitignore \
                    --owner=$(IGROUP) --group=$(IUSER) -cv --bzip2 -p \
                    -f alsa-driver-$(CONFIG_SND_VERSION).tar.bz2 alsa-driver-$(CONFIG_SND_VERSION) ; \
		mv alsa-driver-$(CONFIG_SND_VERSION) alsa-driver ; \
	}

.PHONY: uninstall
uninstall:
	-rm -rf $(DESTDIR)$(prefix)/include/sound
ifeq ($(moddir_tree),y)
	{ \
		for i in core $(SUBDIRS) ; do \
			rm -rf $(DESTDIR)$(moddir)/$$i ; \
		done ; \
	}
else
	rm -f $(DESTDIR)$(moddir)/snd*.o $(DESTDIR)$(moddir)/persist.o $(DESTDIR)$(moddir)/isapnp.o
endif
	rm -f $(DESTDIR)/sbin/init.d/alsasound
	rm -f $(DESTDIR)/etc/rc.d/init.d/alsasound
	rm -f $(DESTDIR)/etc/init.d/alsasound

.PHONY: TAGS
TAGS:
	find . -name '*.[ch]' | etags -

endif # call from 2.6 kernel build system