#
# Copyright (C) 1994 Communications and Systems Specialists, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a 
# copy of this software and associated documentation files (the 
# "Software"), to deal in the Software without restriction, including 
# without limitation the rights to use, copy, modify, merge, publish, 
# distribute, sublicense, and/or sell copies of the Software, and to 
# permit  persons to whom the Software is furnished to do so, subject to 
# the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
# IN NO EVENT SHALL COMMUNICATIONS AND SYSTEMS SPECIALISTS, INC. BE 
# LIABLE FOR ANY CLAIM,  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of Communications and 
# Systems Specialists, Inc. shall not be used in advertising or otherwise
# to promote the sale, use or other dealings in this Software without 
# prior written authorization from Communications and Systems 
# Specialists, Inc.
############################################################################


# Adjust for the location of OpenWindows or comment out if OpenWindows is 
# not available.  If OPENWINHOME is not set, default to /usr/openwin for 
# the location of OpenWindows
OPENWINHOME:sh	= echo ${OPENWINHOME:-/usr/openwin}

# Adjust for the location of Motif; if Motif is not available, comment
# the MOTIF... options out.
# If MOTIFHOME is not set, default to /opt/SUNWmotif for the location of
# Motif
MOTIFHOME:sh	= echo ${MOTIFHOME:-/opt/SUNWmotif}
MOTIFOBJ	= lib/XmsgXm.o
MOTIFTEST	= test/XmTest

# Specify the compiler
CC = cc

# Location of X include files; adjust as necessary
XINC = -I/usr/X11R6/include -I${OPENWINHOME}/include -I${MOTIFHOME}/include

# Location of X libraries; adjust as necessary
XLIB = -L/usr/X11R6/lib -L$(OPENWINHOME)/lib -L$(MOTIFHOME)/lib

# Location to place libXmsg.a
LIBINSTALLDIR = /usr/X11R6/lib

# Location to place include directory
INCINSTALLDIR = /usr/X11R6/include/Xmsg

# Location to place man pages
MAN3INSTALLDIR = /usr/X11R6/man/man3

# Debug flags
DEBUG =  -g

# Optimization flags
OPTIMIZE = -O2

# O/S Specific libraries
# Solaris 2: -lgen -lsocket -lnsl
OSLIBS = -lgen -lsocket -lnsl

# Compiler arguments
ARGS = -Xc

### DO NOT MODIFY ANYTHING BELOW HERE ###

#
# Source package description
#

LIBNAME	= libXmsg.a

INCDIRS	= -I./lib -I./include $(XINC)
LIBDIRS	= -L./lib             $(XLIB)

CFLAGS	= $(DEBUG) $(OPTIMIZE) $(ARGS) $(INCDIRS) -DXmsgUSE_DEBUG=1
LDFLAGS	= $(LIBDIRS)

LIBS	= -lXmsg -lXm -lXaw -lXt -lXmu -lXtst -lX11 $(OSLIBS)



all:	lib/$(LIBNAME) test/XawTest $(MOTIFTEST)

# rules for making the Xmsg library
OBJS	= lib/Xmsg.o $(MOTIFOBJ)

lib/%.o : lib/%.c
	$(COMPILE.c) -o $@ $<

lib/$(LIBNAME): $(OBJS)
	$(AR) $(ARFLAGS) $@ $?
#	ranlib $@

install: all
	install -d $(LIBINSTALLDIR)
	install -c lib/$(LIBNAME) $(LIBINSTALLDIR)
#	ranlib $(LIBINSTALLDIR)/$(LIBNAME)
	chmod 664 $(LIBINSTALLDIR)/$(LIBNAME)
	install -d $(INCINSTALLDIR)
	install -c include/* $(INCINSTALLDIR)
	install -d $(MAN3INSTALLDIR)
	install -c man3/* $(MAN3INSTALLDIR)


# rules for making test programs

test/%.o : test/%.c
	$(COMPILE.c) -o $@ $<

test/XawTest : test/XawTest.o lib/$(LIBNAME)
	$(CC) $(LDFLAGS) -o $@ $@.o $(LIBS)

test/XmTest : test/XmTest.o lib/$(LIBNAME)
	$(CC) $(LDFLAGS) -o $@ $@.o $(LIBS)


tar:
	cd ..; tar cvf Xmsg-1.0.tar Xmsg-1.0; gzip Xmsg-1.0.tar

clean:
	rm -f lib/$(LIBNAME) lib/*.o test/*.o test/XawTest test/XmTest
