# Makefile for Independent JPEG Group's software

# This makefile is suitable for Borland C (Turbo C) on MS-DOS.
# It is set up for Borland C++, revision 3.0 or later.
# For older versions (pre-3.0), replace "-O2" with "-O -G -Z" in CFLAGS.
# If you have an even older version of Turbo C, you may be able to make it
# work by saying "CC= tcc" below.  (Very early versions of Turbo C++,
# like 1.01, are so buggy that you may as well forget it.)
# Thanks to Tom Wright and Ge' Weijers for this file.

# Read installation instructions before saying "make" !!

# The name of your C compiler:
CC= bcc

# You may need to adjust these cc options:
CFLAGS= -ms -w-par -O2
# -ms selects small memory model for most efficient code
# -w-par suppresses warnings about unused function parameters
# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z)
# Generally, we recommend defining any configuration symbols in jconfig.h,
# NOT via -D switches here.

# Link-time cc options:
LDFLAGS= -ms
# memory model option here must match CFLAGS!

# Put here the object file name for the correct system-dependent memory
# manager file.  For DOS, we recommend jmemdos.c and jmemdosa.asm.
SYSDEPMEM= jmemdos.obj jmemdosa.obj

# End of configurable options.


# source files: JPEG library proper
LIBSOURCES= jcapi.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c jcmainct.c \
        jcmarker.c jcmaster.c jcomapi.c jcparam.c jcprepct.c jcsample.c \
        jdapi.c jdatasrc.c jdatadst.c jdcoefct.c jdcolor.c jddctmgr.c \
        jdhuff.c jdmainct.c jdmarker.c jdmaster.c jdpostct.c jdsample.c \
        jerror.c jutils.c jfdctllm.c jidctllm.c jidctred.c jquant1.c \
        jquant2.c jmemmgr.c jmemansi.c jmemname.c jmemnobs.c jmemdos.c
# source files: cjpeg/djpeg applications
APPSOURCES= cjpeg.c djpeg.c rdppm.c wrppm.c rdgif.c wrgif.c rdtarga.c \
        wrtarga.c
SOURCES= $(LIBSOURCES) $(APPSOURCES)
# files included by source files
INCLUDES= jdct.h jerror.h jinclude.h jmemsys.h jmorecfg.h jpegint.h \
        jpeglib.h jversion.h cdjpeg.h cderror.h
# documentation, test, and support files
DOCS= README install.doc usage.doc cjpeg.1 djpeg.1 example.c libjpeg.doc \
        structure.doc coderules.doc filelist.doc change.log
MAKEFILES= configure makefile.auto makefile.ansi makefile.unix \
        makefile.manx makefile.sas makcjpeg.st makdjpeg.st makljpeg.st \
        makefile.bcc makefile.mc6 makefile.mms makefile.vms makvms.opt
CONFIGFILES= jconfig.auto jconfig.manx jconfig.sas jconfig.st jconfig.bcc \
        jconfig.mc6 jconfig.vms
OTHERFILES= jconfig.doc ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm
TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg
DISTFILES= $(DOCS) $(MAKEFILES) $(CONFIGFILES) $(SOURCES) $(INCLUDES) \
        $(OTHERFILES) $(TESTFILES)
# library object files common to compression and decompression
COMOBJECTS= jcomapi.obj jutils.obj jerror.obj jmemmgr.obj $(SYSDEPMEM)
# compression library object files
CLIBOBJECTS= jcapi.obj jcparam.obj jdatadst.obj jcmaster.obj jcmarker.obj \
        jcmainct.obj jcprepct.obj jccoefct.obj jccolor.obj jcsample.obj \
        jchuff.obj jcdctmgr.obj jfdctllm.obj
# decompression library object files
DLIBOBJECTS= jdapi.obj jdatasrc.obj jdmaster.obj jdmarker.obj jdmainct.obj \
        jdcoefct.obj jdpostct.obj jddctmgr.obj jidctllm.obj jidctred.obj \
        jdhuff.obj jdsample.obj jdcolor.obj jquant1.obj jquant2.obj
# These objectfiles are included in libjpeg.lib
LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS)
# object files for cjpeg and djpeg applications (excluding library files)
COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj
DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj

# need linker response file because file list > 128 chars
RFILE= libjpeg.ans


