#
#   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 GTK routines
#

SHELL		=	/bin/sh
prefix		=	@prefix@
exec_prefix	=	@exec_prefix@
PARENT		=	..
BASE		=	../..
HDRS		=	$(PARENT)/hdrs
CC		=	@CC@
CCFLAGS		=	-O @gcc_useful_options@ @funny_compiler_options@
LDFLAGS		=	
GTKINCL		=	`pkg-config --cflags gtk+-2.0`
CFLAGS		=	$(CCFLAGS) -I$(HDRS) -I$(BASE) $(GTKINCL)
LIBDIR		=	@libdir@
MYLIBDIR	=	$(PARENT)/lib
LIB		=	$(MYLIBDIR)/libgnuspool_int.a
SHLIB		=	$(MYLIBDIR)/libgnuspool_int.so
LIBS		=	@LIBS@
LIBNET		=	@SOCKLIBS@
GTKLIBS		=	`pkg-config --libs gtk+-2.0`
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-xpq gspl-xuser
SYSBINS		=	gtksave
XRES		=	xspq.xpm xspq.menu xspqview.menu xspqsel.menu xspuser.xpm xspuser.menu

XSPUSEROBS=xspuser.o xspu_cbs.o gtk_lib.o
XSPQOBS=xspq.o xsq_cbs.o xsq_jplist.o xsq_jcall.o xsq_pcall.o xsq_prompt.o xsq_view.o gtk_lib.o
GTKSAVEOBS=gtksave.o

all:		@main_target@

nonshared:	gspl-xpq gspl-xuser gtksave

shared:		xspq_s xspuser_s gtksave_s

gspl-xuser:	$(XSPUSEROBS)
		$(CC) -o $@ $(LDFLAGS) $(XSPUSEROBS) $(LIB) $(GTKLIBS) $(LIBNET) $(LIBS)

xspuser_s:	$(XSPUSEROBS)
		$(CC) -o gspl-xuser $(LDFLAGS) $(XSPUSEROBS) $(SHLIB) $(GTKLIBS) $(LIBNET) $(LIBS)
		touch $@

gspl-xpq:		$(XSPQOBS)
		$(CC) -o $@ $(LDFLAGS) $(XSPQOBS) $(LIB) $(GTKLIBS) $(LIBNET) $(LIBS)

xspq_s:		$(XSPQOBS)
		$(CC) -o gspl-xpq $(LDFLAGS) $(XSPQOBS) $(SHLIB) $(GTKLIBS) $(LIBNET) $(LIBS)
		touch $@

gtksave:	$(GTKSAVEOBS)
		$(CC) -o $@ $(LDFLAGS) $(GTKSAVEOBS) $(LIB) $(LIBS)

gtksave_s:	$(GTKSAVEOBS)
		$(CC) -o gtksave $(LDFLAGS) $(GTKSAVEOBS) $(SHLIB) $(LIBS)
		touch $@

install:	all
		$(INSTALL) $(USERMODES) $(USERBINS) $(BINDIR)
		$(INSTALL) $(SYSBINS) $(INTBINDIR)
		$(INSTALL_DATA) $(XRES) $(HELPFILEDIR)

install-strip:	all
		$(INSTALL) -s $(USERMODES) $(USERBINS) $(BINDIR)
		$(INSTALL) -s $(SYSBINS) $(INTBINDIR)
		$(INSTALL_DATA) $(XRES) $(HELPFILEDIR)

clean:
	$(RM) *.o $(USERBINS) $(SYSBINS) *_s core.*

distclean:	clean
	$(RM) Makefile
