# ****************************************************************************
# 
# $Id: Makefile,v 1.4 2000/10/13 15:45:51 brian Exp $
# 
# Copyright (C) 1997  Brian Bidulock <bidulock@planet.eon.net>
# 
# 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.
# 
# ****************************************************************************
# 
# $Log: Makefile,v $
# Revision 1.4  2000/10/13 15:45:51  brian
# First public release.
#
# Revision 1.3  1998/09/16 05:06:24  brian
# Checkin in new main revision.
#
# Revision 1.2  1998/09/15 20:04:09  brian
# Removed RCS file references from Makefile.
#
# Revision 1.1.1.1  1998/08/14 18:44:23  brian
# Imported Brian's SS7 stack into prototype directory.
#
# Revision 0.1.0.17  1998/08/14 03:47:03  brian
# Made corrections so that dynamic libraries are linked and installed
# properly.
#
# Revision 0.1.0.16  1998/08/10 03:23:58  brian
# Compiled on Lab System.
#
# Revision 0.1.0.15  1997/12/06 09:23:48  brian
# ISUP runs but some problems left to debug (segmentation fault on exit).
#
# Revision 0.1.0.14  1997/12/06 08:49:14  brian
# First clean compile of ISUP.
#
# Revision 0.1.0.13  1997/12/04 10:41:51  brian
# Minor fix to mnemonics and text.
#
# Revision 0.1.0.12  1997/12/04 10:35:02  brian
# SCCP optional parameters work for both encode and decodevim SCCP_Codec.C!
#
# Revision 0.1.0.11  1997/12/03 23:31:53  brian
# SCCP level encode/decode works good. Still working on optional parameters.
#
# Revision 0.1.0.10  1997/12/03 09:47:29  brian
# Still working up necessary support for SCCP.
#
# Revision 0.1.0.9  1997/12/03 04:22:38  brian
# Added counting flags.
#
# Revision 0.1.0.8  1997/12/02 23:39:03  brian
# Clean compile of SCCP codecs.
#
# Revision 0.1.0.7  1997/12/02 22:46:34  brian
# Added SCCP codec.
#
# Revision 0.1.0.6  1997/12/01 18:06:48  brian
# Level 3 works fine.
#
# Revision 0.1.0.5  1997/12/01 07:38:57  brian
# Few minor corrections. Start of Level 3 codec.
#
# Revision 0.1.0.4  1997/11/29 06:27:31  brian
# First attempt at testable decoder.
#
# Revision 0.1.0.3  1997/11/29 01:03:52  brian
# Added some reporting.
#
# Revision 0.1.0.2  1997/11/28 23:59:34  brian
# Initial checkout compile.
#
# Revision 0.1.0.1  1997/11/28 23:59:11  brian
# Initial development branch.
#
# Revision 0.1  1997/11/28 23:58:56  brian
# Initial revision
#
# ****************************************************************************

DESC =

PACKAGE=ss7codec

REV_MAJ = 0
REV_MIN = 1
REV_SUB = 0
REV=$(REV_MAJ).$(REV_MIN).$(REV_SUB)

RELEASE=$(PACKAGE)-$(REV)

LIB_FILES = lib$(PACKAGE).so.$(REV)

CC = gcc
CCC = g++

CLIBS = $(LIB_FILES:lib%.so.$(REV)=-l%)
OFLAGS = -fexceptions
#DFLAGS =
DFLAGS = -ggdb -D_DEBUG
LFLAGS = $(DFLAGS) -shared
CFLAGS = $(DFLAGS) $(OFLAGS)
CLFLAGS = $(DFLAGS) $(OFLAGS)
CCFLAGS = $(DFLAGS) -fexceptions -fpic -fPIC

AAA_FILES = 
CLB_FILES = 
CCC_FILES = Codec.C SS7_Codec.C L2_Codec.C L3_Codec.C SCCP_Codec.C ISUP_Codec.C
SRC_FILES = test1.C test2.C test3.C test4.C
OLA_FILES = $(AAA_FILES:%.S=%.o)
OLB_FILES = $(CLB_FILES:%.c=%.o)
OOO_FILES = $(CCC_FILES:%.C=%.o)
ALB_FILES = $(CLB_FILES:%.c=%.s)
ASM_FILES = $(CCC_FILES:%.C=%.s) $(SRC_FILES:%.C=%.s)
OBJ_FILES = $(SRC_FILES:%.C=%)
HDR_FILES = $(CCC_FILES:%.C=%.H) $(CLB_FILES:%.c=%.h) $(AAA_FILES:%.S=%.h)
MAN_FILES = 
MGZ_FILES = $(MAN_FILES:%=%.gz)
DOC_FILES = README $(RELEASE).lsm
TXT_FILES = $(AAA_FILES) \
	    $(CCC_FILES) \
	    $(CLB_FILES) \
	    $(SRC_FILES) \
	    $(HDR_FILES) \
	    $(MAN_FILES) \
	    $(DOC_FILES)
