# Makefile for pbmplus tools.
#
# Copyright (C) 1989, 1991 by Jef Poskanzer.
# Modified by Robert A. Knop Jr. (rknop@cco.caltech.edu) 940126 for 
#       Amiga SAS/C 6.0 or greater (tested with 6.50)
#    Merge is not currently supported by this makefile
#    LibTIFF is not currently supported by this makefile (perhaps soon...)
#    RKNOP has also created "SMakefile"s in each of {pbm/ pgm/ ppm/ pnm/}
#       which were similarly based on the Unix Makefile#
#    The shell utility "foreach" (should have been included in the archive with)
#       this SMakefile) is necessary for the SMakefiles to work.
#    Feel free to experiment with SCOPTIONS, although these have been tweaked
#       at great length to get netpbm to compile.  It is probably wise to have
#       the SCOPTIONS files in the four subdirectories identical to the one
#       in the top netpbm source directory.    
#    All changes pertinent to SAS/C 6.x are labeled by the word "RKNOP"
#
# 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.

# CONFIGURE: gcc makes things go faster on some machines, but not everyone
# has it.  Warning: do not use gcc's -finline-functions or -fstrength-reduce
# flags, they can produce incorrect code.  (This is with gcc versions 1.35,
# 1.36, and 1.37, later versions may fix these bugs.)  Also, on some systems
# gcc can't compile pnmconvol - dunno why.  And on some systems you can't
# use the -ansi flag, it gives compilation errors in <math.h>.
# For the Amiga, the makefiles will die severely if you don't use SAS/C 6.x
#CC =		cc
#CC =		gcc
CC =		sc
#CC =		gcc -fcombine-regs -fpcc-struct-return
#CC =		gcc -ansi -pedantic -fcombine-regs -fpcc-struct-return

# CONFIGURE: cc flags go here.
# On some systems, e.g a sun386i, there is no strstr function. If this
# is the case on your system, set the -DNEED_STRSTR flag.
#CFLAGS =	-O
#CFLAGS =	-O -DNEED_STRSTR
#CFLAGS =	-g
#CFLAGS =	-g -O
CFLAGS =

MFLAGS =

# CONFIGURE: ld flags go here.  Eunice users may want to use -noshare so that
# the binaries can run standalone.
LDFLAGS
#LDFLAGS =	-s
#LDFLAGS =	
#LDFLAGS =	-noshare

# CONFIGURE: PBMPLUS's support for TIFF files depends on the library from
# Sam Leffler's TIFF Software package - see the OTHER.SYSTEMS file for a
# full description and access information.  To configure PBMPLUS to use the
# library: first, if necessary, fetch the TIFF Software, unpack it in a
# scratch directory somewhere, and move the libtiff subdirectory right here
# into the PBMPLUS top-level directory.  Configure and "make" in the
# libtiff directory.  Yes, you do have to do the TIFF make by hand, the
# general PBMPLUS make will *not* make libtiff.  Finally, uncomment the
# following five definitions.
#
# Libtiff is pretty good about portability, but there are some machines
# it has problems on.  If you run into problems, you may wish to contact
# Sam directly, at the address listed in the OTHER.SYSTEMS file.
#
# By the way, you must have at least version 2.4 of libtiff.  Earlier
# versions will not work.
#
# RKNOP: The SAS/C version does not yet have a converted libtiff SMakefile
TIFFDEF =
TIFFINC =
TIFFLIB =
TIFFBINARIES =
TIFFOBJECTS =
#TIFFDEF =	-DLIBTIFF
#TIFFINC =	-I../libtiff
#TIFFLIB =	../libtiff/libtiff.a
#TIFFBINARIES =	tifftopnm pnmtotiff
#TIFFOBJECTS =	tifftopnm.o pnmtotiff.o

# CONFIGURE: Define the directory that you want the binaries copied to.
# If you need scripts and binaries to be in different directories, you
# can set that up too.
#INSTALLBINARIES =	sys:netpbm
INSTALLBINARIES = Laertes:CCode/netpbm-exec
INSTALLSCRIPTS =	$(INSTALLBINARIES)

# CONFIGURE: Define the directories that you want the manual sources copied to,
# plus the suffix you want them to have.
INSTALLMANUALS1 =	sys:netpbm-man/man1
SUFFIXMANUALS1 =	1
INSTALLMANUALS3 =	sys:netpbm-man/man3
SUFFIXMANUALS3 =	3
INSTALLMANUALS5 =	sys:netpbm-man/man5
SUFFIXMANUALS5 =	5

# CONFIGURE: Normally the man pages are installed using "cp".  By changing
# this define you can use something else, for example a script that calls
# compress or pack. The ../mantocat is used on systems which use man pages
# in the "cat" format.
MANCP =			copy
#MANCP =			cp
#MANCP =		../mantocat

