#
# Makefile for LUG
#
# (c) 1992, Raul Rivero
#
# Makefile for the LUG Library     -->     SGI version
#
#
#    ********************************************************
#    *                                                      *
#    *  Check include/lugconfig.h for internal defines !!!  *
#    *                                                      *
#    ********************************************************
#

###                                                                         ###
#                                                                             #
# Thank you for the ideas and additional configurations to the people at lune #
#                                                                             #
###                                                                         ###


# Shell
SHELL = /bin/sh

#
# Directories of LUG package.
#
DIRS = convert lib show utils

#
# Uncomment next line if you are using other compiler (e.g. gcc)
#
CC = cc

#
# Compiler options ( only C-O-M-P-I-L-E-R, not LUG options ).
#
COPTS = +z +O3 -Aa -D_INCLUDE_POSIX_SOURCE -D_INCLUDE_XOPEN_SOURCE

#
# Location of LUG header files.
#
LUGINC = -I../include 
LUGLIB = -L.. -llug

#
# Where lug library will live
#
LIBLUGDEST =  /usr/local/lib

#
# If you have installed the Utah Raster Toolkit library define
# next variables, example:
#
#       URTINC = -I/usr/local/include/urt
#       URTLIB = -L/usr/local/lib -lrle
#       URTDEF = -DiRLE
#
# , or leave undefined if you don't have it.
#
URTINC = -I/usr/local/include/urt
URTLIB = -L/usr/local/lib -lrle
URTDEF = -DiRLE

#
# If you have installed the Sam Leffler's TIFF library define
# next variables, example:
#
#       TIFFINC = -I/usr/local/include/tiff
#       TIFFLIB = -L/usr/local/lib -ltiff
#       TIFFDEF = -DiTIFF
#
# , or leave undefined if you don't have it.
#
TIFFINC = -I/usr/local/include/tiff
TIFFLIB = -L/usr/local/lib -ltiff
TIFFDEF = -DiTIFF

#
# If you have installed the JPEG library define
# next variables, example:
#
#       JPEGINC = -I/usr/local/include/jpeg
#       JPEGLIB = -L/usr/local/lib -ljpeg
#       JPEGDEF = -DiJPEG
#
# , but if you already has installed the new (5.*) IJL library
# change the last on with:
#
#       JPEGDEF = -DiJPEGNEW
#
# , or leave undefined if you don't have it.
#
JPEGINC = -I/usr/local/include/jpeg
JPEGLIB = -L/usr/local/lib -ljpeg
JPEGDEF = -DiJPEGNEW

#
# If your machine is a SGI computer define next variables, ... ok,
# ok, an example:
#
#       SGIINC = -I/usr/include/gl
#       SGILIB = -limage
#       SGIDEF = -DiSGI
#
# , else leave undefined.
#
SGIINC =
SGILIB =
SGIDEF =

#
# Define what kind of viwer you'll support. Options are:
#
#       Machine                  Add
#       -------                  ---
#       hp9000                  -DiHP
#       sgi/aix                 -DiGL
#       pc                      -DiPC
#       x11                     -DiX11
#       vfr ( sgi )             -DiVFR   <-- SGI's Video Framer needs hardware
#       linux			-DiLINUX
#
# Probably, also you'll need give a path to the headers.
#
# And example: we have a SGI with X11 and a Video FRamer, so
# we define...
#
#       VIEWDEF = -DiGL -DiVFR
#       VIEWLIB = -lgl_s -lvfr
#       VIEWINC = -I/usr/include/gl -I/usr/video/vfr/src/inc
#
VIEWINC = -I/usr/include/X11R5 
VIEWLIB = -L/usr/lib/X11R5 -lX11 
VIEWDEF = -DiX11 

#
# Final includes ( don't touch this ! ).
#
INCS = $(LUGINC) $(URTINC)  $(TIFFINC) $(JPEGINC) $(SGIINC)  $(VIEWINC) 
LIBS = $(LUGLIB) $(URTLIB)  $(TIFFLIB) $(JPEGLIB) $(VIEWLIB) -lm
DEFS =           $(URTDEF)  $(TIFFDEF) $(JPEGDEF) $(SGIDEF)  $(VIEWDEF) 

#
# Library objects.
#
OBJS =  convert/cnv.o           convert/encodgif.o      convert/gif.o   \
        convert/heightfield.o   convert/jpeg.o          convert/pbm.o   \
        convert/pcx.o           convert/pix.o           convert/ps.o    \
        convert/raw.o           convert/rgb.o           convert/rla.o   \
        convert/rle.o           convert/sgi.o           convert/tga.o   \
        convert/tiff.o          lib/bitmap.o            lib/error.o     \
        lib/general.o           lib/in_out.o            lib/memory.o    \
        show/hp.o               show/pc.o               show/sgi.o      \
        show/vfr.o              show/x11.o              utils/blur.o    \
        utils/change.o          utils/chroma.o          utils/cut.o     \
        utils/dither.o          utils/flip.o            utils/gamma.o   \
        utils/histoequal.o      utils/hsl.o             utils/mask.o    \
        utils/medianfilter.o    utils/mirror.o          utils/paste.o   \
        utils/quantize.o        utils/rotate.o          utils/sharpen.o \
        utils/slowzoom.o        utils/solid.o           utils/to24.o    \
        utils/tobw.o            utils/tohalftone.o      utils/toinverse.o \
        utils/zoom.o 		utils/convolve.o	show/linux.o
 
all:	        liblug.a liblug.sl example 


clean:;		rm -f $(OBJS) liblug.a 
		( cd examples; $(MAKE) clean )

install:        liblug.a liblug.sl 
		@echo "Installing library..."
		@if [ ! -d $(LIBLUGDEST) ]; \
		then \
			mkdir $(LIBLUGDEST); \
			chmod 755 $(LIBLUGDEST); \
		fi; \
		cp liblug.a $(LIBLUGDEST); \
		chmod 644 $(LIBLUGDEST)/liblug.a; \
		cp liblug.sl $(LIBLUGDEST); \
		chmod 755 $(LIBLUGDEST)/liblug.sl
		@echo "OK."

archive:;	( cd .. ; tar cvf lug-1.0.tar lug ; compress lug-1.0.tar )

liblug.a:;	@for i in $(DIRS); do \
			( cd $$i ; make "INCS=$(INCS)" "DEFS=$(DEFS)" "CC=$(CC)" "COPTS=$(COPTS)" ) ; \
		done;
		ar scr liblug.a $(OBJS)
###             ranlib liblug.a

liblug.sl:	liblug.a
		ld -s -b -o liblug.sl $(OBJS)

example: 	liblug.a
		( cd examples; make "INCS=$(LUGINC)" "LIBS=$(LIBS)" "CC=$(CC)" "COPTS=$(COPTS)" )

