[zaptel-commits] tzafrir: branch 1.2 r2746 - /branches/1.2/Makefile

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Mon Jul 16 13:17:30 CDT 2007


Author: tzafrir
Date: Mon Jul 16 13:17:29 2007
New Revision: 2746

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2746
Log:
Cleaning up Makefile:
INSTALL_PREFIX: /usr . A place under which standard stuff is installed.
DESTDIR: A complete subtree under which the system is installed.

Modified:
    branches/1.2/Makefile

Modified: branches/1.2/Makefile
URL: http://svn.digium.com/view/zaptel/branches/1.2/Makefile?view=diff&rev=2746&r1=2745&r2=2746
==============================================================================
--- branches/1.2/Makefile (original)
+++ branches/1.2/Makefile Mon Jul 16 13:17:29 2007
@@ -36,7 +36,7 @@
 # Set HOTPLUG_FIRMWARE=no to override automatic building with hotplug support
 # if it is enabled in the kernel.
 ifeq ($(BUILDVER),linux26)
-  ifneq (,$(wildcard $(INSTALL_PREFIX)/etc/udev/rules.d))
+  ifneq (,$(wildcard $(DESTDIR)/etc/udev/rules.d))
     DYNFS=yes
     UDEVRULES=yes
   endif
@@ -91,7 +91,7 @@
 
 HOSTCC=gcc
 
-INSTALL_PREFIX:=$(DESTDIR)
+INSTALL_PREFIX	:= $(DESTDIR)
 
 CFLAGS+=-I. -O4 -g -Wall
 CFLAGS_PPC:=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
@@ -114,9 +114,9 @@
 
 KFLAGS+=-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
+KMAKE_INST:= $(KMAKE) INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=misc modules_install
+
+CONFIG_FILE:=$(DESTDIR)/etc/zaptel.conf
 CFLAGS+=-DZAPTEL_CONFIG=\"$(CONFIG_FILE)\"
 
 ifeq ($(BUILDVER),linux24)
@@ -126,6 +126,10 @@
 
 # sample makefile "trace print"
 #tracedummy=$(shell echo ====== GOT HERE ===== >&2; echo >&2)
+
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+FIRMWARE_DIR	:= $(firstword $(wildcard /usr/lib/hotplug/firmware /lib/firmware ))
+endif
 
 CHKCONFIG	:= $(wildcard /sbin/chkconfig)
 UPDATE_RCD	:= $(wildcard /usr/sbin/update-rc.d)
@@ -160,6 +164,8 @@
   endif
 endif
 