# CONFIGURE: Normally the Makefiles build and install separate binaries for
# each program.  However, on some systems (especially those without shared
# libraries) this can mean a lot of space.  In this case you might try
# building a "merge" instead.  The idea here is to link all the binaries
# together into one huge executable, with a tiny dispatch program as the
# main.  Then the merged binary is installed with file-system links for
# each program it includes.  The dispatch routine can tell which program
# to run by looking at argv[0].  On a Sun3 under SunOS 3.5 the space for
# executables went from 2.9 meg to .36 meg.
#
# Note that if you make a "merge", the executables don't get created
# until you do the install.
# RKNOP: Merge is not supported for Amiga SAS/C
all:		binaries
install:	install.bin install.man
#all:		merge
#install:	install.merge install.man

# End of configurable definitions.

SHELL =		/bin/sh
#MAKE =		make
MAKE =		smake
SUBDIRS =	pbm pgm ppm pnm

binaries:
	execute stamp-date.amiga
        execute < <(T:main_smake.tmp)
	foreach im in $(SUBDIRS)
		echo $${im}
		cd $${im}
		$(MAKE) $(MFLAGS) CC=$(CC) CFLAGS=$(CFLAGS) TIFFDEF=$(TIFFDEF) TIFFINC=$(TIFFINC) TIFFLIB=$(TIFFLIB) TIFFBINARIES=$(TIFFBINARIES) TIFFOBJECTS=$(TIFFOBJECTS) LDFLAGS=$(LDFLAGS) binaries
	end
	<

# RKNOP 940126
# "smake nostamp" will do the same as "smake" or "smake binaries", only
# stamp-date.amiga will NOT be run.  This is convenient if you are
# experimenting and a build tends to die halfway through... the samkefile can
# continue to use the old compile.h (which normally stamp-date creates) and
# whatever objects files previous passes at the compilation have left behind
nostamp:
        execute < <(T:main_smake.tmp)
	foreach im in $(SUBDIRS)
		echo $${im}
		cd $${im}
		$(MAKE) $(MFLAGS) CC=$(CC) CFLAGS=$(CFLAGS) TIFFDEF=$(TIFFDEF) TIFFINC=$(TIFFINC) TIFFLIB=$(TIFFLIB) TIFFBINARIES=$(TIFFBINARIES) TIFFOBJECTS=$(TIFFOBJECTS) LDFLAGS=$(LDFLAGS) binaries
	end
	<

#merge:
#	./stamp-date
#	for i in $(SUBDIRS) ; do \
#	    ( echo $$i ; cd $$i ; $(MAKE) $(MFLAGS) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'TIFFDEF=$(TIFFDEF)' 'TIFFINC=$(TIFFINC)' 'TIFFLIB=$(TIFFLIB)' 'TIFFBINARIES=$(TIFFBINARIES)' 'TIFFOBJECTS=$(TIFFOBJECTS)' 'LDFLAGS=$(LDFLAGS)' merge ); \
#	done

install.bin:
        -makedir $(INSTALLBINARIES)
        execute < <(T:main_smake.tmp)
	foreach im in $(SUBDIRS)
		echo $${im}
		cd $${im}
		$(MAKE) $(MFLAGS) CC=$(CC) CFLAGS=$(CFLAGS) TIFFDEF=$(TIFFDEF) TIFFINC=$(TIFFINC) TIFFLIB=$(TIFFLIB) TIFFBINARIES=$(TIFFBINARIES) TIFFOBJECTS=$(TIFFOBJECTS) LDFLAGS=$(LDFLAGS) INSTALLBINARIES=$(INSTALLBINARIES) INSTALLSCRIPTS=$(INSTALLSCRIPTS) install.bin
	end
        <

#install.merge:
#       -mkdir $(INSTALLBINARIES)
#	for i in $(SUBDIRS) ; do \
#	    ( echo $$i ; cd $$i ; $(MAKE) $(MFLAGS) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'TIFFDEF=$(TIFFDEF)' 'TIFFINC=$(TIFFINC)' 'TIFFLIB=$(TIFFLIB)' 'TIFFBINARIES=$(TIFFBINARIES)' 'TIFFOBJECTS=$(TIFFOBJECTS)' 'LDFLAGS=$(LDFLAGS)' 'INSTALLBINARIES=$(INSTALLBINARIES)' 'INSTALLSCRIPTS=$(INSTALLSCRIPTS)' install.merge ); \
#	done

install.man:
        execute < <(T:main_smake.tmp)
	foreach im in $(SUBDIRS)
	   echo $${im}
	   cd $${im}
	   $(MAKE) $(MFLAGS) TIFFBINARIES=$(TIFFBINARIES) INSTALLMANUALS1=$(INSTALLMANUALS1) SUFFIXMANUALS1=$(SUFFIXMANUALS1) INSTALLMANUALS3=$(INSTALLMANUALS3) SUFFIXMANUALS3=$(SUFFIXMANUALS3) INSTALLMANUALS5=$(INSTALLMANUALS5) SUFFIXMANUALS5=$(SUFFIXMANUALS5) MANCP=$(MANCP) install.man
	end
        <

clean:
	-delete *.shar *.shar? art.* compile.h
#libtiff removed from the foreach below for the time being
        execute < <(T:main_smake.tmp)
	foreach im in $(SUBDIRS)
	   echo $${im}
	   cd $${im}
	   $(MAKE) $(MFLAGS) clean
	end
	<
