
SHELL=	/bin/sh
prefix=	@prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
mandir = @mandir@
incdir = @includedir@
libdir = @libdir@
srcdir = @srcdir@
sharedlibdir = $(libdir)/shared
LD=$(CC)

INCLUDES=	-I. -I$(srcdir) -I$(incdir)
DEFS=		@DEFS@

COMPILEC=	$(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(VERSNO)
LINK=		$(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@

all:	progs	libs

install:	all
	-mkdir -p $(bindir)
	-mkdir -p $(libdir)
	-mkdir -p $(incdir)
	cp bmeps  $(bindir)/bmeps
	chmod 755 $(bindir)/bmeps
	cp libbmeps.a $(libdir)/libbmeps.a
	chmod 755 $(libdir)/libbmeps.a
	cp bmeps.h $(incdir)/bmeps.h
	chmod 644 $(incdir)/bmeps.h
	cp pngeps.h $(incdir)/pngeps.h
	chmod 644 $(incdir)/pngeps.h
	mkdir -p lib/docu/bmeps
	cp DOCU/*.pdf lib/docu/bmeps
	find lib -type d -exec chmod 755 {} \;
	find lib -type f -exec chmod 644 {} \;
	(cd lib; tar cf - ./*) | (cd $(libdir) ; tar xvf -)
	[ ! -d $(mandir)/man1 ] && mkdir -p $(mandir)/man1 && chmod 755 $(mandir)/man1
	cp bmeps.1 $(mandir)/man1/bmeps.1
	chmod 644 $(mandir)/man1/bmeps.1
	@echo Documentation resides in $(libdir)/lib/docu/bmeps.

progs:	bmeps 

IMGOBJECTS=	pngeps.o jpgeps.o pnmeps.o # tifeps.o - maybe in June 2003
LIBOBJECTS=	bmeps.o $(IMGOBJECTS) bmepsoe.o

OBJECTS=	bmepsm.o	$(LIBOBJECTS)

IMGLIBS= @LIBPNM@ @LIBJPG@ @LIBPNG@ # @LIBTIFF@ - maybe in June 2003
LIBS=	$(IMGLIBS) @ZLIB@ -lm

bmeps:	$(OBJECTS)
	$(LD)	$(LDFLAGS)	-o bmeps	$(OBJECTS)	$(LIBS)
	chmod	755		bmeps

libs:	libbmeps.a

libbmeps.a:	$(LIBOBJECTS)
	-rm	libbmeps.a
	ar	-r	libbmeps.a	$(LIBOBJECTS)
	chmod	755	libbmeps.a


.SUFFIXES:
.SUFFIXES:	.c	.o

.c.o:
	$(COMPILEC) -c $< -o $@

VERSNO=-DVERSNUMB=\"1.0.7a\"
