#
#   Copyright 2008 Free Software Foundation, Inc.
#
#  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 3 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, see <http://www.gnu.org/licenses/>.
#
#	Makefile for Motif-based routines
#	Note that GNU does not support Motif.
#	There are things in LessTif which don't quite work right (Combox Boxes and Spin boxes mainly)
#	so I don't recommend you try to use it.
#	Please note you have to find the Motif includes and library and a home for the resource files
#	"Findappdefloc" may help with the latter
#

SHELL		=	/bin/sh
prefix		=	@prefix@
exec_prefix	=	@exec_prefix@
PARENT		=	..
BASE		=	../..
HDRS		=	$(PARENT)/hdrs
CC		=	@CC@
CCFLAGS		=	-O @gcc_useful_options@ @funny_compiler_options@
CFLAGS		=	$(CCFLAGS) -I$(HDRS) -I$(PARENT) -I$(BASE)
LDFLAGS		=	
PARENT		=	..
MYLIBDIR	=	$(PARENT)/lib
LIB		=	$(MYLIBDIR)/libgnuspool_int.a
SHLIB		=	$(MYLIBDIR)/libgnuspool_int.so
LIBS		=	@LIBS@
LIBNET		=	@SOCKLIBS@
XLIBS		=	@XWIN_LIBS@
RM		=	rm -f
INSTALL		=	@INSTALL@
INSTALL_DATA	=	@INSTALL_DATA@
SPOOLUSER	=	@SPOOLUSER@
USERMODES	=	-o $(SPOOLUSER) -g root -m 4755
BINDIR		=	@bindir@
INTBINDIR	=	@pkgexecdir@
HELPFILEDIR	=	@sphelpdir@
USERBINS	=	gspl-xmpq gspl-xmuser
APPDEFLOC	=	`./Findappdefloc`

XMSPQOBS=xmspq.o xmsq_jlist.o xmsq_plist.o xmsq_cbs.o xmsq_jcall.o xmsq_pcall.o xmsq_prompt.o xmsq_view.o
XMSPUSEROBS=xmspuser.o xmspu_cbs.o

all:		@main_target@

nonshared:	$(USERBINS)

shared:		xmspq_s xmspuser_s

gspl-xmpq:		$(XMSPQOBS)
		$(CC) -o $@ $(LDFLAGS) $(XMSPQOBS) $(LIB) $(XLIBS) $(LIBNET) $(LIBS)

xmspq_s:	$(XMSPQOBS)
		$(CC) -o gspl-xmpq $(LDFLAGS) $(XMSPQOBS) $(SHLIB) $(XLIBS) $(LIBNET) $(LIBS)
		touch $@

gspl-xmuser:	$(XMSPUSEROBS)
		$(CC) -o $@ $(LDFLAGS) $(XMSPUSEROBS) $(LIB) $(XLIBS) $(LIBNET) $(LIBS)

xmspuser_s:	$(XMSPUSEROBS)
		$(CC) -o gspl-xmuser $(LDFLAGS) $(XMSPUSEROBS) $(SHLIB) $(XLIBS) $(LIBNET) $(LIBS)
		touch $@

install:	all
		$(INSTALL) $(USERMODES) $(USERBINS) $(BINDIR)
		(m4 xmspq.m4;m4 xmspuser.m4) >GSPOOL
		$(INSTALL_DATA) GSPOOL $(APPDEFLOC)
		$(RM) GSPOOL

install-strip:	all
		$(INSTALL) -s $(USERMODES) $(USERBINS) $(BINDIR)
		(m4 xmspq.m4;m4 xmspuser.m4) >GSPOOL
		$(INSTALL_DATA) GSPOOL $(APPDEFLOC)
		$(RM) GSPOOL

clean:
	$(RM) *.o gspl-xmpq gspl-xmuser *_s

distclean:	clean
	$(RM) Makefile
