Ignore files generated in the dependency checks.
[libpri-bristuff.git] / Makefile
blob78fb5d6975148ac8d80e34739cc8aa799cf24a71
2 # libpri: An implementation of Primary Rate ISDN
4 # Written by Mark Spencer <markster@linux-support.net>
6 # Copyright (C) 2001, Linux Support Services, Inc.
7 # All Rights Reserved.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 # Uncomment if you want libpri not send PROGRESS_INDICATOR w/ALERTING
25 #ALERTING=-DALERTING_NO_PROGRESS
27 # Uncomment if you want libpri to count number of Q921/Q931 sent/received
28 #LIBPRI_COUNTERS=-DLIBPRI_COUNTERS
30 # Uncomment if you want libpri to always keep layer 2 up
31 #LAYER2ALWAYSUP=-DLAYER2ALWAYSUP
33 # Uncomment if you want libpri to hangup a call to an NT (p2mp) port if one
34 # device sends a RELEASE COMPLETE with cause 17
35 #FASTBUSYONBUSY=-DFASTBUSYONBUSY
37 # workaround for slowly responding COs
38 #RELAXEDTIMERS=-DRELAXED_TIMERS
40 CC=gcc
41 GREP=grep
42 AWK=awk
44 OSARCH=$(shell uname -s)
45 PROC?=$(shell uname -m)
47 SONAME=1.0
48 STATIC_LIBRARY=libpri.a
49 DYNAMIC_LIBRARY=libpri.so.$(SONAME)
50 STATIC_OBJS=copy_string.o pri.o q921.o prisched.o q931.o pri_facility.o version.o
51 DYNAMIC_OBJS=copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo version.lo
52 CFLAGS=-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC $(ALERTING) $(LIBPRI_COUNTERS) $(LAYER2ALWAYSUP) $(FASTBUSYONBUSY) -DRELAX_TRB $(RELAXEDTIMERS)
53 INSTALL_PREFIX=$(DESTDIR)
54 INSTALL_BASE=/usr
55 libdir?=$(INSTALL_BASE)/lib
56 SOFLAGS = -Wl,-hlibpri.so.1.0
57 LDCONFIG = /sbin/ldconfig
58 ifneq (,$(findstring X$(OSARCH)X, XLinuxX XGNU/kFreeBSDX))
59 LDCONFIG_FLAGS=-n
60 else
61 ifeq (${OSARCH},FreeBSD)
62 LDCONFIG_FLAGS=-m
63 CFLAGS += -I../zaptel -I../zapata
64 INSTALL_BASE=/usr/local
65 endif
66 endif
67 ifeq (${OSARCH},SunOS)
68 CFLAGS += -DSOLARIS -I../zaptel-solaris
69 LDCONFIG =
70 LDCONFIG_FLAGS = \# # Trick to comment out the period in the command below
71 SOSLINK = ln -sf libpri.so.1.0 libpri.so.1
72 #INSTALL_PREFIX = /opt/asterisk # Uncomment out to install in standard Solaris location for 3rd party code
73 endif
75 export PRIVERSION
77 PRIVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
79 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
80 #This works for even old (2.96) versions of gcc and provides a small boost either way.
81 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesnt support it.
82 ifeq ($(PROC),sparc64)
83 PROC=ultrasparc
84 CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
85 endif
87 all: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
89 update:
90 @if [ -d .svn ]; then \
91 echo "Updating from Subversion..." ; \
92 svn update -q; \
93 else \
94 echo "Not under version control"; \
97 install: $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
98 mkdir -p $(INSTALL_PREFIX)$(libdir)
99 mkdir -p $(INSTALL_PREFIX)$(INSTALL_BASE)/include
100 ifneq (${OSARCH},SunOS)
101 install -m 644 libpri.h $(INSTALL_PREFIX)$(INSTALL_BASE)/include
102 install -m 755 $(DYNAMIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
103 if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v $(INSTALL_PREFIX)$(libdir)/$(DYNAMIC_LIBRARY); fi
104 ( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so)
105 install -m 644 $(STATIC_LIBRARY) $(INSTALL_PREFIX)$(libdir)
106 if test $$(id -u) = 0; then $(LDCONFIG) $(LDCONFIG_FLAGS) $(INSTALL_PREFIX)$(libdir); fi
107 else
108 install -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include -m 644 libpri.h
109 install -f $(INSTALL_PREFIX)$(libdir) -m 755 $(DYNAMIC_LIBRARY)
110 ( cd $(INSTALL_PREFIX)$(libdir) ; ln -sf libpri.so.$(SONAME) libpri.so)
111 install -f $(INSTALL_PREFIX)$(libdir) -m 644 $(STATIC_LIBRARY)
112 endif
114 uninstall:
115 @echo "Removing Libpri"
116 rm -f $(INSTALL_PREFIX)$(libdir)/libpri.so.$(SONAME)
117 rm -f $(INSTALL_PREFIX)$(libdir)/libpri.so
118 rm -f $(INSTALL_PREFIX)$(libdir)/libpri.a
119 rm -f $(INSTALL_PREFIX)$(INSTALL_BASE)/include/libpri.h
121 pritest: pritest.o
122 $(CC) -o pritest pritest.o -L. -lpri -lzap $(CFLAGS)
124 testprilib.o: testprilib.c
125 $(CC) $(CFLAGS) -D_REENTRANT -D_GNU_SOURCE -o $@ -c $<
127 testprilib: testprilib.o
128 $(CC) -o testprilib testprilib.o -L. -lpri -lpthread $(CFLAGS)
130 pridump: pridump.o
131 $(CC) -o pridump pridump.o -L. -lpri $(CFLAGS)
133 MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
135 %.o: %.c
136 $(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
138 %.lo: %.c
139 $(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
141 $(STATIC_LIBRARY): $(STATIC_OBJS)
142 ar rcs $(STATIC_LIBRARY) $(STATIC_OBJS)
143 ranlib $(STATIC_LIBRARY)
145 $(DYNAMIC_LIBRARY): $(DYNAMIC_OBJS)
146 $(CC) -shared $(SOFLAGS) -o $@ $(DYNAMIC_OBJS)
147 $(LDCONFIG) $(LDCONFIG_FLAGS) .
148 ln -sf libpri.so.1.0 libpri.so
149 ln -sf libpri.so.1.0 libpri.so.1
150 $(SOSLINK)
152 version.c: FORCE
153 @build_tools/make_version_c > $@.tmp
154 @cmp -s $@.tmp $@ || mv $@.tmp $@
155 @rm -f $@.tmp
157 clean:
158 rm -f *.o *.so *.lo *.so.1 *.so.1.0
159 rm -f testprilib $(STATIC_LIBRARY) $(DYNAMIC_LIBRARY)
160 rm -f pritest pridump
161 rm -f .*.d
163 .PHONY:
165 FORCE:
167 ifneq ($(wildcard .*.d),)
168 include .*.d
169 endif