RCS_FILES = $(TXT_FILES:%=RCS/%,v)
BIN_FILES = $(OLA_FILES) \
	    $(OBJ_FILES) \
	    $(OOO_FILES) \
	    $(OLB_FILES) \
	    $(LIB_FILES) \
	    $(MGZ_FILES)

USR_DIR = /usr/local
MAN_DIR = $(USR_DIR)/man/man1
BIN_DIR = $(USR_DIR)/bin
DOC_DIR = $(USR_DIR)/doc/$(RELEASE)
LIB_DIR = $(USR_DIR)/lib

all: $(TXT_FILES) $(BIN_FILES)

$(LIB_FILES): %.$(REV): $(OOO_FILES) $(OLB_FILES) $(OLA_FILES)
	$(CC) $(LFLAGS) -Wl,-soname=$*.$(REV),-soname=$*.$(REV_MAJ).$(REV_MIN),-soname=$* -o $@ $(OOO_FILES) $(OLB_FILES) $(OLA_FILES); \
#	su -c "make install_lib"

# $(OBJ_FILES): %: %.h  # make .depend does this

$(OBJ_FILES): %: %.C $(LIB_FILES)
	$(CCC) $(CFLAGS) $(CLIBS) $< -o $@

$(OOO_FILES): %.o: %.C
	$(CCC) $(CCFLAGS) $(CCLIBS) -c -o $@ $<

$(OLB_FILES): %.o: %.c
	$(CC) $(CLFLAGS) -c -o $@ $<

$(OLA_FILES): %.o: %.S
	$(CC) $(CLFLAGS) -c -o $@ $<

$(ASM_FILES): %.s: %.C
	$(CCC) $(CCFLAGS) $(CCLIBS) -S -o $@ $<

$(ALB_FILES): %.s: %.c
	$(CC) $(CFLAGS) $(CCLIBS) -S -o $@ $<

$(MGZ_FILES): %.gz : %
	gzip $< ; \
	zcat $@ > $< ; \
	touch $@

#$(TXT_FILES): % : RCS/%,v
#	co -l$(REV) $<

#.checkin: $(TXT_FILES) Makefile
#	ci -l$(REV) $?; \
#	touch $@

install_man: $(MAN_FILES)
	install -d -o root -g root -m 755 $(MAN_DIR); \
	for i in $?; do install -o root -g root -m 644 $$i $(MAN_DIR); done

install_manz: $(MGZ_FILES)
	install -d -o root -g root -m 755 $(MAN_DIR); \
	for i in $?; do install -o root -g root -m 644 $$i $(MAN_DIR); done

install_doc: $(DOC_FILES) GPL
	install -d -o root -g root -m 755 $(DOC_DIR); \
	for i in $?; do install -o root -g root -m 644 $$i $(DOC_DIR); done

install_obj: $(OBJ_FILES)
	install -d -o root -g bin -m 755 $(BIN_DIR); \
	for i in $?; do install -s -o root -g bin -m 755 $$i $(BIN_DIR); done

install_lib: $(LIB_FILES)
	install -d -o root -g root -m 755 $(LIB_DIR); \
	for i in $?; do install -s -o root -g root -m 644 $$i $(LIB_DIR); done; \
	/sbin/ldconfig; \
	/sbin/ldconfig -p | grep ss7

install: install_lib install_obj install_doc install_manz

uinstall:
	cd $(MAN_DIR); \
	rm -f $(MGZ_FILES); \
	cd $(BIN_DIR); \
	rm -f $(OBJ_FILES); \
	cd $(LIB_DIR); \
	rm -f $(LIB_FILES); \
	cd $(DOC_DIR); \
	rm -f $(DOC_FILES);
	
release_src: $(TXT_FILES) GPL Makefile
	tar -C .. -cf ../$(RELEASE).src ; \
	for i in $?; do tar -C .. -rf ../$(RELEASE).src $(PACKAGE)/$$i; done; \
	gzip -S .tgz ../$(RELEASE).src

release_bin: $(TXT_FILES) $(BIN_FILES) GPL Makefile
	tar -C .. -cf ../$(RELEASE).bin ; \
	for i in $?; do tar -C .. -rf ../$(RELEASE).bin $(PACKAGE)/$$i; done; \
	gzip -S .tgz ../$(RELEASE).bin

