summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile176
1 files changed, 103 insertions, 73 deletions
diff --git a/Makefile b/Makefile
index b6e139c..f25edba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,17 @@
#
# Makefile for Zaptel driver modules and utilities
#
-# Copyright (C) 2001-2006 Digium, Inc.
+# Copyright (C) 2001-2007 Digium, Inc.
#
#
+CFLAGS+=-DSTANDALONE_ZAPATA -DBUILDING_TONEZONE
-HOSTCC=gcc
+ifeq ($(MAKELEVEL),0)
PWD:=$(shell pwd)
+endif
-INSTALL_PREFIX:=$(DESTDIR)
+ARCH:=$(shell uname -m | sed -e s/i.86/i386/)
# If you want to build for a kernel other than the current kernel, set KVERS
ifndef KVERS
@@ -25,7 +27,69 @@ ifndef KSRC
endif
KINCLUDES:=$(KSRC)/include
-CFLAGS+=-I. -O4 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
+ifeq (2.6,$(shell echo $(KVERS) | cut -d. -f1-2))
+ BUILDVER:=linux26
+else
+ BUILDVER:=linux24
+endif
+
+ifeq ($(BUILDVER),linux26)
+ ifneq (,$(wildcard $(INSTALL_PREFIX)/etc/udev/rules.d))
+ DYNFS=yes
+ UDEVRULES=yes
+ endif
+ HOTPLUG_FIRMWARE:=$(shell if grep CONFIG_FW_LOADER $(KINCLUDES)/linux/autoconf.h | grep -q undef; then echo "no"; else echo "yes"; fi)
+endif
+
+# Set this to override hotplug firmware loading and revert to embedded firmware
+HOTPLUG_FIRMWARE?=yes
+
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+ CFLAGS+=-DHOTPLUG_FIRMWARE
+endif
+
+MODULES:=zaptel tor2 torisa wcusb wcfxo wctdm wctdm24xxp \
+ ztdynamic ztd-eth wct1xxp wcte11xp pciradio \
+ ztd-loc # ztdummy
+#MODULES+=wcfxsusb
+ifeq ($(BUILDVER),linux26)
+MODULES+=ztdummy zttranscode
+endif
+MODULE_ALIASES=wcfxs wctdm8xxp wct2xxp
+
+MODULESO:=$(MODULES:%=%.o)
+MODULESKO:=$(MODULES:%=%.ko)
+
+# add this later, so it doesn't become part of MODULESO/MODULESKO
+MODULES+=wct4xxp wctc4xxp
+
+ifeq ($(ARCH),i386)
+ifneq ($(wildcard $(PWD)/hpec/hpec_x86_32.o_shipped),)
+HPEC_PRESENT=yes
+endif
+endif
+
+ifeq ($(ARCH),x86_64)
+ifneq ($(wildcard $(PWD)/hpec/hpec_x86_64.o_shipped),)
+HPEC_PRESENT=yes
+endif
+endif
+
+#NOTE NOTE NOTE
+#
+# all variables set before the include of Kbuild are needed by the 2.6 kernel module build process
+
+ifneq ($(KBUILD_EXTMOD),)
+
+include $(src)/Makefile.kernel26
+
+else
+
+HOSTCC=gcc
+
+INSTALL_PREFIX:=$(DESTDIR)
+
+CFLAGS+=-I. -O4 -g -Wall
CFLAGS_PPC:=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
CFLAGS_X86-64:=$(shell if uname -m | grep -q x86_64; then echo "-m64"; fi)
CFLAGS+=$(CFLAGS_PPC) $(CFLAGS_X86-64)
@@ -45,32 +109,17 @@ KFLAGS+=$(shell if uname -r | grep -q 2.4; then if uname -m | grep -q x86_64; th
#
KFLAGS+=-DSTANDALONE_ZAPATA
-CFLAGS+=-DSTANDALONE_ZAPATA
KMAKE:= $(MAKE) -C $(KSRC) SUBDIRS=$(PWD)
KMAKE_INST:= $(KMAKE) INSTALL_MOD_PATH=$(INSTALL_PREFIX) INSTALL_MOD_DIR=misc modules_install
CONFIG_FILE:=$(INSTALL_PREFIX)/etc/zaptel.conf
CFLAGS+=-DZAPTEL_CONFIG=\"$(CONFIG_FILE)\"
-ifeq (2.6,$(shell echo $(KVERS) | cut -d. -f1-2))
- BUILDVER:=linux26
-else
- BUILDVER:=linux24
-endif
-
ifeq ($(BUILDVER),linux24)
#We only support DEVFS in linux 2.4 kernels, since its considered obsolete post 2.4
DYNFS:=$(shell ps ax | grep -v grep | grep -q devfsd && echo "yes")
endif
-ifeq ($(BUILDVER),linux26)
- ifneq (,$(wildcard $(INSTALL_PREFIX)/etc/udev/rules.d))
- DYNFS=yes
- UDEVRULES=yes
- endif
- HOTPLUG_FIRMWARE:=$(shell if grep CONFIG_FW_LOADER $(KINCLUDES)/linux/autoconf.h | grep -q undef; then echo "no"; else echo "yes"; fi)
-endif
-
CHKCONFIG:=$(shell sh -c 'type -p chkconfig' 2> /dev/null)
ifndef CHKCONFIG
CHKCONFIG:=:
@@ -80,22 +129,8 @@ ifneq ($(wildcard .version),)
ZAPTELVERSION:=$(shell cat .version)
endif
-# Set this to override hotplug firmware loading and revert to classic header based
-#HOTPLUG_FIRMWARE=no
-
-ifeq ($(HOTPLUG_FIRMWARE),yes)
- CFLAGS+=-DHOTPLUG_FIRMWARE
-endif
-
-# CVS mirrors of SVN have .svnrevision files showing
-# which SVN revision they are based on, and .svnbranch
-# showing the branch they are made from
-ifneq ($(wildcard .svnrevision),)
- ZAPTELVERSION:=SVN-$(shell cat .svnbranch)-r$(shell cat .svnrevision)
-else
- ifneq ($(wildcard .svn),)
- ZAPTELVERSION=SVN-$(shell build_tools/make_svn_branch_name)
- endif
+ifneq ($(wildcard .svn),)
+ ZAPTELVERSION=SVN-$(shell build_tools/make_svn_branch_name)
endif
TZOBJS:=zonedata.lo tonezone.lo
@@ -103,53 +138,42 @@ LIBTONEZONE_SO:=libtonezone.so
LIBTONEZONE_SO_MAJOR_VER:=1
LIBTONEZONE_SO_MINOR_VER:=0
-MODULES:=zaptel tor2 torisa wcusb wcfxo wctdm wctdm24xxp \
- ztdynamic ztd-eth wct1xxp wcte11xp pciradio \
- ztd-loc # ztdummy
-#MODULES+=wcfxsusb
-ifeq ($(BUILDVER),linux26)
-MODULES+=ztdummy zttranscode
-endif
-MODULE_ALIASES=wcfxs wctdm8xxp wct2xxp
-
-MODULESO:=$(MODULES:%=%.o)
-MODULESKO:=$(MODULES:%=%.ko)
-
MOD_DESTDIR:=zaptel
-obj-m:=$(MODULESO)
-obj-m+=wct4xxp/ wctc4xxp/
-MODULES+=wct4xxp wctc4xxp
-
-# Also build xpp in the subdirectory xpp/ . But only for >=2.6.10 and only
-# for i386. On other archs the module will probably build but panic.
-# This line is only meaningful when this Makefile is used as kconfig for
-# 2.6 build
+BINS=ztcfg torisatool makefw ztmonitor ztspeed zttest fxotune
+ifneq (,$(wildcard /usr/include/newt.h))
+BINS+=zttool
+endif
-ifneq (,$(shell [ 0$(SUBLEVEL) -ge 8 ] && echo 1))
-obj-m+=xpp/
+ifeq ($(BUILDVER),linux24)
+all: prereq $(MODULESO) wct4xxp/wct4xxp.o $(BINS) $(LIBTONEZONE_SO)
endif
-ifneq (,$(wildcard /usr/include/newt.h))
-ZTTOOL:=zttool
+ifeq ($(BUILDVER),linux26)
+all: prereq $(BINS) $(LIBTONEZONE_SO)
+ @if [ -z "$(KSRC)" -o ! -d "$(KSRC)" ]; then echo "You do not appear to have the sources for the $(KVERS) kernel installed."; exit 1 ; fi
+ $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE) modules
endif
-BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
-all: $(BUILDVER) $(LIBTONEZONE_SO)
+ifeq ($(HPEC_PRESENT),yes)
+ifeq ($(ARCH),i386)
+ZAPTEL_HPEC:=hpec/hpec_x86_32.o_shipped
+endif
-linux24: prereq $(MODULESO) wct4xxp/wct4xxp.o $(BINS)
+ifeq ($(ARCH),x86_64)
+ZAPTEL_HPEC:=hpec/hpec_x86_64.o_shipped
+endif
-linux26: prereq $(BINS)
- @echo $(KSRC)
- @if [ -z "$(KSRC)" -o ! -d "$(KSRC)" ]; then echo "You do not appear to have the sources for the $(KVERS) kernel installed."; exit 1 ; fi
- $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE) modules
+CFLAGS+=-DECHO_CAN_HPEC -I$(PWD)/hpec
+zaptel-base.o: hpec/hpec_zaptel.h hpec/hpec_user.h
+endif
version.h: FORCE
- ZAPTELVERSION="${ZAPTELVERSION}" build_tools/make_version_h > $@.tmp
- if cmp -s $@.tmp $@ ; then echo; else \
+ @ZAPTELVERSION="${ZAPTELVERSION}" build_tools/make_version_h > $@.tmp
+ @if cmp -s $@.tmp $@ ; then echo; else \
mv $@.tmp $@ ; \
fi
- rm -f $@.tmp
+ @rm -f $@.tmp
wct4xxp/wct4xxp.o:
$(MAKE) -C wct4xxp KFLAGS="$(KFLAGS) -I.." CFLAGS="$(CFLAGS) -I.."
@@ -159,9 +183,11 @@ devel: tor2ee
tests: patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest
$(MAKE) -C wctc4xxp tests CFLAGS="$(CFLAGS) -I.."
+$(MODULESO): zaptel.h
+
tor2.o: tor2-hw.h tor2fw.h
-zaptel.o: digits.h arith.h sec.h mec.h sec-2.h mec2.h mec3.h zconfig.h version.h
+zaptel-base.o: digits.h arith.h sec.h sec-2.h mec.h mec2.h mec3.h mg2ec.h kb1ec.h zconfig.h version.h tones.h
torisa.o: torisa.h
@@ -177,7 +203,10 @@ pciradio.o: radfw.h
ztdummy.o: ztdummy.h
-$(MODULESO): %.o: %.c zaptel.h
+zaptel.o: zaptel-base.o $(ZAPTEL_HPEC)
+ $(LD) -r -o $@ $< $(ZAPTEL_HPEC)
+
+$(filter-out zaptel.o,$(MODULESO)) zaptel-base.o: %.o: %.c
$(CC) $(KFLAGS) -o $@ -c $<
tor2ee.o: tor2-hw.h
@@ -206,8 +235,6 @@ radfw.h: makefw pciradio.rbt
gendigits: gendigits.o
$(CC) -o $@ $^ -lm
-zaptel.c: tones.h
-
prereq: tones.h tor2fw.h radfw.h version.h
zttool.o: zttool.c zaptel.h
@@ -428,3 +455,6 @@ clean:
rm -rf mISDNuser*
FORCE:
+
+endif
+