# 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 SETUP instructions before saying "make" !!

# The name of your C compiler:
CC= bcc

# You may need to adjust these cc options:
CFLAGS= -DHAVE_STDC -DINCLUDES_ARE_ANSI \
	-ms -DMSDOS -DUSE_FMEM -DINCOMPLETE_TYPES_BROKEN -w-par -O2
# -DHAVE_STDC -DINCLUDES_ARE_ANSI enable ANSI-C features (we DON'T want -A)
# -ms selects small memory model for most efficient code
# -DMSDOS enables DOS-specific code
# -DUSE_FMEM indicates we have _fmemcpy() and _fmemset()
# -DINCOMPLETE_TYPES_BROKEN suppresses bogus warning about undefined structures
# -w-par suppresses warnings about unused function parameters
# -O2 enables full code optimization (for pre-3.0 Borland C++, use -O -G -Z)

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

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


# source files (independently compilable files)
SOURCES= jbsmooth.c jcarith.c jccolor.c jcdeflts.c jcexpand.c jchuff.c \
        jcmain.c jcmaster.c jcmcu.c jcpipe.c jcsample.c jdarith.c jdcolor.c \
        jddeflts.c jdhuff.c jdmain.c jdmaster.c jdmcu.c jdpipe.c jdsample.c \
        jerror.c jquant1.c jquant2.c jfwddct.c jrevdct.c jutils.c jmemmgr.c \
        jrdjfif.c jrdgif.c jrdppm.c jrdrle.c jrdtarga.c jwrjfif.c jwrgif.c \
        jwrppm.c jwrrle.c jwrtarga.c
# virtual source files (not present in distribution file, see SETUP)
VIRTSOURCES= jmemsys.c
# system-dependent implementations of virtual source files
SYSDEPFILES= jmemansi.c jmemname.c jmemnobs.c jmemdos.c jmemdos.h \
        jmemdosa.asm
# files included by source files
INCLUDES= jinclude.h jconfig.h jpegdata.h jversion.h jmemsys.h
# documentation, test, and support files
DOCS= README SETUP USAGE CHANGELOG cjpeg.1 djpeg.1 architecture codingrules
MAKEFILES= makefile.ansi makefile.unix makefile.manx makefile.sas \
        makcjpeg.st makdjpeg.st makljpeg.st makefile.mc5 makefile.mc6 \
        makefile.bcc makefile.mms makefile.vms makvms.opt
OTHERFILES= ansi2knr.c ckconfig.c example.c
TESTFILES= testorig.jpg testimg.ppm testimg.gif testimg.jpg
DISTFILES= $(DOCS) $(MAKEFILES) $(SOURCES) $(SYSDEPFILES) $(INCLUDES) \
        $(OTHERFILES) $(TESTFILES)
# objectfiles common to cjpeg and djpeg
COMOBJECTS= jutils.obj jerror.obj jmemmgr.obj jmemsys.obj jmemdosa.obj
# compression objectfiles
CLIBOBJECTS= jcmaster.obj jcdeflts.obj jcarith.obj jccolor.obj jcexpand.obj \
        jchuff.obj jcmcu.obj jcpipe.obj jcsample.obj jfwddct.obj \
        jwrjfif.obj jrdgif.obj jrdppm.obj jrdrle.obj jrdtarga.obj
COBJECTS= jcmain.obj $(CLIBOBJECTS) $(COMOBJECTS)
# decompression objectfiles
DLIBOBJECTS= jdmaster.obj jddeflts.obj jbsmooth.obj jdarith.obj jdcolor.obj \
        jdhuff.obj jdmcu.obj jdpipe.obj jdsample.obj jquant1.obj \
        jquant2.obj jrevdct.obj jrdjfif.obj jwrgif.obj jwrppm.obj \
        jwrrle.obj jwrtarga.obj
DOBJECTS= jdmain.obj $(DLIBOBJECTS) $(COMOBJECTS)
# These objectfiles are included in libjpeg.lib
LIBOBJECTS= $(CLIBOBJECTS) $(DLIBOBJECTS) $(COMOBJECTS)


all: cjpeg.exe djpeg.exe


# libjpeg.lib is useful if you are including the JPEG software in a larger
# program; you'd include it in your link, rather than the individual modules.
libjpeg.lib: $(LIBOBJECTS) $(RFILE)
    del libjpeg.lib
    tlib @$(RFILE)

