[svn-commits] rmudgett: branch 1.0 r308 - /branches/1.0/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 8 23:16:22 CDT 2012


Author: rmudgett
Date: Wed Aug  8 23:16:18 2012
New Revision: 308

URL: http://svnview.digium.com/svn/libss7?view=rev&rev=308
Log:
Redo the libss7 Makefile using libpri's Makefile.

* libss7 is now built optimized by default.
To build libss7 without optimization:
make LIBSS7_OPT=

* The Makefile now has an uninstall target.

* Fixed all compiler warnings including the new ones because the compiler
is now optimizing the build.

Modified:
    branches/1.0/Makefile
    branches/1.0/isup.c
    branches/1.0/ss7linktest.c
    branches/1.0/ss7test.c

Modified: branches/1.0/Makefile
URL: http://svnview.digium.com/svn/libss7/branches/1.0/Makefile?view=diff&rev=308&r1=307&r2=308
==============================================================================
--- branches/1.0/Makefile (original)
+++ branches/1.0/Makefile Wed Aug  8 23:16:18 2012
@@ -1,20 +1,78 @@
+#
+# libss7: An implementation of Signaling System 7 (SS7)
+#
+# Written by Mark Spencer <markster at linux-support.net>
+#
+# Copyright (C) 2001, Linux Support Services, Inc.
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
 CC=gcc
 GREP=grep
 AWK=awk
 
 OSARCH=$(shell uname -s)
-
+PROC?=$(shell uname -m)
+
+# SONAME version; should be changed on every ABI change
+# please don't change it needlessly; it's perfectly fine to have a SONAME
+# of 1.0 and a version of 1.4.x
+SONAME:=1.0
+
+STATIC_LIBRARY=libss7.a
+DYNAMIC_LIBRARY:=libss7.so.$(SONAME)
+STATIC_OBJS= \
+	isup.o \
+	mtp2.o \
+	mtp3.o \
+	ss7.o \
+	ss7_sched.o \
+	version.o
+DYNAMIC_OBJS= \
+	$(STATIC_OBJS)
+CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(LIBSS7_OPT) $(COVERAGE_CFLAGS)
 INSTALL_PREFIX=$(DESTDIR)
 INSTALL_BASE=/usr
 libdir?=$(INSTALL_BASE)/lib
-STATIC_OBJS=mtp2.o ss7_sched.o ss7.o mtp3.o isup.o version.o
-DYNAMIC_OBJS=mtp2.o ss7_sched.o ss7.o mtp3.o isup.o version.o
-STATIC_LIBRARY=libss7.a
-DYNAMIC_LIBRARY=libss7.so.1.0
-CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC
+ifneq ($(findstring Darwin,$(OSARCH)),)
+  SOFLAGS=-dynamic -bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
+  ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
+    SOFLAGS+=/usr/lib/bundle1.o
+  endif
+  LDCONFIG=/usr/bin/true
+else
+  SOFLAGS=-shared -Wl,-h$(DYNAMIC_LIBRARY) $(COVERAGE_LDFLAGS)
+  LDCONFIG = /sbin/ldconfig
+endif
+ifneq (,$(findstring X$(OSARCH)X, XLinuxX XGNU/kFreeBSDX XGNUX))
 LDCONFIG_FLAGS=-n
-SOFLAGS=-Wl,-hlibss7.so.1
-LDCONFIG=/sbin/ldconfig
+else
+ifeq (${OSARCH},FreeBSD)
+LDCONFIG_FLAGS=-m
+#CFLAGS += -I../zaptel -I../zapata
+INSTALL_BASE=/usr/local
+endif
+endif
+ifeq (${OSARCH},SunOS)
+#CFLAGS += -DSOLARIS -I../zaptel-solaris
+CFLAGS += -DSOLARIS
+LDCONFIG =
+LDCONFIG_FLAGS = \# # Trick to comment out the period in the command below
+#INSTALL_PREFIX = /opt/asterisk  # Uncomment out to install in standard Solaris location for 3rd party code
+endif
 
 UTILITIES=parser_debug
 
@@ -26,54 +84,124 @@
 
 SS7VERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
 
