SRCDIR = ../..
BUILDDIR = $(SRCDIR)
include $(BUILDDIR)/Makefile.config

LIBOPT = $(BUILDDIR)/libopt

PPMDIR = $(BUILDDIR)/ppm
LIBPPM = libppm.$(NETPBMLIBSUFFIX)

PGMDIR = $(BUILDDIR)/pgm
LIBPGM = libpgm.$(NETPBMLIBSUFFIX)

PBMDIR = $(BUILDDIR)/pbm
LIBPBM = libpbm.$(NETPBMLIBSUFFIX)

NETPBMLIBS = $(PPMDIR)/$(LIBPPM) $(PGMDIR)/$(LIBPGM) $(PBMDIR)/$(LIBPBM) 

INCLUDE = -I$(SRCDIR)/shhopt

all: hpcdtoppm

merge: hpcdtoppm

OBJ=	main.o output.o color.o format.o tools.o error.o \
	ppm.o postscr.o const.o

hpcdtoppm: $(OBJ) $(NETPBMLIBS) $(LIBOPT)
	$(LD) $(LDFLAGS) -o hpcdtoppm $(OBJ) `$(LIBOPT) $(NETPBMLIBS)`

HEADERLINKS = pm_config.h pm.h pbm.h pgm.h ppm.h

%.o: %.c $(HEADERLINKS)
	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@

.PHONY: install.bin
install.bin: install.bin.common

.PHONY: install.man
install.man: install.man.common

# And libraries.
$(PBMDIR)/$(LIBPBM): FORCE
	cd $(PBMDIR) ; $(MAKE) $(LIBPBM)
$(PGMDIR)/$(LIBPGM): FORCE
	cd $(PGMDIR) ; $(MAKE) $(LIBPGM)
$(PPMDIR)/$(LIBPPM): FORCE
	cd $(PPMDIR) ; $(MAKE) $(LIBPPM)

BINARIES = hpcdtoppm
SCRIPTS = pcdindex
MANUALS1 = hpcdtoppm pcdindex

include $(SRCDIR)/Makefile.common

clean: clean.common

FORCE:
