# Makefile for Independent JPEG Group's software

# This makefile is suitable for Unix-like systems with ANSI-capable compilers.
# If you have a non-ANSI compiler, makefile.unix is a better starting point.

# Read installation instructions before saying "make" !!

# The name of your C compiler:
CC= cc

# You may need to adjust these cc options:
CFLAGS=
# Generally, we recommend defining any configuration symbols in jconfig.h,
# NOT via -D switches here.

# Link-time cc options:
LDFLAGS= 

# To link any special libraries, add the necessary -l commands here.
LDLIBS= 

# Put here the object file name for the correct system-dependent memory
# manager file.  For Unix this is usually jmemnobs.o, but you may want
# to use o.jmemansi or o.jmemname if you have limited swap space.
SYSDEPMEM= o.jmemansi

# miscellaneous OS-dependent stuff
# linker
LN= $(CC)
# file deletion command
RM= rm -f
# library (.a) file creation command
AR= libfile -co

# End of configurable options.


# source files: JPEG library proper
LIBSOURCES= c.jcapimin c.jcapistd c.jccoefct c.jccolor c.jcdctmgr c.jchuff \
        c.jcinit c.jcmainct c.jcmarker c.jcmaster c.jcomapi c.jcparam \
        c.jcphuff c.jcprepct c.jcsample c.jctrans c.jdapimin c.jdapistd \
        c.jdatadst c.jdatasrc c.jdcoefct c.jdcolor c.jddctmgr c.jdhuff \
        c.jdinput c.jdmainct c.jdmarker c.jdmaster c.jdmerge c.jdphuff \
        c.jdpostct c.jdsample c.jdtrans c.jerror c.jfdctflt c.jfdctfst \
        c.jfdctint c.jidctflt c.jidctfst c.jidctint c.jidctred c.jquant1 \
        c.jquant2 c.jutils c.jmemmgr
# memmgr back ends: compile only one of these into a working library
SYSDEPSOURCES= c.jmemansi c.jmemname c.jmemnobs c.jmemdos c.jmemmac
# source files: cjpeg/djpeg/jpegtran applications, also rdjpgcom/wrjpgcom
APPSOURCES= c.cjpeg c.djpeg c.jpegtran c.cdjpeg c.rdcolmap c.rdswitch \
        c.rdjpgcom c.wrjpgcom c.rdppm c.wrppm c.rdgif c.wrgif c.rdtarga \
        c.wrtarga c.rdbmp c.wrbmp c.rdrle c.wrrle
SOURCES= $(LIBSOURCES) $(SYSDEPSOURCES) $(APPSOURCES)
# files included by source files
INCLUDES= h.jchuff h.jdhuff h.jdct h.jerror h.jinclude h.jmemsys h.jmorecfg \
        h.jpegint h.jpeglib h.jversion h.cdjpeg h.cderror
# documentation, test, and support files
DOCS= README install.doc usage.doc 1.cjpeg 1.djpeg 1.jpegtran 1.rdjpgcom \
        1.wrjpgcom wizard.doc c.example libjpeg.doc structure.doc \
        coderules.doc filelist.doc change.log
MKFILES= configure makefile.cfg makefile.ansi makefile.unix makefile.bcc \
        makefile.mc6 makefile.dj makefile.wat makcjpeg.st makdjpeg.st \
        makljpeg.st maktjpeg.st makefile.manx makefile.sas makefile.mms \
        makefile.vms makvms.opt
CONFIGFILES= jconfig.cfg jconfig.manx jconfig.sas jconfig.st jconfig.bcc \
        jconfig.mc6 jconfig.dj jconfig.wat jconfig.vms
OTHERFILES= jconfig.doc c.ckconfig c.ansi2knr 1.ansi2knr jmemdosa.asm
TESTFILES= test.orig_jpg test.img_ppm test.img_gif test.img_jpg test.prog_jpg \
        test.imgp_jpg
DISTFILES= $(DOCS) $(MKFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \
        $(OTHERFILES) $(TESTFILES)
# library object files common to compression and decompression
COMOBJECTS= o.jcomapi o.jutils o.jerror o.jmemmgr $(SYSDEPMEM)
# compression library object files
CLIBOBJECTS= o.jcapimin o.jcapistd o.jctrans o.jcparam o.jdatadst o.jcinit \
        o.jcmaster o.jcmarker o.jcmainct o.jcprepct o.jccoefct o.jccolor \
        o.jcsample o.jchuff o.jcphuff o.jcdctmgr o.jfdctfst o.jfdctflt \
        o.jfdctint
# decompression library object files
DLIBOBJECTS= o.jdapimin o.jdapistd o.jdtrans o.jdatasrc o.jdmaster \
        o.jdinput o.jdmarker o.jdhuff o.jdphuff o.jdmainct o.jdcoefct \
        o.jdpostct o.jddctmgr o.jidctfst o.jidctflt o.jidctint o.jidctred \
        o.jdsample o.jdcolor o.jquant1 o.jquant2 o.jdmerge
# These objectfiles are included in libjpeg.a
LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS)
# object files for sample applications (excluding library files)
COBJECTS= o.cjpeg o.rdppm o.rdgif o.rdtarga o.rdrle o.rdbmp o.rdswitch \
        o.cdjpeg
DOBJECTS= o.djpeg o.wrppm o.wrgif o.wrtarga o.wrrle o.wrbmp o.rdcolmap \
        o.cdjpeg
TROBJECTS= o.jpegtran o.rdswitch o.cdjpeg