+#The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
+#This works for even old (2.96) versions of gcc and provides a small boost either way.
+#A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesnt support it.
+ifeq ($(PROC),sparc64)
+PROC=ultrasparc
+LIBSS7_OPT = -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
+else
+  ifneq ($(CODE_COVERAGE),)
+    LIBSS7_OPT=
+    COVERAGE_CFLAGS=-ftest-coverage -fprofile-arcs
+    COVERAGE_LDFLAGS=-ftest-coverage -fprofile-arcs
+  else
+    LIBSS7_OPT=-O2
+  endif
+endif
+
+ifeq ($(CPUARCH),i686)
+CFLAGS += -m32
+SOFLAGS += -m32
+endif
+
 all: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY) $(UTILITIES)
 
-MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
-
-%.lo: %.c
-	$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
-
-clean:
-	rm -f *.o *.so *.lo *.so.1 *.so.1.0
-	rm -f parser_debug ss7linktest ss7test $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
-	rm -f .*.d
+update:
+	@if [ -d .svn ]; then \
+		echo "Updating from Subversion..." ; \
+		fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
+		svn update | tee update.out; \
+		torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
+		echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
+		rm -f .version; \
+		if [ `grep -c ^C update.out` -gt 0 ]; then \
+			echo ; echo "The following files have conflicts:" ; \
+			grep ^C update.out | cut -b4- ; \
+		fi ; \
+		rm -f update.out; \
+	else \
+		echo "Not under version control";  \
+	fi
 
 install: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
 	mkdir -p $(INSTALL_PREFIX)$(libdir)
 	mkdir -p $(INSTALL_PREFIX)$(INSTALL_BASE)/include
+ifneq (${OSARCH},SunOS)
 	install -m 644 libss7.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include
-	cp -dp *.so* $(INSTALL_PREFIX)$(libdir)
+	install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
+	#if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi
+	( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf $(DYNAMIC_LIBRARY) libss7.so)
+ifeq ($(SONAME),1.0)
+	# Add this link for historic reasons
+	( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf $(DYNAMIC_LIBRARY) libss7.so.1)
+endif
 	install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
-	$(LDCONFIG) 2> /dev/null || :
+	if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(libdir); fi
+else
+	install -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include -m 644 libss7.h
+	install -f $(INSTALL_PREFIX)$(libdir) -m 755 $(DYNAMIC_LIBRARY)
+	( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf $(DYNAMIC_LIBRARY) libss7.so)
+ifeq ($(SONAME),1.0)
+	# Add this link for historic reasons
+	( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf $(DYNAMIC_LIBRARY) libss7.so.1)
+endif
+	install -f $(INSTALL_PREFIX)$(libdir) -m 644 $(STATIC_LIBRARY)
+endif
+
+uninstall:
+	@echo "Removing Libss7"
+	rm -f $(INSTALL_PREFIX)$(libdir)/$(STATIC_LIBRARY)
+	rm -f $(INSTALL_PREFIX)$(libdir)/libss7.so
+ifeq ($(SONAME),1.0)
+	rm -f $(INSTALL_PREFIX)$(libdir)/libss7.so.1
+endif
+	rm -f $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY)
+	rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include/libss7.h
+
+ss7test: ss7test.o $(STATIC_LIBRARY)
+	$(CC) -o $@ $< $(STATIC_LIBRARY) -lpthread $(CFLAGS)
+
+ss7linktest: ss7linktest.o $(STATIC_LIBRARY)
+	$(CC) -o $@ $< $(STATIC_LIBRARY) -lpthread $(CFLAGS)
+
+parser_debug: parser_debug.o $(STATIC_LIBRARY)
+	$(CC) -o $@ $< $(STATIC_LIBRARY) $(CFLAGS)
+
+MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
+
+%.lo: %.c
+	$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
 
 $(STATIC_LIBRARY): $(STATIC_OBJS)
 	ar rcs $(STATIC_LIBRARY) $(STATIC_OBJS)
 	ranlib $(STATIC_LIBRARY)
 
 $(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS)
-	$(CC) -shared $(SOFLAGS) -o $@ $(DYNAMIC_OBJS)
+	$(CC) $(SOFLAGS) -o $@ $(DYNAMIC_OBJS)
 	$(LDCONFIG) $(LDCONFIG_FLAGS) .
