#  Generic makefile for display, animate, montage, and import for
#  computers that do not have xmkmf.
#
#  Copyright 1994 E. I. du Pont de Nemours and Company
#
#  Permission to use, copy, modify, distribute, and sell this software and
#  its documentation for any purpose is hereby granted without fee,
#  provided that the above Copyright notice appear in all copies and that
#  both that Copyright notice and this permission notice appear in
#  supporting documentation, and that the name of E. I. du Pont de Nemours
#  and Company not be used in advertising or publicity pertaining to
#  distribution of the software without specific, written prior
#  permission.  E. I. du Pont de Nemours and Company makes no representations
#  about the suitability of this software for any purpose.  It is provided
#  "as is" without express or implied warranty.
#
#  E. I. du Pont de Nemours and Company disclaims all warranties with regard
#  to this software, including all implied warranties of merchantability
#  and fitness, in no event shall E. I. du Pont de Nemours and Company be
#  liable for any special, indirect or consequential damages or any
#  damages whatsoever resulting from loss of use, data or profits, whether
#  in an action of contract, negligence or other tortious action, arising
#  out of or in connection with the use or performance of this software.
#

# If your system does not have /usr/include/dirent.h, define NoDIRENT.
#
#DIRENT_DEFINES= -DNoDIRENT

#
# Uncomment the following lines if you have the JPEG, TIFF, or XPM  libraries.
# See README for more details.
#
#JPEG_DEFINES= -DHasJPEG
#JPEG_INCLUDES= -I../jpeg
#JPEG_LIBRARIES= -Ljpeg -ljpeg
#MPEG_DEFINES= -DHasMPEG
#MPEG_INCLUDES= -I../mpeg
#MPEG_LIBRARIES= -Lmpeg -lmpeg
#TIFF_DEFINES= -DHasTIFF
#TIFF_DEFINES= -DHasTIFF
#TIFF_INCLUDES= -I../tiff
#TIFF_LIBRARIES= -Ltiff -ltiff
#XPM_DEFINES= -DHasXPM
#XPM_INCLUDES= -I../xpm
#XPM_LIBRARIES= -Lxpm -lXpm

MAGICK_INCLUDES= -Imagick

CC = @CC@
DEFS = @DEFS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LDFLAGS =
LIBS = @LIBS@
X_INCLUDES = @X_CFLAGS@
X_LIBRARIES = @X_LIBS@ @X_EXTRA_LIBS@ -lX11

LOCALDIR= /usr/local/bin
LOCALMAN= /usr/local/man/mann

DEFINES= $(MAGICK_INCLUDES) $(DIRENT_DEFINES) $(JPEG_DEFINES) $(JPEG_INCLUDES)\
  $(MPEG_DEFINES) $(MPEG_INCLUDES) $(TIFF_DEFINES) $(TIFF_INCLUDES) \
  $(XPM_DEFINES) $(XPM_INCLUDES) $(X_INCLUDES)
SYS_LIBRARIES= $(JPEG_LIBRARIES) $(MPEG_LIBRARIES) $(TIFF_LIBRARIES) \
  $(XPM_LIBRARIES) $(X_LIBRARIES) $(LIBS)

DisplayObjects= display.o
ImportObjects= import.o
MontageObjects= montage.o
AnimateObjects= animate.o
ConvertObjects= convert.o
IdentifyObjects= identify.o
MogrifyObjects= mogrify.o
CombineObjects= combine.o
SegmentObjects= segment.o

PROGRAMS= display import montage animate convert mogrify identify combine \
  segment

CFLAGS= -O $(DEFINES)

all: libmagick.a $(PROGRAMS)

libmagick.a: 
	(cd magick; make CFLAGS="$(CFLAGS)")

display: $(DisplayObjects)
	rm -f $@
	$(CC) -o $@ $(DisplayObjects) magick/libMagick.a $(SYS_LIBRARIES)


import: $(ImportObjects)
	rm -f $@
	$(CC) -o $@ $(ImportObjects) magick/libMagick.a $(SYS_LIBRARIES)

montage: $(MontageObjects)
	rm -f $@
	$(CC) -o $@ $(MontageObjects) magick/libMagick.a $(SYS_LIBRARIES)

animate: $(AnimateObjects)
	rm -f $@
	$(CC) -o $@ $(AnimateObjects) magick/libMagick.a $(SYS_LIBRARIES)

convert: $(ConvertObjects)
	rm -f $@
	$(CC) -o $@ $(ConvertObjects) magick/libMagick.a $(SYS_LIBRARIES)

identify: $(IdentifyObjects)
	rm -f $@
	$(CC) -o $@ $(IdentifyObjects) magick/libMagick.a $(SYS_LIBRARIES)

mogrify: $(MogrifyObjects)
	rm -f $@
	$(CC) -o $@ $(MogrifyObjects) magick/libMagick.a $(SYS_LIBRARIES)

combine: $(CombineObjects)
	rm -f $@
	$(CC) -o $@ $(CombineObjects) magick/libMagick.a $(SYS_LIBRARIES)


segment: $(SegmentObjects)
	rm -f $@
	$(CC) -o $@ $(SegmentObjects) magick/libMagick.a $(SYS_LIBRARIES)

install: display import montage animate convert mogrify combine segment
	$(INSTALL_PROGRAM) display $(LOCALDIR)/display
	$(INSTALL_DATA) display.man $(LOCALMAN)/display.n
	$(INSTALL_PROGRAM) import $(LOCALDIR)/import
	$(INSTALL_DATA) import.man $(LOCALMAN)/import.n
	$(INSTALL_PROGRAM) montage $(LOCALDIR)/montage
	$(INSTALL_DATA) montage.man $(LOCALMAN)/montage.n
	$(INSTALL_PROGRAM) animate $(LOCALDIR)/animate
	$(INSTALL_DATA) animate.man $(LOCALMAN)/animate.n
	$(INSTALL_PROGRAM) convert $(LOCALDIR)/convert
	$(INSTALL_DATA) convert.man $(LOCALMAN)/convert.n
	$(INSTALL_PROGRAM) identify $(LOCALDIR)/identify
	$(INSTALL_DATA) identify.man $(LOCALMAN)/identify.n
	$(INSTALL_PROGRAM) mogrify $(LOCALDIR)/mogrify
	$(INSTALL_DATA) mogrify.man $(LOCALMAN)/mogrify.n
	$(INSTALL_PROGRAM) combine $(LOCALDIR)/combine
	$(INSTALL_DATA) combine.man $(LOCALMAN)/combine.n
	$(INSTALL_PROGRAM) segment $(LOCALDIR)/segment
	$(INSTALL_DATA) segment.man $(LOCALMAN)/segment.n

clean::
	(cd magick; make clean)
	rm -f *.ln *.bak *.o core errs ,* *~ *.a .emacs_* make.log MakeOut
	rm -f display
	rm -f import
	rm -f montage
	rm -f animate
	rm -f convert
	rm -f mogrify
	rm -f combine
	rm -f segment

display.o: display.c magick/magick.h magick/image.h magick/utility.h magick/X.h magick/widget.h
import.o: import.c magick/magick.h magick/image.h magick/X.h
montage.o: montage.c magick/magick.h magick/image.h magick/X.h magick/compress.h
animate.o: animate.c magick/magick.h magick/image.h magick/compress.h magick/X.h magick/widget.h
convert.o: convert.c magick/magick.h magick/image.h magick/X.h
mogrify.o: mogrify.c magick/magick.h magick/image.h magick/X.h
combine.o: combine.c magick/magick.h magick/image.h magick/X.h
segment.o: segment.c magick/magick.h magick/image.h magick/X.h