summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-17 19:06:34 +0000
committerkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-17 19:06:34 +0000
commitc9f7297b684b0daba5d1a939ba13c98de97eff8f (patch)
tree98e572a5473dc9f32a60bf4db565da4ed076b8e8
parentb3c1476d129d058703d75fce49097f075cb7fb93 (diff)
Merged revisions 1064-1065 via svnmerge from
https://origsvn.digium.com/svn/zaptel/branches/1.2 ........ r1064 | kpfleming | 2006-05-17 11:49:46 -0500 (Wed, 17 May 2006) | 2 lines move udev rules creating into a script, and generate it properly based on the installed udev version ........ r1065 | kpfleming | 2006-05-17 13:50:38 -0500 (Wed, 17 May 2006) | 2 lines move module-rules building into a script, and remove some old unnecessary steps ........ git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1067 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rw-r--r--Makefile154
-rwxr-xr-xbuild_tools/genmodconf100
-rwxr-xr-xbuild_tools/genudevrules30
-rw-r--r--udev/zaptel.permissions2
-rw-r--r--udev/zaptel.rules6
-rw-r--r--udev/zaptel.rules-combined6
6 files changed, 159 insertions, 139 deletions
diff --git a/Makefile b/Makefile
index 340dc3d..ac759c4 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,9 @@
# Copyright (C) 2001-2006 Digium, Inc.
#
#
+
.EXPORT_ALL_VARIABLES:
-BASEADDR=0xd0000
PWD:=$(shell pwd)
HOSTCC=gcc
@@ -77,54 +77,15 @@ else
BUILDVER:=linux26
endif
-ifeq ($(BUILDVER),linux26)
- ifneq (,$(wildcard $(ROOT_PREFIX)/etc/modprobe.d))
- MODCONF:=$(ROOT_PREFIX)/etc/modprobe.d/zaptel
- else
- ifneq (,$(wildcard $(ROOT_PREFIX)/etc/modules.d))
- MODCONF:=$(ROOT_PREFIX)/etc/modules.d/zaptel
- else
- ifneq (,$(wildcard $(ROOT_PREFIX)/etc/modprobe.conf))
- MODCONF:=$(ROOT_PREFIX)/etc/modprobe.conf
- MODCONFBACKUP:=1
- else
- ifneq (,$(wildcard $(ROOT_PREFIX)/etc/conf.modules))
- MODCONF:=$(ROOT_PREFIX)/etc/conf.modules
- MODCONFBACKUP:=1
- endif
- endif
- endif
- endif
- # get the minor version of module-init-tools, since only 3.2.x and above support
- # $CMDLINE_OPTS replacement
- MODTOOLSVERSION:=$(shell /sbin/modprobe --version | awk '{print $$3;}' | cut -d . -f2)
- ifneq ($(MODTOOLSVERSION),1)
- MODCMDLINE:=\$$CMDLINE_OPTS
- endif
-else # BUILDVER == linux24
- ifneq (,$(wildcard $(ROOT_PREFIX)/etc/modutils))
- MODCONF:=$(ROOT_PREFIX)/etc/modutils/zaptel
- MODCONFBACKUP:=1
- else
- ifneq (,$(wildcard $(ROOT_PREFIX)/etc/modules.conf))
- MODCONF:=$(ROOT_PREFIX)/etc/modules.conf
- MODCONFBACKUP:=1
- endif
- endif
-endif
-
# This is not related to the version that we build. Rather, to the
# version that we runs. If we build for 2.4 using 2.4 headers on a 2.6
# system with udev mounted on /dev , no point in installing files to /dev
# because they'll be wiped at next reboot.
-DYNFS:=$(shell ps ax | grep -q -v grep | grep -qw 'devfsd\|udevd' && echo "yes")
+DYNFS:=$(shell ps ax | grep -v grep | grep -qw 'devfsd\|udevd' && echo "yes")
-# Check for udev permissions directories
+# Check for udev rules directories
ifneq (,$(wildcard $(ROOT_PREFIX)/etc/udev/rules.d))
UDEVRULES=yes
- ifneq (,$(wildcard $(ROOT_PREFIX)/etc/udev/permissions.d))
- UDEVPERMISSIONS=yes
- endif
endif
CHKCONFIG:=$(shell sh -c 'type -p chkconfig' 2> /dev/null)
@@ -157,7 +118,7 @@ MODULES:=zaptel tor2 torisa wcusb wcfxo wctdm wctdm24xxp \
ztd-loc # ztdummy
#MODULES+=wcfxsusb
# build ztdummy by default for 2.6 kernels
-ifeq (${BUILDVER},linux26)
+ifeq ($(BUILDVER),linux26)
MODULES+=ztdummy
endif
@@ -195,10 +156,6 @@ UTILS:=tor2ee ztspeed zttool ztmonitor sethdlc-new \
usbfxstest fxstest fxotune fxsdump ztdiag
UTILSO:=$(UTILS:%=%.o)
-#PRIMARY=wcfxsusb
-PRIMARY=torisa
-#PRIMARY=wcfxo
-
all: modules $(LIBTONEZONE_SO)
programs: $(BINS)
@@ -353,12 +310,7 @@ ifndef DYNFS
done
else # DYNFS
ifdef UDEVRULES
- ifdef UDEVPERMISSIONS
- install -m 644 udev/zaptel.rules $(INSTALL_PREFIX)/etc/udev/rules.d
- install -m 644 udev/zaptel.permissions $(INSTALL_PREFIX)/etc/udev/permissions.d
- else # !UDEVPERMISSIONS (newer, combined syntax)
- install -m 644 udev/zaptel.rules-combined $(INSTALL_PREFIX)/etc/udev/rules.d/zaptel.rules
- endif
+ build_tools/genudevrules > $(INSTALL_PREFIX)/etc/udev/rules.d/zaptel.rules
else # !UDEVRULES
@echo "**** Dynamic filesystem detected -- not creating device nodes"
endif
@@ -372,29 +324,25 @@ install: all devices
install -D -m 755 sethdlc $(INSTALL_PREFIX)/sbin/sethdlc ; \
fi
if [ -f zttool ]; then install -D -m 755 zttool $(INSTALL_PREFIX)/sbin/zttool; fi
- if [ -f zaptel.ko ]; then \
- for x in $(MODULESKO); do \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/extra/$$x ; \
- done; \
- $(KMAKE_INST); \
- if [ -f datamods/syncppp.ko ]; then \
- $(MAKE) -C datamods install; \
- else \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/{hdlc_*,syncppp}.ko; \
- fi; \
- if ! [ -f wcfxsusb.ko ]; then \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxsusb.ko; \
- fi; \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxs.ko; \
+ifeq ($(BUILDVER),linux26)
+ for x in $(MODULESKO); do \
+ rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/extra/$$x ; \
+ done; \
+ $(KMAKE_INST); \
+ if [ -f datamods/syncppp.ko ]; then \
+ $(MAKE) -C datamods install; \
else \
- for x in $(MODULESO); do \
- install -D -m 644 $$x $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/$$x ; \
- done; \
- if ! [ -f wcfxsusb.o ]; then \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxsusb.o; \
- fi; \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxs.o; \
+ rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/{hdlc_*,syncppp}.ko; \
fi
+else
+ for x in $(MODULESO); do \
+ install -D -m 644 $$x $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/$$x ; \
+ done
+endif
+ if ! [ -f wcfxsusb.o ]; then \
+ rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxsusb.o; \
+ fi; \
+ rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxs.o
install -D -m 755 $(LIBTONEZONE_SO) $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER).$(LIBTONEZONE_SO_MINOR_VER)
[ `id -u` = 0 ] && /sbin/ldconfig || :
rm -f $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO)
@@ -402,64 +350,20 @@ install: all devices
$(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER)
ln -sf $(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER).$(LIBTONEZONE_SO_MINOR_VER) \
$(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO)
- if [ -x /usr/sbin/sestatus ] && (/usr/sbin/sestatus | grep -q "SELinux status:" | grep -q "enabled") ; then restorecon -v $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO); fi
+ if [ -x /usr/sbin/sestatus ] && (/usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled") ; then restorecon -v $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO); fi
install -D -m 644 zaptel.h $(INSTALL_PREFIX)/usr/include/linux/zaptel.h
install -D -m 644 torisa.h $(INSTALL_PREFIX)/usr/include/linux/torisa.h
install -D -m 644 tonezone.h $(INSTALL_PREFIX)/usr/include/tonezone.h
install -m 644 doc/ztcfg.8 $(INSTALL_PREFIX)/usr/share/man/man8
install -m 644 doc/zttool.8 $(INSTALL_PREFIX)/usr/share/man/man8
- if [ -n "$(MODCONF)" ]; then \
- if [ -n "$(MODCONFBACKUP)" ]; then \
- if [ -f $(MODCONF) ]; then mv -f $(MODCONF) $(MODCONF).bak ; fi; \
- cat $(MODCONF).bak | grep -q -v "alias char-major-250" | \
- grep -q -v "post-install torisa /sbin/ztcfg" | \
- grep -q -v "post-install wcfxsusb /sbin/ztcfg" | \
- grep -q -v "alias wctdm" | \
- grep -q -v "post-install wctdm /sbin/ztcfg" > $(MODCONF); \
- if ! grep -q "options torisa" $(MODCONF); then \
- echo "options torisa base=$(BASEADDR)" >> $(MODCONF); \
- fi; \
- if ! grep -q "alias char-major-196" $(MODCONF); then \
- echo "alias char-major-196 $(PRIMARY)" >> $(MODCONF); \
- fi; \
- else \
- grep "^options" $(MODCONF) > $(MODCONF).new; \
- rm -f $(MODCONF) $(MODCONF).bak; \
- mv $(MODCONF).new $(MODCONF); \
- fi; \
- for x in $(MODULES); do \
- if ! grep -q "post-install $$x" $(MODCONF); then \
- if ! grep -q "install $$x " $(MODCONF); then \
- if [ "$$x" != "zaptel" ] ; then \
- if [ -f zaptel.ko ]; then echo "install $$x /sbin/modprobe --ignore-install $$x $(MODCMDLINE) && /sbin/ztcfg" >> $(MODCONF); \
- else echo "post-install $$x /sbin/ztcfg" >> $(MODCONF); \
- fi; \
- fi; \
- fi; \
- fi; \
- done; \
- if ! grep -q "alias wcfxs" $(MODCONF); then \
- echo "alias wcfxs wctdm" >> $(MODCONF); \
- fi; \
- if ! grep -q "alias wct2xxp" $(MODCONF); then \
- echo "alias wct2xxp wct4xxp" >> $(MODCONF); \
- fi; \
- fi
+ build_tools/genmodconf $(BUILDVER) "$(ROOT_PREFIX)" "$(filter-out zaptel,$(MODULES))"
if [ -d /etc/modutils ]; then \
/sbin/update-modules ; \
fi
[ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
[ -f $(CONFIG_FILE) ] || install -D -m 644 zaptel.conf.sample $(CONFIG_FILE)
-install-udev:
- ifdef UDEVRULES
- ifdef UDEVPERMISSIONS
- install -m 644 udev/zaptel.rules $(INSTALL_PREFIX)/etc/udev/rules.d
- install -m 644 udev/zaptel.permissions $(INSTALL_PREFIX)/etc/udev/permissions.d
- else # !UDEVPERMISSIONS (newer, combined syntax)
- install -m 644 udev/zaptel.rules-combined $(INSTALL_PREFIX)/etc/udev/rules.d/zaptel.rules
- endif
- endif
+install-udev: devices
config:
if [ -d $(INSTALL_PREFIX)/etc/rc.d/init.d ]; then \
@@ -486,7 +390,7 @@ update:
rm -f .version; \
if [ `grep -q -c ^C update.out` -gt 0 ]; then \
echo ; echo "The following files have conflicts:" ; \
- grep -q ^C update.out | cut -b4- ; \
+ grep ^C update.out | cut -b4- ; \
fi ; \
rm -f update.out; \
elif [ -d CVS ]; then \
@@ -495,7 +399,7 @@ update:
rm -f .version; \
if [ `grep -q -c ^C update.out` -gt 0 ]; then \
echo ; echo "The following files have conflicts:" ; \
- grep -q ^C update.out | cut -d' ' -f2- ; \
+ grep ^C update.out | cut -d' ' -f2- ; \
fi ; \
rm -f update.out; \
else \
@@ -522,10 +426,10 @@ install-linux26: $(MODULESKO)
clean:
rm -f torisatool makefw tor2fw.h radfw.h
- rm -f ${BINS}
+ rm -f $(BINS)
rm -f *.o ztcfg tzdriver sethdlc sethdlc-new
rm -f $(TZOBJS) $(LIBTONEZONE_SO) *.lo
-ifeq (${BUILDVER},linux26)
+ifeq ($(BUILDVER),linux26)
$(KMAKE) clean
$(MAKE) -C datamods clean
endif
diff --git a/build_tools/genmodconf b/build_tools/genmodconf
new file mode 100755
index 0000000..cafc869
--- /dev/null
+++ b/build_tools/genmodconf
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+# this script makes an attempt to build a proper set of rules
+# for loading the Zaptel modules and automatically running ztcfg
+#
+# it accepts three parameters:
+# the kernel major version being targeted (either linux24 or linux26)
+# the root prefix to be used for finding/creating the files
+# the list of module names being installed
+#
+# the process is as follows:
+#
+# for linux24, the file can be located either at /etc/modules.conf (combined
+# with all other rules) or in /etc/modutils/zaptel (only the Zaptel rules)
+#
+# for linux26, the file can be located at /etc/modprobe.conf (combined with all
+# other rules), /etc/modprobe.d/zaptel (Zaptel only) or /etc/modules.d/zaptel
+# (Zaptel only)
+#
+# when the file is Zaptel rules only, then we don't preserve the existing
+# contents of the file; the system administrator can put desired options and
+# overrides in a separate file with a name that appears earlier in the sort
+# order, so there is no need to edit the file produced by this script
+#
+# when the file is combined with all other rules, then we make a backup
+# of it and remove all the old Zaptel rules we can find, replacing them with
+# new ones
+#
+# in addition, for linux26, versions of module-init-tools 3.2.0 and later
+# have the ability to pass module parameters specified on the modprobe command
+# line to commands in 'install' rules, thus keeping them from being lost, so
+# we try to determine what version is installed and take advantage of that
+
+if [ "${1}" == "linux24" ]; then
+ if [ -d ${2}/etc/modutils ]; then
+ target=${2}/etc/modutils/zaptel
+ elif [ -f ${2}/etc/modules.conf ]; then
+ target=${2}/etc/modules.conf
+ backup=1
+ else
+ echo No suitable location for module rules can be found... exiting.
+ exit 1
+ fi
+elif [ "${1}" == "linux26" ]; then
+ toolver=`/sbin/modprobe --version | awk '{print $$3;}' | cut -d. -f2`
+ if [ ${toolver} -ge 2 ]; then
+ cmdopts=\$CMDLINE_OPTS
+ fi
+ if [ -d ${2}/etc/modprobe.d ]; then
+ target=${2}/etc/modprobe.d/zaptel
+ elif [ -d ${2}/etc/modules.d ]; then
+ target=${2}/etc/modules.d/zaptel
+ elif [ -f ${2}/etc/modprobe.conf ]; then
+ target=${2}/etc/modprobe.conf
+ backup=1
+ elif [ -f ${2}/etc/conf.modules ]; then
+ target=${2}/etc/conf.modules
+ backup=1
+ else
+ echo No suitable location for module rules can be found... exiting.
+ exit 1
+ fi
+else
+ echo Unknown kernel build version requested... exiting.
+ exit 1
+fi
+
+if [ -n "${backup}" ]; then
+ if [ -f ${target} ]; then
+ mv ${target} ${target}.bak
+ cat ${target}.bak | grep -v "alias char-major-250" | grep -v "alias char-major-196" > ${target}
+ fi
+else
+ rm -f ${target}
+ echo "# automatically generated file; do not edit" > ${target}
+fi
+
+echo Building ${target}...
+
+if [ "${1}" == "linux24" ]; then
+ for mod in ${3}; do
+ if ! grep -q "post-install ${mod} " ${target}; then
+ echo "post-install ${mod} /sbin/ztcfg" >> ${target}
+ fi
+ done
+elif [ "${1}" == "linux26" ]; then
+ for mod in ${3}; do
+ if ! grep -q "install ${mod} " ${target}; then
+ echo "install ${mod} /sbin/modprobe --ignore-install ${mod} ${cmdopts} && /sbin/ztcfg" >> ${target}
+ fi
+ done
+fi
+
+if ! grep -q "alias wcfxs" ${target}; then
+ echo "alias wcfxs wctdm" >> ${target};
+fi;
+if ! grep -q "alias wct2xxp" ${target}; then
+ echo "alias wct2xxp wct4xxp" >> ${target};
+fi;
+
diff --git a/build_tools/genudevrules b/build_tools/genudevrules
new file mode 100755
index 0000000..a536f75
--- /dev/null
+++ b/build_tools/genudevrules
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+ver=`udevinfo -V | cut -f3 -d" "`
+
+if [ -z "${ver}" ]; then
+ echo Cannot determine the version of udev installed this system... exiting.
+ exit 1
+fi
+
+# udev versions prior to 055 use a single '=' for matching key values
+# udev versions 055 and later support '==' for that purpose, and versions
+# beyond 092 will probably make it mandatory
+#
+# very old versions of udev required naming rules and permissions rules to be
+# in separate files, but it's not clear at what version number that changed
+
+if [ ${ver} -gt 54 ]; then
+ match="=="
+else
+ match="="
+fi
+
+cat <<EOF
+# zaptel devices with ownership/permissions for running as non-root
+KERNEL${match}"zapctl", NAME="zap/ctl", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zaptimer", NAME="zap/timer", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zapchannel", NAME="zap/channel", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zappseudo", NAME="zap/pseudo", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zap[0-9]*", NAME="zap/%n", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+EOF
diff --git a/udev/zaptel.permissions b/udev/zaptel.permissions
deleted file mode 100644
index efc4b44..0000000
--- a/udev/zaptel.permissions
+++ /dev/null
@@ -1,2 +0,0 @@
-# zaptel devices -- for running asterisk as non-root
-zap/*:asterisk:asterisk:660
diff --git a/udev/zaptel.rules b/udev/zaptel.rules
deleted file mode 100644
index 9ad7f73..0000000
--- a/udev/zaptel.rules
+++ /dev/null
@@ -1,6 +0,0 @@
-# zaptel devices
-KERNEL=="zapctl", NAME="zap/ctl"
-KERNEL=="zaptimer", NAME="zap/timer"
-KERNEL=="zapchannel", NAME="zap/channel"
-KERNEL=="zappseudo", NAME="zap/pseudo"
-KERNEL=="zap[0-9]*", NAME="zap/%n"
diff --git a/udev/zaptel.rules-combined b/udev/zaptel.rules-combined
deleted file mode 100644
index 91719fc..0000000
--- a/udev/zaptel.rules-combined
+++ /dev/null
@@ -1,6 +0,0 @@
-# zaptel devices with ownership/permissions for running as non-root
-KERNEL=="zapctl", NAME="zap/ctl", OWNER="asterisk", GROUP="asterisk", MODE="0660"
-KERNEL=="zaptimer", NAME="zap/timer", OWNER="asterisk", GROUP="asterisk", MODE="0660"
-KERNEL=="zapchannel", NAME="zap/channel", OWNER="asterisk", GROUP="asterisk", MODE="0660"
-KERNEL=="zappseudo", NAME="zap/pseudo", OWNER="asterisk", GROUP="asterisk", MODE="0660"
-KERNEL=="zap[0-9]*", NAME="zap/%n", OWNER="asterisk", GROUP="asterisk", MODE="0660"