+SELINUX_ENABLED	:= $(shell  [ -x /usr/sbin/sestatus ] && {/usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"})
+
 ifneq ($(wildcard .version),)
   ZAPTELVERSION:=$(shell cat .version)
 else
@@ -173,7 +179,14 @@
 LIBTONEZONE_SO_MAJOR_VER:=1
 LIBTONEZONE_SO_MINOR_VER:=0
 
+LIBDIR			:= $(INSTALL_PREFIX)/lib
+INCLUDE_DIR		:= $(INSTALL_PREFIX)/include
+# Note: Zaptel's use of /sbin is slightly non-standard:
+SBINDIR			:= /sbin
+# No better default. If INSTALL_PREFIX != /usr, I'm not sure 
+# where the man page sit. So they need to be manually overriden anyway.
 MANDIR			= /usr/share/man/man8
+MODS_DIR		:= /lib/modules/$(KVERS)/misc
 MAN_PAGES_BASE		= ztcfg 
 BINS=ztcfg torisatool makefw ztmonitor ztspeed zttest fxotune
 ifneq (,$(wildcard /usr/include/newt.h))
@@ -347,29 +360,29 @@
 
 devices:
 ifndef DYNFS
-	mkdir -p $(INSTALL_PREFIX)/dev/zap
-	rm -f $(INSTALL_PREFIX)/dev/zap/ctl
-	rm -f $(INSTALL_PREFIX)/dev/zap/channel
-	rm -f $(INSTALL_PREFIX)/dev/zap/pseudo
-	rm -f $(INSTALL_PREFIX)/dev/zap/timer
-	rm -f $(INSTALL_PREFIX)/dev/zap/253
-	rm -f $(INSTALL_PREFIX)/dev/zap/252
-	rm -f $(INSTALL_PREFIX)/dev/zap/251
-	rm -f $(INSTALL_PREFIX)/dev/zap/250
-	mknod $(INSTALL_PREFIX)/dev/zap/ctl c 196 0
-	mknod $(INSTALL_PREFIX)/dev/zap/timer c 196 253
-	mknod $(INSTALL_PREFIX)/dev/zap/channel c 196 254
-	mknod $(INSTALL_PREFIX)/dev/zap/pseudo c 196 255
+	mkdir -p $(DESTDIR)/dev/zap
+	rm -f $(DESTDIR)/dev/zap/ctl
+	rm -f $(DESTDIR)/dev/zap/channel
+	rm -f $(DESTDIR)/dev/zap/pseudo
+	rm -f $(DESTDIR)/dev/zap/timer
+	rm -f $(DESTDIR)/dev/zap/253
+	rm -f $(DESTDIR)/dev/zap/252
+	rm -f $(DESTDIR)/dev/zap/251
+	rm -f $(DESTDIR)/dev/zap/250
+	mknod $(DESTDIR)/dev/zap/ctl c 196 0
+	mknod $(DESTDIR)/dev/zap/timer c 196 253
+	mknod $(DESTDIR)/dev/zap/channel c 196 254
+	mknod $(DESTDIR)/dev/zap/pseudo c 196 255
 	N=1; \
 	while [ $$N -lt 250 ]; do \
-		rm -f $(INSTALL_PREFIX)/dev/zap/$$N; \
-		mknod $(INSTALL_PREFIX)/dev/zap/$$N c 196 $$N; \
+		rm -f $(DESTDIR)/dev/zap/$$N; \
+		mknod $(DESTDIR)/dev/zap/$$N c 196 $$N; \
 		N=$$[$$N+1]; \
 	done
 else # DYNFS
   ifdef UDEVRULES
-	install -d $(INSTALL_PREFIX)/etc/udev/rules.d
-	build_tools/genudevrules > $(INSTALL_PREFIX)/etc/udev/rules.d/zaptel.rules
+	install -d $(DESTDIR)/etc/udev/rules.d
+	build_tools/genudevrules > $(DESTDIR)/etc/udev/rules.d/zaptel.rules
   else # !UDEVRULES
 	@echo "**** Dynamic filesystem detected -- not creating device nodes"
   endif
@@ -385,62 +398,67 @@
 	$(MAKE) -C mISDNuser install
 
 install: all devices firmware
-	install -D -m 755 ztcfg $(INSTALL_PREFIX)/sbin/ztcfg
-	if [ -f sethdlc-new ]; then \
-		install -D -m 755 sethdlc-new $(INSTALL_PREFIX)/sbin/sethdlc; \
-	elif [ -f sethdlc ]; then \
-		install -D -m 755 sethdlc $(INSTALL_PREFIX)/sbin/sethdlc ; \
-	fi
-	if [ -f zttool ]; then install -D -m 755 zttool $(INSTALL_PREFIX)/sbin/zttool; fi
-	install -d                  $(INSTALL_PREFIX)$(MANDIR)
-	install -m 644 $(MAN_PAGES) $(INSTALL_PREFIX)$(MANDIR)
+	install -D -m 755 ztcfg $(DESTDIR)$(SBINDIR)/ztcfg
+ifneq (,$(wildcard sethdlc-new))
+	install -D -m 755 sethdlc-new $(DESTDIR)$(SBINDIR)/sethdlc
+else
+  ifneq (,$(wildcard sethdlc))
+	install -D -m 755 sethdlc $(DESTDIR)$(SBINDIR)/sethdlc
+  endif
+endif
+ifneq (,$(wildcard zttool))
+	install -D -m 755 zttool $(DESTDIR)$(SBINDIR)/zttool
+endif
+	install -d                  $(DESTDIR)$(MANDIR)
+	install -m 644 $(MAN_PAGES) $(DESTDIR)$(MANDIR)
 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) wct4xxp/wct4xxp.o; 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)