-	ln -sf libss7.so.1 libss7.so
-	ln -sf libss7.so.1.0 libss7.so.1
+	ln -sf $(DYNAMIC_LIBRARY) libss7.so
+ifeq ($(SONAME),1.0)
+	# Add this link for historic reasons
+	ln -sf $(DYNAMIC_LIBRARY) libss7.so.1
+endif
 
 version.c: FORCE
 	@build_tools/make_version_c > $@.tmp
 	@cmp -s $@.tmp $@ || mv $@.tmp $@
 	@rm -f $@.tmp
 
-ss7test: ss7test.c $(STATIC_LIBRARY)
-	gcc -g -o ss7test ss7test.c libss7.a -lpthread
-
-ss7linktest: ss7linktest.c $(STATIC_LIBRARY)
-	gcc -g -o ss7linktest ss7linktest.c libss7.a -lpthread
-
-parser_debug: parser_debug.c $(STATIC_LIBRARY)
-	gcc -g -Wall -o parser_debug parser_debug.c libss7.a
-
-libss7: ss7_mtp.o mtp.o ss7.o ss7_sched.o
+clean:
+	rm -f *.o *.so *.lo
+ifeq ($(SONAME),1.0)
+	rm -f *.so.1
+endif
+	rm -f $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
+	rm -f parser_debug ss7linktest ss7test
+	rm -f .*.d
 
 .PHONY:
 

Modified: branches/1.0/isup.c
URL: http://svnview.digium.com/svn/libss7/branches/1.0/isup.c?view=diff&rev=308&r1=307&r2=308
==============================================================================
--- branches/1.0/isup.c (original)
+++ branches/1.0/isup.c Wed Aug  8 23:16:18 2012
@@ -349,7 +349,7 @@
 static FUNC_DUMP(nature_of_connection_ind_dump)
 {
 	unsigned char con = parm[0];
-	char *continuity;
+	char *continuity = "";
 
 	ss7_message(ss7, "\t\t\tSatellites in connection: %d\n", con&0x03);
 	con>>=2; 
@@ -392,6 +392,8 @@
 static FUNC_DUMP(forward_call_ind_dump)
 {
 	char *cb_str, *hg_str, *kj_str;
+
+	cb_str = hg_str = kj_str = "";
 	switch ((parm[0] >> 1) & 3) {
 		case 0:
 			cb_str = "no end-to-end";
@@ -1843,6 +1845,8 @@
 		babits = parm[i] & 0x3;
 		dcbits = (parm[i] >> 2) & 0x3;
 		febits = (parm[i] >> 4) & 0x3;
+
+		ba_str = dc_str = fe_str = "";
 
 		if (dcbits == 0) {
 			switch (babits) {
@@ -2546,6 +2550,7 @@
 		offset += varparams + 1; /* add one for the optionals */
 		len -= varparams + 1;
 	} else {
+		opt_ptr = NULL;
 		offset += varparams;
 		len -= varparams;
 	}

Modified: branches/1.0/ss7linktest.c
URL: http://svnview.digium.com/svn/libss7/branches/1.0/ss7linktest.c?view=diff&rev=308&r1=307&r2=308
==============================================================================
--- branches/1.0/ss7linktest.c (original)
+++ branches/1.0/ss7linktest.c Wed Aug  8 23:16:18 2012
@@ -40,7 +40,7 @@
 #include <sys/ioctl.h>
 #include <pthread.h>
 #include <errno.h>
-#include <time.h>
+#include <sys/time.h>
 #include <dahdi/user.h>
 #include "libss7.h"
 
@@ -57,9 +57,8 @@
 
 #define NUM_BUFS 32
 
-void ss7_call(struct ss7 *ss7)
-{
-	int i;
+static void ss7_call(struct ss7 *ss7)
+{
 	struct isup_call *c;
 
 	c = isup_new_call(ss7);
@@ -73,14 +72,12 @@
 	}
 }
 
-void *ss7_run(void *data)
+static void *ss7_run(void *data)
 {
 	int res = 0;
-	unsigned char readbuf[512] = "";
 	struct timeval *next = NULL, tv;
 	struct linkset *linkset = (struct linkset *) data;
 	struct ss7 *ss7 = linkset->ss7;
-	int ourlink = linknum;
 	ss7_event *e = NULL;
 	struct pollfd poller;
 	int nextms;
@@ -104,6 +101,8 @@
 			}
 			nextms = tv.tv_sec * 1000;
 			nextms += tv.tv_usec / 1000;
+		} else {
+			nextms = -1;
 		}
 		poller.fd = linkset->fd;
 		poller.events = ss7_pollflags(ss7, linkset->fd);
@@ -111,10 +110,10 @@
 
 		res = poll(&poller, 1, nextms);
 		if (res < 0) {
-			printf("next->tv_sec = %d\n", next->tv_sec);
-			printf("next->tv_usec = %d\n", next->tv_usec);
-			printf("tv->tv_sec = %d\n", tv.tv_sec);
-			printf("tv->tv_usec = %d\n", tv.tv_usec);
+			printf("next->tv_sec = %d\n", (int) next->tv_sec);
+			printf("next->tv_usec = %d\n", (int) next->tv_usec);
+			printf("tv->tv_sec = %d\n", (int) tv.tv_sec);
+			printf("tv->tv_usec = %d\n", (int) tv.tv_usec);
 			perror("select");
 		}
 		else if (!res) {
@@ -217,15 +216,16 @@
 			}
 		}
 	}
-}
-
-void myprintf(struct ss7 *ss7, char *fmt)
-{
-	int i = 0;
+
+	return NULL;
+}
+
+static void myprintf(struct ss7 *ss7, char *fmt)
+{
 	printf("%s", fmt);
 }
 