archive: $(RCS_FILES) GPL Makefile
	tar -C .. -cf ../$(RELEASE).ar ; \
	for i in $?; do tar -C .. -rf ../$(RELEASE).ar $(PACKAGE)/$$i; done; \
	gzip -S .tgz ../$(RELEASE).ar

release: release_src release_bin

sizes: $(TXT_FILES) $(LIB_FILES) $(OOO_FILES) $(OLB_FILES) $(OLA_FILES)
	wc -l $(TXT_FILES)
	size $(OLA_FILES) $(OLB_FILES) $(OOO_FILES) $(LIB_FILES)

clean:
	rm -f $(BIN_FILES) core

src_dist_clean: clean
	rm -f $(TXT_FILES) ../$(RELEASE).src.tgz

bin_dist_clean: clean
	rm -f $(TXT_FILES) $(BIN_FILES) ../$(RELEASE).bin.tgz

dist_clean: src_dist_clean bin_dist_clean

arch_clean: dist_clean
	rm -f ../$(RELEASE).ar.tgz

.depend_S: $(AAA_FILES)
	echo "" > $@; \
	for i in $?; do $(CC) -M $$i >> $@; done

.depend_l: $(CLB_FILES)
	echo "" > $@; \
	for i in $?; do $(CC) -M $$i >> $@; done

.depend_C: $(CCC_FILES)
	echo "" > $@; \
	for i in $?; do $(CCC) -M $$i >> $@; done

.depend_c: $(SRC_FILES)
	echo "" > $@; \
	for i in $?; do $(CCC) -M $$i >> $@; done

.depend: .depend_S .depend_l .depend_C .depend_c
	echo "# DON'T REMOVE THIS LINE" > $@; \
	cat .depend_S >> $@; \
	cat .depend_l >> $@; \
	cat .depend_C >> $@; \
	sed -e s/.o:/:/ .depend_c >> $@; \
	rm $?

depend: .depend
	mv Makefile Makefile.bak; \
	sed -e "/^# DON'T/,$$$$d" Makefile.bak > Makefile; \
	cat .depend >> Makefile; \
	rm .depend

# DON'T REMOVE THIS LINE



Codec.o: Codec.C Codec.H /usr/include/values.h /usr/include/features.h \
 /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h \
 /usr/include/string.h
SS7_Codec.o: SS7_Codec.C SS7_Codec.H Codec.H /usr/include/values.h \
 /usr/include/features.h /usr/include/sys/cdefs.h \
 /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h
L2_Codec.o: L2_Codec.C L2_Codec.H Codec.H /usr/include/values.h \
 /usr/include/features.h /usr/include/sys/cdefs.h \
 /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h
L3_Codec.o: L3_Codec.C L3_Codec.H Codec.H /usr/include/values.h \
 /usr/include/features.h /usr/include/sys/cdefs.h \
 /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 SS7_Codec.H /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h
SCCP_Codec.o: SCCP_Codec.C SCCP_Codec.H Codec.H /usr/include/values.h \
 /usr/include/features.h /usr/include/sys/cdefs.h \
 /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 SS7_Codec.H /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h
ISUP_Codec.o: ISUP_Codec.C ISUP_Codec.H SS7_Codec.H Codec.H \
 /usr/include/values.h /usr/include/features.h \
 /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h

test1: test1.C L2_Codec.H Codec.H /usr/include/values.h \
 /usr/include/features.h /usr/include/sys/cdefs.h \
 /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h
test2: test2.C L3_Codec.H Codec.H /usr/include/values.h \
 /usr/include/features.h /usr/include/sys/cdefs.h \
 /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 SS7_Codec.H /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h
test3: test3.C SCCP_Codec.H Codec.H /usr/include/values.h \
 /usr/include/features.h /usr/include/sys/cdefs.h \
 /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 SS7_Codec.H /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h
test4: test4.C ISUP_Codec.H SS7_Codec.H Codec.H \
 /usr/include/values.h /usr/include/features.h \
 /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/limits.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/syslimits.h \
 /usr/include/limits.h /usr/include/bits/posix1_lim.h \
 /usr/include/bits/local_lim.h /usr/include/linux/limits.h \
 /usr/include/bits/posix2_lim.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/float.h \
 /usr/include/unistd.h /usr/include/bits/posix_opt.h \
 /usr/include/bits/types.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h \
 /usr/include/bits/confname.h /usr/include/getopt.h \
 /usr/include/g++-2/iostream.h /usr/include/g++-2/streambuf.h \
 /usr/include/libio.h /usr/include/_G_config.h \
 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stdarg.h