# linker response file for same
$(RFILE) : Makefile
    del $(RFILE)
    echo libjpeg.lib & >$(RFILE)
    echo +jcmaster.obj +jcdeflts.obj +jcarith.obj +jccolor.obj & >>$(RFILE)
    echo +jcexpand.obj +jchuff.obj +jcmcu.obj +jcpipe.obj & >>$(RFILE)
    echo +jcsample.obj +jfwddct.obj +jwrjfif.obj +jrdgif.obj & >>$(RFILE)
    echo +jrdppm.obj +jrdrle.obj +jrdtarga.obj +jdmaster.obj & >>$(RFILE)
    echo +jddeflts.obj +jbsmooth.obj +jdarith.obj +jdcolor.obj & >>$(RFILE)
    echo +jdhuff.obj +jdmcu.obj +jdpipe.obj +jdsample.obj & >>$(RFILE)
    echo +jquant1.obj +jquant2.obj +jrevdct.obj +jrdjfif.obj & >>$(RFILE)
    echo +jwrgif.obj +jwrppm.obj +jwrrle.obj +jwrtarga.obj & >>$(RFILE)
    echo +jutils.obj +jerror.obj +jmemmgr.obj +jmemsys.obj & >>$(RFILE)
    echo +jmemdosa.obj >>$(RFILE)

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

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

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

jmemsys.c:
	echo You must select a system-dependent jmemsys.c file.
	echo Please read the SETUP directions.
	exit 1

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

test:
	del testout.*
	djpeg testorig.jpg testout.ppm
	djpeg -gif testorig.jpg testout.gif
	cjpeg testimg.ppm testout.jpg
	fc testimg.ppm testout.ppm
	fc testimg.gif testout.gif
	fc testimg.jpg testout.jpg


jbsmooth.obj : jbsmooth.c jinclude.h jconfig.h jpegdata.h
jcarith.obj : jcarith.c jinclude.h jconfig.h jpegdata.h
jccolor.obj : jccolor.c jinclude.h jconfig.h jpegdata.h
jcdeflts.obj : jcdeflts.c jinclude.h jconfig.h jpegdata.h
jcexpand.obj : jcexpand.c jinclude.h jconfig.h jpegdata.h
jchuff.obj : jchuff.c jinclude.h jconfig.h jpegdata.h
jcmain.obj : jcmain.c jinclude.h jconfig.h jpegdata.h jversion.h
jcmaster.obj : jcmaster.c jinclude.h jconfig.h jpegdata.h
jcmcu.obj : jcmcu.c jinclude.h jconfig.h jpegdata.h
jcpipe.obj : jcpipe.c jinclude.h jconfig.h jpegdata.h
jcsample.obj : jcsample.c jinclude.h jconfig.h jpegdata.h
jdarith.obj : jdarith.c jinclude.h jconfig.h jpegdata.h
jdcolor.obj : jdcolor.c jinclude.h jconfig.h jpegdata.h
jddeflts.obj : jddeflts.c jinclude.h jconfig.h jpegdata.h
jdhuff.obj : jdhuff.c jinclude.h jconfig.h jpegdata.h
jdmain.obj : jdmain.c jinclude.h jconfig.h jpegdata.h jversion.h
jdmaster.obj : jdmaster.c jinclude.h jconfig.h jpegdata.h
jdmcu.obj : jdmcu.c jinclude.h jconfig.h jpegdata.h
jdpipe.obj : jdpipe.c jinclude.h jconfig.h jpegdata.h
jdsample.obj : jdsample.c jinclude.h jconfig.h jpegdata.h
jerror.obj : jerror.c jinclude.h jconfig.h jpegdata.h
jquant1.obj : jquant1.c jinclude.h jconfig.h jpegdata.h
jquant2.obj : jquant2.c jinclude.h jconfig.h jpegdata.h
jfwddct.obj : jfwddct.c jinclude.h jconfig.h jpegdata.h
jrevdct.obj : jrevdct.c jinclude.h jconfig.h jpegdata.h
jutils.obj : jutils.c jinclude.h jconfig.h jpegdata.h
jmemmgr.obj : jmemmgr.c jinclude.h jconfig.h jpegdata.h jmemsys.h
jrdjfif.obj : jrdjfif.c jinclude.h jconfig.h jpegdata.h
jrdgif.obj : jrdgif.c jinclude.h jconfig.h jpegdata.h
jrdppm.obj : jrdppm.c jinclude.h jconfig.h jpegdata.h
jrdrle.obj : jrdrle.c jinclude.h jconfig.h jpegdata.h
jrdtarga.obj : jrdtarga.c jinclude.h jconfig.h jpegdata.h
jwrjfif.obj : jwrjfif.c jinclude.h jconfig.h jpegdata.h
jwrgif.obj : jwrgif.c jinclude.h jconfig.h jpegdata.h
jwrppm.obj : jwrppm.c jinclude.h jconfig.h jpegdata.h
jwrrle.obj : jwrrle.c jinclude.h jconfig.h jpegdata.h
jwrtarga.obj : jwrtarga.c jinclude.h jconfig.h jpegdata.h
jmemsys.obj : jmemsys.c jinclude.h jconfig.h jpegdata.h jmemsys.h
jmemdosa.obj : jmemdosa.asm
	tasm /mx jmemdosa.asm