-int zap_open(int devnum, int *ismtp2)
+static int zap_open(int devnum, int *ismtp2)
 {
 	int fd;
 	struct dahdi_bufferinfo bi;
@@ -256,7 +256,7 @@
 	return fd;
 }
 
-void print_args(void)
+static void print_args(void)
 {
 	printf("Incorrect arguments.  Should be:\n");
 	printf("ss7linktest [sigchan number] [ss7 style - itu or ansi] [OPC - in decimal] [DPC - in decimal]\n");

Modified: branches/1.0/ss7test.c
URL: http://svnview.digium.com/svn/libss7/branches/1.0/ss7test.c?view=diff&rev=308&r1=307&r2=308
==============================================================================
--- branches/1.0/ss7test.c (original)
+++ branches/1.0/ss7test.c Wed Aug  8 23:16:18 2012
@@ -38,7 +38,7 @@
 #include <sys/socket.h>
 #include <pthread.h>
 #include <errno.h>
-#include <time.h>
+#include <sys/time.h>
 #include <dahdi/user.h>
 #include "libss7.h"
 
@@ -52,10 +52,9 @@
 
 #define NUM_BUFS 32
 
-void *ss7_run(void *data)
+static void *ss7_run(void *data)
 {
 	int res = 0;
-	unsigned char readbuf[512] = "";
 	struct timeval *next = NULL, tv;
 	struct linkset *linkset = (struct linkset *) data;
 	struct ss7 *ss7 = linkset->ss7;
@@ -90,10 +89,10 @@
 		FD_SET(linkset->fd, &efds);
 		res = select(linkset->fd + 1, &rfds, &wfds, &efds, next ? &tv : NULL);
 		if (res < 0) {
-			printf("next->tv_sec = %d\n", next->tv_sec);
-			printf("next->tv_usec = %d\n", next->tv_usec);
-			printf("tv->tv_sec = %d\n", tv.tv_sec);
-			printf("tv->tv_usec = %d\n", tv.tv_usec);
+			printf("next->tv_sec = %d\n", (int) next->tv_sec);
+			printf("next->tv_usec = %d\n", (int) next->tv_usec);
+			printf("tv->tv_sec = %d\n", (int) tv.tv_sec);
+			printf("tv->tv_usec = %d\n", (int) tv.tv_usec);
 			perror("select");
 		}
 		else if (!res)
@@ -144,7 +143,7 @@
 	}
 }
 
-void myprintf(struct ss7 *ss7, char *fmt)
+static void myprintf(struct ss7 *ss7, char *fmt)
 {
 	int i = 0;
 	for (i = 0; i < 2; i++) {




More information about the svn-commits mailing list