# Treat this Makefile like -*- text -*-.
#
# Makefile for the finger library.
#
# Copyright (C) 1988,1990 Free Software Foundation, Inc.
# Copyright (C) 1991 International Computer Science Institute, Berkeley, USA.
#
# This file is part of GNU Finger.
# 
# GNU Finger 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 1, or (at your
# option) any later version.
#
# GNU Finger 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 GNU Finger; see the file COPYING.  If not, write to the
# Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Id: Makefile,v 1.36 1994/10/12 22:30:24 stolcke Exp $ ICSI (Berkeley)
#
SHELL = /bin/sh

#ifndef .PMAKE
.CURDIR = .
#endif

INCLUDES = $(.CURDIR)/../include/
INCFLAGS = -I. -I$(.CURDIR) -I$(INCLUDES)
CFLAGS = -O $(INCFLAGS)
DEPFLAG = -M
SABERFLAGS = -C
RANLIB = ranlib
RM = rm -f
AR = ar

.c.o:
	$(CC) -c $(CFLAGS) $<

ALL_SOURCES = $(CORELIB_SOURCES) $(BITMAP_SOURCES) $(SITE_SOURCES)

CORELIB_SOURCES = error.c os.c packet.c tcp.c tty.c util.c getservhost.c \
		  text-finger.c face-finger.c dither.c call.c mail.c
CORELIB_OBJECTS = error.o os.o packet.o tcp.o tty.o util.o getservhost.o \
		  text-finger.o face-finger.o dither.o call.o mail.o

BM_READERS_SRC = read_bitmap.c read_rastfile.c read_x_bitmap.c read_lispmug.c
BM_WRITERS_SRC = save_bitmap.c save_rastfile.c save_x_bitmap.c save_lispmug.c
BM_SHOWERS_SRC = x_show_face.c sun_show_face.c showface.c
BITMAP_SOURCES = $(BM_READERS_SRC) $(BM_WRITERS_SRC) $(BM_SHOWERS_SRC) bitmap.c

BM_READERS_OBJ = read_bitmap.o read_rastfile.o read_x_bitmap.o read_lispmug.o
BM_WRITERS_OBJ = save_bitmap.o save_rastfile.o save_x_bitmap.o save_lispmug.o
BM_SHOWERS_OBJ = x_show_face.o sun_show_face.o showface.o
BITMAP_OBJECTS = $(BM_READERS_OBJ) $(BM_WRITERS_OBJ) $(BM_SHOWERS_OBJ) bitmap.o

SITE_SOURCES = userface.c userinfo.c
SITE_OBJECTS = userface.o userinfo.o

COMPAT_SOURCES = ualarm.c flock.c getusershell.c authuser.c
COMPAT_OBJECTS = ualarm.o flock.o getusershell.o authuser.o

LIBFINGER_SOURCES = $(CORELIB_SOURCES) $(BITMAP_SOURCES) $(SITE_SOURCES) \
		    $(COMPAT_SOURCES)
LIBFINGER_OBJECTS = $(CORELIB_OBJECTS) $(BITMAP_OBJECTS) $(SITE_OBJECTS) \
		    $(COMPAT_OBJECTS)

all: libfinger.a

libfinger.a: $(LIBFINGER_OBJECTS)
	$(RM) libfinger.a
	$(AR) cr libfinger.a $(LIBFINGER_OBJECTS)
	$(RANLIB) libfinger.a

saber:
	#load $(SABERFLAGS) $(INCFLAGS) $(LIBFINGER_SOURCES)

always:

clean:
	rm -f *.o *.a *.bak any-to-any showxbm showmug mail

dirs:
	test -d $(.CURDIR)/$(MAKEOBJDIR) || mkdir $(.CURDIR)/$(MAKEOBJDIR)

showxbm: read_x_bitmap.c x_show_face.o bitmap.o util.o
	$(CC) -DTEST -g $(INCFLAGS) -o showxbm $(.CURDIR)/read_x_bitmap.c \
		x_show_face.o bitmap.o util.o -lXaw -lXt -lXmu -lXext -lX11 

showmug: read_lispmug.c x_show_face.o bitmap.o util.o
	$(CC) -DTEST -g $(INCFLAGS) -o showmug $(.CURDIR)/read_lispmug.c \
		x_show_face.o bitmap.o util.o -lXaw -lXt -lXmu -lXext -lX11

# The test program for the SMTP interface
mail:	mail.c libfinger.a
	$(CC) -o $@ -DTEST $(CFLAGS) $(.CURDIR)/mail.c libfinger.a

any-to-any.o: any-to-any.c
	$(CC) -g $(INCFLAGS) -c $(.CURDIR)/any-to-any.c

any-to-any: any-to-any.o libfinger.a
	$(CC) -g -o any-to-any any-to-any.o -L. -lfinger -lm

$(COMPAT_SOURCES): $(.CURDIR)/../config.h

tags:	$(LIBFINGER_SOURCES) $(.CURDIR)/$(INCLUDES)*.h $(.CURDIR)/../config.h
	ctags -u $? 
	
DEPSTRING = DO NOT DELETE THIS LINE -- make depend depends on it.

