# =============================================================================
# xLogin - Makefile
#
# -----------------------------------------------------------------------------
# Copyright (C) 1995-1999 by Karim Kaschani
#
# 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
# to 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
# THE AUTHOR 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. 
# -----------------------------------------------------------------------------
#
# NOTE: If your system's utmp- or utmpx-file lacks the UTMP_FILE, UTMPX_FILE,
#       WTMP_FILE or WTMPX_FILE macro, make sure to set -DUTMP_FILE,
#       -DUTMPX_FILE, DWTMP_FILE or -DWTMPX_FILE appropriately.
# =============================================================================

# the directory, where the binaries go
BINDIR    = /usr/local/bin

# the directory, where the man pages will be installed
MANDIR	  = /usr/local/man/man1

# the directory, where you keep your pixmaps
PIXMAPDIR = /usr/local/include/X11/pixmaps

# the directory, where the X application defaults are installed
XAPPDEFAULTS = /usr/X11/lib/X11/app-defaults

# ----------------------------------------------------------------- Solaris 2.4

#INSTALL  = /usr/ucb/install
#CC       = gcc
#CFLAGS   = -c
#COPTIONS = -g -O2
#DEFINES  = -DSUN -DSVR4 -DSYSV
#INCLUDES = -I/usr/openwin/include -I/usr/dt/include
#LDFLAGS  = -lnsl
#XLDFLAGS = -L/usr/openwin/lib -L/usr/dt/lib -lXm -lXt -lXext -lX11 \
#           -R /usr/openwin/lib -R /usr/dt/lib

# ----------------------------------------------------------------------- SunOS

#INSTALL  = /bin/install
#CC       = gcc
#CFLAGS   = -c
#COPTIONS = -O
#DEFINES  = -DSUN -DUTMP_FILE=\"/etc/utmp\" -DWTMP_FILE=\"/var/adm/wtmp\"
#INCLUDES = -I/usr/openwin/include -I/usr/dt/include
#LDFLAGS  =
#XLDFLAGS = -L/usr/openwin/lib -L/usr/dt/lib -lXm -lXt -lXext -lX11 \
#           -R /usr/openwin/lib -R /usr/dt/lib

# -------------------------------------------------------------------- HPUX 9.0

#INSTALL  = /usr/local/bin/install
#CC       = cc
#CFLAGS   = -c
#COPTIONS = -Aa -O
#DEFINES  = -DSYSV -DHPUX -D_HPUX_SOURCE
#INCLUDES = -I/usr/include/X11R5 -I/usr/include/Motif1.2
#LDFLAGS  =
#XLDFLAGS = -L/usr/lib/X11R5 -L/usr/lib/Motif1.2 -lXm -lXt -lXext -lX11

# ------------------------------------------------------------------- AIX 4.1.4

#INSTALL  = installbsd
#CC       = cc
#CFLAGS   = -c
#COPTIONS = -O
#DEFINES  = -DAIX -DSYSV
#INCLUDES =
#LDFLAGS  =
#XLDFLAGS = -lXm -lXt -lXext -lX11

# ----------------------------------------------------------------------- Linux

INSTALL  = /usr/bin/install
CC       = gcc
CFLAGS   = -c
COPTIONS = -g -O2
DEFINES  = -DSYSV
INCLUDES = -I/usr/X11R6/include -I/usr/local/include
LDFLAGS  = -lnsl
XLDFLAGS = -L/usr/X11R6/lib -L/usr/local/lib -lXm -lXt -lXext -lX11

# --------------------------------------------------------------- general stuff
# There should be no need to change anything below this line
# -----------------------------------------------------------------------------

XSRC = connect.c parse.c strutils.c net.c xhost.c xlogin.c
XOBJ = connect.o parse.o strutils.o net.o xhost.o xlogin.o

RSRC = net.c strutils.c xdisplay.c
ROBJ = net.o strutils.o xdisplay.o

all: xLogin xDisplay

xLogin: $(XOBJ)
	$(CC) -o xLogin $(XOBJ) $(XLDFLAGS) $(LDFLAGS)

$(XOBJ): xLogin.xbm

xDisplay: $(ROBJ)
	$(CC) -o xDisplay $(ROBJ) $(XLDFLAGS) $(LDFLAGS)

.c.o: $(XSRC)
	$(CC) $(CFLAGS) $(COPTIONS) $(DEFINES) $(INCLUDES) $<

connect.o: xlogin.h parse.h xhost.h
net.o: xlogin.h
parse.o: xlogin.h
xhost.o: xlogin.h
xlogin.o: xlogin.h parse.h net.h xhost.h connect.h help.h xLogin.xbm
xdisplay.o: net.h strutils.h

install: xLogin xDisplay xLogin.xbm xLogin.xpm xLogin.1 xDisplay.1
	$(INSTALL) -s -m 755 xLogin $(BINDIR)
	$(INSTALL) -s -m 755 xDisplay $(BINDIR)
	$(INSTALL)    -m 644 xLogin.xbm $(PIXMAPDIR)
	$(INSTALL)    -m 644 xLogin.xpm $(PIXMAPDIR)
	$(INSTALL)    -m 644 xLogin.1 $(MANDIR)
	$(INSTALL)    -m 644 xDisplay.1 $(MANDIR)
	$(INSTALL)    -m 644 xLogin.ad $(XAPPDEFAULTS)/xLogin

deinstall:
	rm -f $(BINDIR)/xLogin \
	      $(BINDIR)/xDisplay \
	      $(PIXMAPDIR)/xLogin.xbm \
	      $(PIXMAPDIR)/xLogin.xpm \
	      $(MANDIR)/xLogin.1 \
	      $(MANDIR)/xDisplay.1 \
	      $(XAPPDEFAULTS)/xLogin

clean:
	rm -f $(XOBJ) $(ROBJ) xLogin xDisplay core
