File: kmerge

package info (click to toggle)
alsa-driver 1.0.13-5etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 20,108 kB
  • ctags: 50,477
  • sloc: ansic: 319,881; sh: 32,930; makefile: 2,015; python: 1,527; perl: 1,316; xml: 896; awk: 66
file content (197 lines) | stat: -rw-r--r-- 4,557 bytes parent folder | download | duplicates (5)
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
#!/bin/bash
#
# Syntax:
#
#   kmerge [kernel_directory] [[kernel sound directory]]
#

PATCH_FILE=patch-2.5

KDIR=/usr/src/linux
if [ "x$1" != "x" ]; then
  KDIR="$1"
fi
KADIR=$KDIR/sound
ADIR=$PWD/..
if [ "x$2" != "x" ]; then
  ADIR="$2"
fi

if [ ! -r $ADIR/include/version.h ]; then
	cat << EOF
	
ERROR:
	
$ADIR/include/version.h does not exist, building will fail
without it, please run ./configure in $ADIR first to set
up the information required to build, then run kmerge to
merge drivers to the kernel.
	
EOF
	exit 1
fi

function copy_file () {
	ln -svf $ADIR/$1 $KADIR/$2
}

function copy_dir () {
	pushd $PWD > /dev/null
	cd $ADIR/$1
	mkdir -p $KADIR/$2
	if [ -r Makefile ]; then
		ln -svf $ADIR/$1/Makefile $KADIR/$2/Makefile
	fi
	if [ -r Config.in ]; then
		ln -svf $ADIR/$1/Config.in $KADIR/$2/Config.in
	fi
	if [ -r Config.help ]; then
		ln -svf $ADIR/$1/Config.help $KADIR/$2/Config.help
	fi
	if [ 1 -eq 1 ]; then
		for i in *.[ch]; do
			ln -svf $ADIR/$1/$i $KADIR/$2/$i
		done
	fi
	popd > /dev/null
}

function copy_include_dir () {
	pushd $PWD > /dev/null
	cd $ADIR/$1
	for i in *.h; do
		rm -f $KDIR/include/sound/$i
		ln -svf $ADIR/$1/$i $KDIR/include/sound
	done
	popd > /dev/null
	
	#
	# The library and utils look for <sound/asound.h> (among other things)
	# to configure and compile. This is a quick, crude and ugly fix to
	# avoid breaking alsa-lib and alsa-utils's heart, and to stop
	# frustrating users trying to compile alsa-lib when the driver is
	# in the kernel :)
	#
	# -WV
	#

	ln -svf $KDIR/include/sound /usr/include/sound
}

function showdiff () {
	if ! cmp $KDIR/$1 ../$2; then
		diff -u $KDIR/$1 ../$2
		echo -n "ok? (y/ ) "
		read line
		if [ -z "$line" ] || [ "$line" = "y" ] || [ "$line" = "Y" ]; then
			echo "Continue"
		else
			exit 1
		fi
	fi
}

only_symlinks=n

if [ ! -r $ADIR/core/sound.c ]; then
  echo "Can't find ALSA sources..."
  exit
fi
if [ ! -r $KDIR/drivers/sound/sound_core.c ]; then
  if [ -r $KDIR/sound/oss/Config.in ]; then
    only_symlinks=y
    echo "OSS code already moved, creating symlinks only"
  else
    echo "Can't find kernel sources..."
    exit
  fi
fi

if [ "$only_symlinks" = "n" ]; then
  showdiff drivers/sound/sound_core.c sound_core.c
  showdiff drivers/sound/sound_firmware.c sound_firmware.c
  showdiff drivers/sound/Makefile oss/Makefile
fi

pushd $PWD > /dev/null
if [ "$only_symlinks" = "n" ]; then
  cd $KDIR
  cat $ADIR/scripts/$PATCH_FILE | patch -p1
  rm -rf $KADIR
  mkdir -p $KADIR
  mv $KDIR/drivers/sound $KADIR/oss
  rm -f $KADIR/oss/Makefile
  rm -f $KADIR/oss/sound_core.c
  rm -f $KADIR/oss/sound_firmware.c
fi
mkdir -p $KDIR/include/sound
copy_include_dir include
copy_file Config.in Config.in
copy_file Makefile Makefile
copy_file sound_core.c sound_core.c
copy_file sound_firmware.c sound_firmware.c
copy_file last.c last.c
copy_file oss/Makefile oss/Makefile
copy_dir core core
copy_dir core/seq core/seq
copy_dir core/seq/instr core/seq/instr
copy_dir core/seq/oss core/seq/oss
copy_dir core/oss core/oss
copy_dir drivers drivers
copy_dir drivers/mpu401 drivers/mpu401
copy_dir drivers/opl3 drivers/opl3
copy_dir i2c i2c
copy_dir isa isa
copy_dir isa/ad1816a isa/ad1816a
copy_dir isa/ad1848 isa/ad1848
copy_dir isa/cs423x isa/cs423x
copy_dir isa/es1688 isa/es1688
copy_dir isa/gus isa/gus
copy_dir isa/opti9xx isa/opti9xx
copy_dir isa/sb isa/sb
copy_dir isa/wavefront isa/wavefront
copy_dir pci pci
copy_dir pci/ac97 pci/ac97
copy_dir pci/ali5451 pci/ali5451
copy_dir pci/cs46xx pci/cs46xx
copy_dir pci/emu10k1 pci/emu10k1
copy_dir pci/korg1212 pci/korg1212
copy_dir pci/nm256 pci/nm256
copy_dir pci/rme9652 pci/rme9652
copy_dir pci/trident pci/trident
copy_dir pci/ymfpci pci/ymfpci
copy_dir ppc ppc
copy_dir synth synth
copy_dir synth/emux synth/emux
rm -f $KDIR/include/sound/sound
popd > /dev/null

#
# Warn users about the symlinky nature of the merge, so they
# don't go deleting the alsa-driver sources and upsetting the
# kernel and other things :)
#
# -WV
#

cat << EOF

WARNING:

The kmerge script merges the ALSA driver into the kernel by
creating symbolic links to files in the alsa-driver source
tree.

DO NOT delete this source tree, as this will upset the kernel
and other things such as /usr/include/sound/ which the library
et al looks for.

Experienced users: If you want to delete this, make sure
to copy all the needed includes et al into the proper areas
of $KDIR FIRST.

If you want to delete your kernel sources, make sure to copy
the includes to /usr/include/sound, otherwise alsa-lib and
other programs will scream at you :)

EOF