all: libjpeg.lib cjpeg.exe djpeg.exe

libjpeg.lib: $(LIBOBJECTS) $(RFILE)
	del libjpeg.lib
	tlib @$(RFILE)

# linker response file for building libjpeg.lib
$(RFILE) : Makefile
    del $(RFILE)
    echo libjpeg.lib & >$(RFILE)
    echo +jcapi.obj +jcparam.obj +jdatadst.obj +jcmaster.obj & >>$(RFILE)
    echo +jcmarker.obj +jcmainct.obj +jcprepct.obj +jccoefct.obj & >>$(RFILE)
    echo +jccolor.obj +jcsample.obj +jchuff.obj +jcdctmgr.obj & >>$(RFILE)
    echo +jfdctllm.obj +jdapi.obj +jdatasrc.obj +jdmaster.obj & >>$(RFILE)
    echo +jdmarker.obj +jdmainct.obj +jdcoefct.obj +jdpostct.obj & >>$(RFILE)
    echo +jddctmgr.obj +jidctllm.obj +jidctred.obj +jdhuff.obj & >>$(RFILE)
    echo +jdsample.obj +jdcolor.obj +jquant1.obj +jquant2.obj & >>$(RFILE)
    echo +jcomapi.obj +jutils.obj +jerror.obj +jmemmgr.obj & >>$(RFILE)
    echo +jmemdos.obj +jmemdosa.obj >>$(RFILE)

cjpeg.exe: $(COBJECTS) libjpeg.lib
	$(CC) $(LDFLAGS) -ecjpeg.exe $(COBJECTS) libjpeg.lib

djpeg.exe: $(DOBJECTS) libjpeg.lib
	$(CC) $(LDFLAGS) -edjpeg.exe $(DOBJECTS) libjpeg.lib

.c.obj:
	$(CC) $(CFLAGS) -c $<

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

clean:
	del *.obj
	del libjpeg.lib
	del cjpeg.exe
	del djpeg.exe
	del testout.*

test: cjpeg.exe djpeg.exe
	del testout.*
	djpeg -outfile testout.ppm  testorig.jpg
	djpeg -gif -outfile testout.gif  testorig.jpg
	cjpeg -outfile testout.jpg  testimg.ppm
	fc /b testimg.ppm testout.ppm
	fc /b testimg.gif testout.gif
	fc /b testimg.jpg testout.jpg


jcapi.obj : jcapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jccoefct.obj : jccoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jccolor.obj : jccolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcdctmgr.obj : jcdctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h
jchuff.obj : jchuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcmainct.obj : jcmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcmarker.obj : jcmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcomapi.obj : jcomapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcparam.obj : jcparam.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcprepct.obj : jcprepct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jcsample.obj : jcsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdapi.obj : jdapi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdatasrc.obj : jdatasrc.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h
jdatadst.obj : jdatadst.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h
jdcoefct.obj : jdcoefct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jddctmgr.obj : jddctmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h
jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdmainct.obj : jdmainct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdmarker.obj : jdmarker.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdpostct.obj : jdpostct.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jdsample.obj : jdsample.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jerror.obj : jerror.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jversion.h jerror.h
jutils.obj : jutils.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jfdctllm.obj : jfdctllm.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h
jidctllm.obj : jidctllm.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h
jidctred.obj : jidctred.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jdct.h
jquant1.obj : jquant1.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jquant2.obj : jquant2.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h
jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h
jmemansi.obj : jmemansi.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h
jmemname.obj : jmemname.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h
jmemnobs.obj : jmemnobs.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h
jmemdos.obj : jmemdos.c jinclude.h jconfig.h jpeglib.h jmorecfg.h jpegint.h jerror.h jmemsys.h
cjpeg.obj : cjpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h
djpeg.obj : djpeg.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h jversion.h
rdppm.obj : rdppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h
wrppm.obj : wrppm.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h
rdgif.obj : rdgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h
wrgif.obj : wrgif.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h
rdtarga.obj : rdtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h
wrtarga.obj : wrtarga.c cdjpeg.h jinclude.h jconfig.h jpeglib.h jmorecfg.h jerror.h cderror.h
jmemdosa.obj : jmemdosa.asm
	tasm /mx jmemdosa.asm
