ifeq ($(SRCDIR)x,x)
  SRCDIR = $(CURDIR)/..
  BUILDDIR = $(SRCDIR)
endif
SUBDIR = editor
VPATH=.:$(SRCDIR)/$(SUBDIR)

include $(BUILDDIR)/Makefile.config

# We tend to separate out the build targets so that we don't have
# any more dependencies for a given target than it really needs.
# That way, if there is a problem with a dependency, we can still
# successfully build all the stuff that doesn't depend upon it.
# This package is so big, it's useful even when some parts won't 
# build.

PORTBINARIES = pamcut pamdeinterlace pamdice \
	       pamflip pamfunc pamoil pampop9 pamstretch \
	       pbmclean pbmlife pbmmask pbmpscale pbmreduce \
	       pgmbentley pgmenhance pgmmorphconv \
	       pnmalias pnmcat pnmcomp pnmconvol pnmcrop pnmcut pnmenlarge \
	       pnmhisteq pnminvert pnmmontage pnmnorm pnmpad pnmpaste \
	       pnmremap pnmsmooth pnmtile \
	       ppm3d ppmbrighten ppmchange ppmcolormask \
	       ppmdim ppmdist ppmdither ppmflash ppmmix \
	       ppmquant ppmrelief ppmshift ppmspread ppmtv
MATHBINARIES = pgmabel pamedge \
	       pnmgamma pnmnlfilt pnmrotate pnmscale pnmscalefixed \
	       pnmshear pnmstitch ppmglobe ppmlabel ppmntsc 

# We don't include programs that have special library dependencies in the
# merge scheme, because we don't want those dependencies to prevent us
# from building all the other programs.

NOMERGEBINARIES = 
MERGEBINARIES = $(PORTBINARIES) $(MATHBINARIES)


BINARIES = $(MERGEBINARIES) $(NOMERGEBINARIES)
SCRIPTS = pnmflip ppmfade ppmquantall ppmshadow \
	  pamstretch-gen pnmindex pnmmargin pnmquant 

OBJECTS = $(BINARIES:%=%.o)

MERGE_OBJECTS = $(MERGEBINARIES:%=%.o2)

.PHONY: all
all: $(BINARIES)

HEADERLINKS = pm_config.h pm.h pbm.h pgm.h ppm.h pnm.h pam.h pammap.h \
	shhopt.h nstring.h mallocvar.h colorname.h ppmdraw.h ppmcmap.h


include $(SRCDIR)/Makefile.common

install.bin: install.bin.local

.PHONY: install.bin.local
install.bin.local: $(PKGDIR)/bin
# Remember that $(SYMLINK) might just be a copy command.
# backward compatibility: program used to be named pnmnoraw
# backward compatibility: program used to be pnminterp
	cd $(PKGDIR)/bin ; \
	rm -f pnminterp; \
	$(SYMLINK) pamstretch$(EXE) pnminterp
# pamoil replaced pgmoil in June 2001.
	cd $(PKGDIR)/bin ; \
	rm -f pgmoil ; \
	$(SYMLINK) pamoil$(EXE) pgmoil
# In March 2002, pnmnorm replaced ppmnorm and pgmnorm
	cd $(PKGDIR)/bin ; \
	rm -f ppmnorm ; \
	$(SYMLINK) pnmnorm$(EXE) ppmnorm 
	cd $(PKGDIR)/bin ; \
	rm -f pgmnorm ; \
	$(SYMLINK) pnmnorm$(EXE) pgmnorm
# In March 2003, pamedge replaced pgmedge
	cd $(PKGDIR)/bin ; \
	rm -f pgmedge ; \
	$(SYMLINK) pamedge$(EXE) pgmedge
