# Imakefile for pbm tools.
#
# Copyright (C) 1989 by Jef Poskanzer.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation.  This software is provided "as is" without express or
# implied warranty.

ALLCFLAGS =	$(CFLAGS)
LIBPBM =	libpbm.a

PORTBINARIES =	brushtopbm cmuwmtopbm g3topbm icontopbm gemtopbm macptopbm \
		mgrtopbm pbmlife pbmmake pbmmask pbmpaste pbmreduce \
		pbmtoascii pbmtobbnbg pbmtocmuwm pbmtogo pbmtoicon pbmtolj \
		pbmtomacp pbmtomgr pbmtoptx pbmtox10bm pbmtoxbm \
		pbmtoxwd pbmupc pcxtopbm tifftopbm xbmtopbm xwdtopbm
SUNBINARIES =	pbmtorast rasttopbm

PORTMANUALS =	brushtopbm.1 cmuwmtopbm.1 g3topbm.1 icontopbm.1 \
		gemtopbm.1 macptopbm.1 mgrtopbm.1 pbm.5 \
		pbmlife.1 pbmmake.1 pbmmask.1 pbmpaste.1 \
		pbmreduce.1 pbmtoascii.1 pbmtobbnbg.1 pbmtocmuwm.1 pbmtogo.1 \
		pbmtoicon.1 pbmtolj.1 pbmtomacp.1 pbmtomgr.1 \
		pbmtoptx.1 pbmtox10bm.1 pbmtoxbm.1 \
		pbmtoxwd.1 pbmupc.1 pcxtopbm.1 tifftopbm.1 \
		xbmtopbm.1 xwdtopbm.1
SUNMANUALS =	pbmtorast.1 rasttopbm.1

# CONFIGURE: If you are not on a Sun, switch around the commenting here
# to avoid compiling the Sun-specific programs:
BINARIES =	$(PORTBINARIES) $(SUNBINARIES)
# BINARIES =	$(PORTBINARIES)
MANUALS =	$(PORTMANUALS) $(SUNMANUALS)
# MANUALS =	$(PORTMANUALS)

all:		binaries
install:	installbinaries

binaries:	$(BINARIES)

installbinaries:	binaries
	cp $(BINARIES) $(INSTALLBINARIES)

installmanuals:
	cp $(MANUALS) /usr/man/man$(INSTALLMANUALS)

# Rule for plain programs.
$(PORTBINARIES):	pbm.h ../pbmplus.h $(LIBPBM)
	$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPBM)

# Rule for pixrect-dependent programs.
$(SUNBINARIES):	pbm.h ../pbmplus.h $(LIBPBM)
	$(CC) $(ALLCFLAGS) $(LDFLAGS) -o $@ $@.c $(LIBPBM) -lpixrect

# And library.
$(LIBPBM):	libpbm1.o libpbm2.o libpbm3.o libpbm4.o
	-rm $(LIBPBM)
	ar rc $(LIBPBM) libpbm1.o libpbm2.o libpbm3.o libpbm4.o
	-ranlib $(LIBPBM)

libpbm1.o:	pbm.h ../pbmplus.h libpbm.h libpbm1.c
	$(CC) $(ALLCFLAGS) -c libpbm1.c
libpbm2.o:	pbm.h ../pbmplus.h libpbm.h libpbm2.c
	$(CC) $(ALLCFLAGS) -c libpbm2.c
libpbm3.o:	pbm.h ../pbmplus.h libpbm.h libpbm3.c
	$(CC) $(ALLCFLAGS) -c libpbm3.c
libpbm4.o:	pbm.h ../pbmplus.h libpbm.h libpbm4.c
	$(CC) $(ALLCFLAGS) -c libpbm4.c
