# Makefile for pnmtopng/pngtopnm for gcc 2.7 or later (Linux, Solaris, etc.)
# Copyright (C) 1995-1998 Willem van Schaik

CC = gcc
CP = cp
RM = rm

# change to match your directories
#
# it is suggested that you place things like libpng and zlib in 
# version-specific directories like ../zlib-1.0 and that you make a 
# symbolic link like "ln -s zlib-1.0 zlib" in the .. directory 
#
# if the libraries and header files are already installed in /usr/lib and 
# /usr/include, just set the "INC" and "LIB" variables to empty strings and
# set the "LIB2" variables to /usr/lib/lib<whatever>.a

#PNGDIR = ../libgr2/png
PNGDIR = ../libpng
PNGINC = -I$(PNGDIR)
PNGLIB = -L$(PNGDIR) -lpng
PNGLIB2 = $(PNGDIR)/libpng.a

#PNGDIR = ../libgr2/zlib
ZDIR = ../zlib
ZINC = -I$(ZDIR)
ZLIB = -L$(ZDIR) -lz
ZLIB2 = $(ZDIR)/libz.a

#PBMDIR = /usr/local/netpbm
#PBMDIR = ../libgr2
PBMDIR = ../netpbm
PBMINC = -I$(PBMDIR)/pnm -I$(PBMDIR)/ppm -I$(PBMDIR)/pgm -I$(PBMDIR)/pbm
PBMLIB = -L$(PBMDIR)/pnm -L$(PBMDIR)/ppm -L$(PBMDIR)/pgm -L$(PBMDIR)/pbm \
	 -lpnm -lppm -lpgm -lpbm
PBMLIB2 = $(PBMDIR)/pnm/libpnm.a $(PBMDIR)/ppm/libppm.a \
	  $(PBMDIR)/pgm/libpgm.a $(PBMDIR)/pbm/libpbm.a

## # GRR 19991205:  use this section instead for the new/coming pbmplus release
## PBMDIR = ../pbmplus-19991128
## PBMINC = -I$(PBMDIR)/inc
## PBMLIB = -L$(PBMDIR)/libpnm -lpnm
## PBMLIB2 = $(PBMDIR)/libpnm/libpnm.a


# where "make install" puts pnmtopng and pngtopnm

#INSTDIR = $(PBMDIR)/pnm
INSTDIR = /usr/local


CFLAGS = -O3 -Wall -D_BSD_SOURCE $(PNGINC) $(ZINC) $(PBMINC)
LDFLAGS = $(PNGLIB) $(ZLIB) $(PBMLIB) -lm
LDFLAGS2 = $(PNGLIB2) $(ZLIB2) $(PBMLIB2) -lm

MANS = pnmtopng.1 pngtopnm.1
SRCS = pnmtopng.c pngtopnm.c
OBJS = pnmtopng.o pngtopnm.o
EXES = pnmtopng pngtopnm pnmtopng-static pngtopnm-static


# dependency rules

all: $(EXES)

pnmtopng.o:	pnmtopng.c version.h
pngtopnm.o:	pngtopnm.c version.h

pnmtopng: pnmtopng.o
	$(CC) -o $@ pnmtopng.o $(LDFLAGS)

pngtopnm: pngtopnm.o
	$(CC) -o $@ pngtopnm.o $(LDFLAGS)

pnmtopng-static: pnmtopng.o
	$(CC) -o $@ pnmtopng.o $(LDFLAGS2)

pngtopnm-static: pngtopnm.o
	$(CC) -o $@ pngtopnm.o $(LDFLAGS2)

install: all
	$(CP) $(EXES) $(INSTDIR)/bin
	$(CP) $(MANS) $(INSTDIR)/man/man1

clean:
	$(RM) -f $(OBJS) $(EXES)


# end of Makefile.gcc