# This is really gross -- we run cc to figure out dependencies,
# then use sed to replace the actual paths with the corresponding make
# macros, to achieve configuration independence.
# There is a chance that the substitutions produce incorrect results,
# e.g., because the path contains a . which can match anything.  But
# in practice the patterns are redundant enough to make this work.
depend:
	(cd $(.CURDIR); /bin/mv Makefile Makefile.bak; \
	/bin/sed -e '/^# $(DEPSTRING)/,$$ d' Makefile.bak > Makefile; \
	echo "# $(DEPSTRING)" >> Makefile ) ; \
	for src in $(ALL_SOURCES); do \
		$(CC) $(DEPFLAG) $(INCFLAGS) $(.CURDIR)/$$src | \
		(cd $(.CURDIR) ; \
	   	 sed -e 's@ \./@ @g' \
		     -e 's@ $(INCLUDES)/@ $$(INCLUDES)/@g' \
		     -e 's@ $(.CURDIR)/@ $$(.CURDIR)/@g' \
		      >> Makefile) ; \
	done 

# DO NOT DELETE THIS LINE -- make depend depends on it.
error.o : $(.CURDIR)/error.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/error.h 
os.o : $(.CURDIR)/os.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/os.h $(INCLUDES)/packet.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/error.h 
packet.o : $(.CURDIR)/packet.c $(INCLUDES)/general.h $(INCLUDES)/util.h $(INCLUDES)/../config.h \
  $(INCLUDES)/../config.h-dist $(INCLUDES)/packet.h $(INCLUDES)/os.h \
  $(INCLUDES)/error.h $(INCLUDES)/tcp.h 
tcp.o : $(.CURDIR)/tcp.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  fingerpaths.h $(INCLUDES)/tcp.h $(INCLUDES)/os.h $(INCLUDES)/packet.h \
  $(INCLUDES)/error.h $(.CURDIR)/authuser.h 
tty.o : $(.CURDIR)/tty.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/os.h $(INCLUDES)/packet.h $(INCLUDES)/error.h fingerpaths.h 
util.o : $(.CURDIR)/util.c $(INCLUDES)/general.h $(INCLUDES)/util.h $(INCLUDES)/../config.h \
  $(INCLUDES)/../config.h-dist $(INCLUDES)/error.h fingerpaths.h 
getservhost.o : $(.CURDIR)/getservhost.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/error.h \
  $(INCLUDES)/getservhost.h 
text-finger.o : $(.CURDIR)/text-finger.c $(INCLUDES)/util.h $(INCLUDES)/../config.h \
  $(INCLUDES)/../config.h-dist 
face-finger.o : $(.CURDIR)/face-finger.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h 
dither.o : $(.CURDIR)/dither.c $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist 
call.o : $(.CURDIR)/call.c $(INCLUDES)/general.h $(INCLUDES)/util.h $(INCLUDES)/../config.h \
  $(INCLUDES)/../config.h-dist $(INCLUDES)/tcp.h $(INCLUDES)/error.h \
  $(INCLUDES)/face-finger.h $(INCLUDES)/bitmap.h $(INCLUDES)/text-finger.h \
  $(INCLUDES)/call.h 
mail.o : $(.CURDIR)/mail.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/tcp.h fingerpaths.h $(INCLUDES)/os.h $(INCLUDES)/packet.h \
  $(INCLUDES)/error.h 
read_bitmap.o : $(.CURDIR)/read_bitmap.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h 
read_rastfile.o : $(.CURDIR)/read_rastfile.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h 
read_x_bitmap.o : $(.CURDIR)/read_x_bitmap.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h 
read_lispmug.o : $(.CURDIR)/read_lispmug.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h 
save_bitmap.o : $(.CURDIR)/save_bitmap.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h \
  $(INCLUDES)/error.h 
save_rastfile.o : $(.CURDIR)/save_rastfile.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h \
  $(INCLUDES)/error.h 
save_x_bitmap.o : $(.CURDIR)/save_x_bitmap.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h \
  $(INCLUDES)/error.h 
save_lispmug.o : $(.CURDIR)/save_lispmug.c $(INCLUDES)/general.h $(INCLUDES)/util.h \
  $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist $(INCLUDES)/bitmap.h \
  $(INCLUDES)/error.h 
x_show_face.o : $(.CURDIR)/x_show_face.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/call.h $(INCLUDES)/bitmap.h $(INCLUDES)/error.h 
sun_show_face.o : $(.CURDIR)/sun_show_face.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/call.h $(INCLUDES)/bitmap.h $(INCLUDES)/error.h 
showface.o : $(.CURDIR)/showface.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/bitmap.h \
  $(INCLUDES)/error.h $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist 
bitmap.o : $(.CURDIR)/bitmap.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/bitmap.h 
userface.o : $(.CURDIR)/userface.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/bitmap.h 
userinfo.o : $(.CURDIR)/userinfo.c $(.CURDIR)/../config.h $(.CURDIR)/../config.h-dist $(INCLUDES)/general.h \
  $(INCLUDES)/util.h $(INCLUDES)/../config.h $(INCLUDES)/../config.h-dist \
  $(INCLUDES)/packet.h $(INCLUDES)/bitmap.h $(INCLUDES)/error.h 
