summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile122
-rwxr-xr-xbuild_tools/genmodconf100
2 files changed, 121 insertions, 101 deletions
diff --git a/Makefile b/Makefile
index 173508e..8f3daf1 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
# Copyright (C) 2001-2006 Digium, Inc.
#
#
-BASEADDR=0xd0000
+
PWD:=$(shell pwd)
HOSTCC=gcc
@@ -59,48 +59,12 @@ else
BUILDVER:=linux24
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 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
-
-ifeq (${BUILDVER},linux24)
+ifeq ($(BUILDVER),linux24)
#We only support DEVFS in linux 2.4 kernels, since its considered obsolete post 2.4
DYNFS:=$(shell ps ax | grep -q -v grep | grep -q devfsd && echo "yes")
endif
-ifeq (${BUILDVER},linux26)
+ifeq ($(BUILDVER),linux26)
ifneq (,$(wildcard $(ROOT_PREFIX)/etc/udev/rules.d))
DYNFS=yes
UDEVRULES=yes
@@ -137,7 +101,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
@@ -162,10 +126,6 @@ ZTTOOL:=zttool
endif
BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
-#PRIMARY=wcfxsusb
-PRIMARY=torisa
-#PRIMARY=wcfxo
-
all: $(BUILDVER) $(LIBTONEZONE_SO)
linux24: prereq $(MODULESO) $(BINS)
@@ -348,24 +308,20 @@ 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 wcfxsusb.ko ]; then \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxsusb.ko; \
- fi; \
- rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/wcfxs.ko; \
- 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; \
- fi
+ifeq ($(BUILDVER),linux26)
+ for x in $(MODULESKO); do \
+ rm -f $(INSTALL_PREFIX)/lib/modules/$(KVERS)/extra/$$x ; \
+ done; \
+ $(KMAKE_INST); \
+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)
@@ -379,43 +335,7 @@ install: all devices
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
@@ -467,10 +387,10 @@ update:
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
endif
rm -rf .tmp_versions
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;
+