+		rm -f $(DESTDIR)/lib/modules/$(KVERS)/extra/$$x ; \
+	done
+	$(KMAKE_INST)
+else
+	install -d $(DESTDIR)$(MODS_DIR)
+	install -m 644 $(MODULESO) wct4xxp/wct4xxp.o $(DESTDIR)$(MODS_DIR)
+endif
+ifeq (,$(wildcard wcfxsusb.o))
+	rm -f $(DESTDIR)$(MODS_DIR)/wcfxsusb.o
+endif
+	rm -f $(DESTDIR)$(MODS_DIR)/wcfxs.o
+	install -D -m 755 $(LIBTONEZONE_SO) $(DESTDIR)$(LIBDIR)/$(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER).$(LIBTONEZONE_SO_MINOR_VER)
 	[ `id -u` = 0 ] && /sbin/ldconfig || :
-	rm -f $(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO)
+	rm -f $(DESTDIR)$(LIBDIR)/$(LIBTONEZONE_SO)
 	ln -sf $(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER).$(LIBTONEZONE_SO_MINOR_VER) \
-		$(INSTALL_PREFIX)/usr/lib/$(LIBTONEZONE_SO).$(LIBTONEZONE_SO_MAJOR_VER)
+		$(DESTDIR)$(LIBDIR)/$(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 "SELinux status:" | grep -q "enabled") ; then /sbin/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
+		$(DESTDIR)$(LIBDIR)/$(LIBTONEZONE_SO)
+ifneq (,$(SELINUX_ENABLED))
+	/sbin/restorecon -v $(DESTDIR)$(LIBDIR)/$(LIBTONEZONE_SO)
+endif
+	install -d $(DESTDIR)$(INCLUDE_DIR)/linux
+	install -m 644 zaptel.h torisa.h $(DESTDIR)$(INCLUDE_DIR)/linux/
+	install -m 644 tonezone.h $(DESTDIR)$(INCLUDE_DIR)
 	[ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
 	[ -f $(CONFIG_FILE) ] || install -D -m 644 zaptel.conf.sample $(CONFIG_FILE)
 	build_tools/genmodconf $(BUILDVER) "$(INSTALL_PREFIX)" "$(filter-out zaptel ztdummy zttranscode wctc4xxp ztdynamic xpp_usb,$(MODULES)) $(MODULE_ALIASES)"
 	@if [ -d /etc/modutils ]; then \
 		/sbin/update-modules ; \
 	fi
+	@echo "###################################################"
+	@echo "###"
+	@echo "### Zaptel installed successfully."
+	@echo "### If you have not done so before, install init scripts with:"
+	@echo "###"
+	@echo "###   make config"
+	@echo "###"
+	@echo "###################################################"
 
 install-udev: devices
 
+# FIRMWARE_DIR also implies HOTPLUG_FIRMWARE, unless set manually.
 firmware:
-ifeq ($(HOTPLUG_FIRMWARE),yes)
-	if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \
-		install -m 644 wct4xxp/*.ima $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
-		install -m 644 wctc4xxp/*.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \
-	fi
-	if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \
-		install -m 644 wct4xxp/*.ima $(INSTALL_PREFIX)/lib/firmware; \
-		install -m 644 wctc4xxp/*.bin $(INSTALL_PREFIX)/lib/firmware; \
-	fi
+ifneq (,$(FIRMWARE_DIR))
+	install -d $(DESTDIR)$(FIRMWARE_DIR)
+	install -m 644 wct4xxp/*.ima wctc4xxp/*.bin $(DESTDIR)$(FIRMWARE_DIR)
 	@echo "Installed firmware"
 else
 	@echo "Not installing firmware because we are not using hotplug firmware"




More information about the zaptel-commits mailing list