all: libjpeg cjpeg djpeg jpegtran rdjpgcom wrjpgcom

libjpeg: $(LIBOBJECTS)
	$(RM) libjpeg
	$(RM) viafile
	touch viafile
	$(dolines i, $(LIBOBJECTS), echo $i { >> viafile })
	$(AR) libjpeg -v viafile

cjpeg: $(COBJECTS) libjpeg
	$(LN) $(LDFLAGS) -o cjpeg $(COBJECTS) -l@.libjpeg,c:o.stubs $(LDLIBS)

djpeg: $(DOBJECTS) libjpeg
	$(LN) $(LDFLAGS) -o djpeg $(DOBJECTS) -l@.libjpeg,c:o.stubs $(LDLIBS)

jpegtran: $(TROBJECTS) libjpeg
	$(LN) $(LDFLAGS) -o jpegtran $(TROBJECTS) -l@.libjpeg,c:o.stubs $(LDLIBS)

rdjpgcom: o.rdjpgcom
	$(LN) $(LDFLAGS) -o rdjpgcom o.rdjpgcom $(LDLIBS)

wrjpgcom: o.wrjpgcom
	$(LN) $(LDFLAGS) -o wrjpgcom o.wrjpgcom $(LDLIBS)

h.jconfig: doc.jconfig
	echo You must prepare a system-dependent h.jconfig file.
	echo Please read the installation directions in install.doc.
	exit 1

clean:
	$(RM) o.* cjpeg djpeg jpegtran libjpeg rdjpgcom wrjpgcom viafile
	$(RM) test.out*

test: cjpeg djpeg jpegtran
	$(RM) testout*
	run @.djpeg -dct int -ppm -outfile test.out_ppm test.orig_jpg
	run @.djpeg -dct int -gif -outfile test.out_gif  test.orig_jpg
	run @.cjpeg -dct int -outfile test.out_jpg  test.img_ppm
	run @.djpeg -dct int -ppm -outfile test.outp_ppm test.prog_jpg
	run @.cjpeg -dct int -progressive -opt -outfile test.outp_jpg test.img_ppm
	run @.jpegtran -outfile test.outt_jpg test.prog_jpg
	diff test.img_ppm test.out_ppm
	diff test.img_gif test.out_gif
	diff test.img_jpg test.out_jpg
	diff test.img_ppm test.outp_ppm
	diff test.imgp_jpg test.outp_jpg
	diff test.orig_jpg test.outt_jpg


o.jcapimin: c.jcapimin h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcapistd: c.jcapistd h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jccoefct: c.jccoefct h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jccolor: c.jccolor h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcdctmgr: c.jcdctmgr h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jchuff: c.jchuff h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jchuff
o.jcinit: c.jcinit h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcmainct: c.jcmainct h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcmarker: c.jcmarker h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcmaster: c.jcmaster h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcomapi: c.jcomapi h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcparam: c.jcparam h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcphuff: c.jcphuff h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jchuff
o.jcprepct: c.jcprepct h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jcsample: c.jcsample h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jctrans: c.jctrans h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdapimin: c.jdapimin h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdapistd: c.jdapistd h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdatadst: c.jdatadst h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror
o.jdatasrc: c.jdatasrc h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror
o.jdcoefct: c.jdcoefct h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdcolor: c.jdcolor h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jddctmgr: c.jddctmgr h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jdhuff: c.jdhuff h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdhuff
o.jdinput: c.jdinput h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdmainct: c.jdmainct h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdmarker: c.jdmarker h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdmaster: c.jdmaster h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdmerge: c.jdmerge h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdphuff: c.jdphuff h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdhuff
o.jdpostct: c.jdpostct h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdsample: c.jdsample h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jdtrans: c.jdtrans h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jerror: c.jerror h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jversion h.jerror
o.jfdctflt: c.jfdctflt h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jfdctfst: c.jfdctfst h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jfdctint: c.jfdctint h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jidctflt: c.jidctflt h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jidctfst: c.jidctfst h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jidctint: c.jidctint h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jidctred: c.jidctred h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jdct
o.jquant1: c.jquant1 h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jquant2: c.jquant2 h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jutils: c.jutils h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror
o.jmemmgr: c.jmemmgr h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jmemsys
o.jmemansi: c.jmemansi h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jmemsys
o.jmemname: c.jmemname h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jmemsys
o.jmemnobs: c.jmemnobs h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jmemsys
o.jmemdos: c.jmemdos h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jmemsys
o.jmemmac: c.jmemmac h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jpegint h.jerror h.jmemsys
o.cjpeg: c.cjpeg h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror h.jversion
o.djpeg: c.djpeg h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror h.jversion
o.jpegtran: c.jpegtran h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror h.jversion
o.cdjpeg: c.cdjpeg h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.rdcolmap: c.rdcolmap h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.rdswitch: c.rdswitch h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.rdjpgcom: c.rdjpgcom h.jinclude h.jconfig
o.wrjpgcom: c.wrjpgcom h.jinclude h.jconfig
o.rdppm: c.rdppm h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.wrppm: c.wrppm h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.rdgif: c.rdgif h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.wrgif: c.wrgif h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.rdtarga: c.rdtarga h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.wrtarga: c.wrtarga h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.rdbmp: c.rdbmp h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.wrbmp: c.wrbmp h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.rdrle: c.rdrle h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
o.wrrle: c.wrrle h.cdjpeg h.jinclude h.jconfig h.jpeglib h.jmorecfg h.jerror h.cderror
