!if "$(NTMAKEENV)" != "" 
#
# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
# file to this component.  This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def


!else
# Makefile for Independent JPEG Group's software
# Read installation instructions before saying "nmake" !!
# Generally, we recommend defining any configuration symbols in jconfig.h,
#
# nmake [nodebug=1]

!ifndef ROOT
ROOT    = ..\..\..\..
!endif

!ifndef TOOLS
TOOLS   = $(ROOT)\dev\tools\c932
!endif
!ifndef TOOLSBIN
TOOLSBIN= $(TOOLS)\bin
!endif
!ifndef TOOLSINC
TOOLSINC= $(TOOLS)\inc
!endif
!ifndef TOOLSLIB
TOOLSLIB= $(TOOLS)\lib
!endif
!ifndef SDKLIB
SDKLIB  = $(ROOT)\dev\sdk\lib
!endif

!ifndef CPU
CPU     = i386
!endif

CC      = cl -nologo
CFLAGS  = -W3 -Gz -Zlp -D_MT

LIB     = lib -nologo
LIBFLAGS= -machine:$(CPU)

LINK    = link -nologo
LINKFLAGS = -machine:$(CPU) -nodefaultlib -subsystem:console

!if "$(BUILD)" == "debug"
CFLAGS  = $(CFLAGS) -Od -Zi -D_DEBUG
!else
CFLAGS  = $(CFLAGS) -Oxs -Gfy
!endif

# Library object files shared by compression and decompression code
#
SHAOBJ  = jcomapi.obj jutils.obj jerror.obj jmemmgr.obj jmemnobs.obj

# Compression library object files
#
COMOBJ  = jcapimin.obj jcapistd.obj jctrans.obj jcparam.obj jdatadst.obj \
        jcinit.obj jcmaster.obj jcmarker.obj jcmainct.obj jcprepct.obj \
        jccoefct.obj jccolor.obj jcsample.obj jchuff.obj jcphuff.obj \
        jcdctmgr.obj jfdctfst.obj jfdctflt.obj jfdctint.obj

# Decompression library object files
#
DECOBJ  = jdapimin.obj jdapistd.obj jdtrans.obj jdatasrc.obj \
        jdmaster.obj jdinput.obj jdmarker.obj jdhuff.obj jdphuff.obj \
        jdmainct.obj jdcoefct.obj jdpostct.obj jddctmgr.obj jidctfst.obj \
        jidctflt.obj jidctint.obj jidctred.obj jdsample.obj jdcolor.obj \
        jquant1.obj jquant2.obj jdmerge.obj

# object files for sample applications (excluding library files)
COBJECTS= cjpeg.obj rdppm.obj rdgif.obj rdtarga.obj rdrle.obj rdbmp.obj \
        rdswitch.obj cdjpeg.obj

DOBJECTS= djpeg.obj wrppm.obj wrgif.obj wrtarga.obj wrrle.obj wrbmp.obj \
        rdcolmap.obj cdjpeg.obj

TOBJECTS= jpegtran.obj rdswitch.obj cdjpeg.obj

SYSLIBS= $(TOOLSLIB)\libcmt.lib $(SDKLIB)\kernel32.lib $(SDKLIB)\user32.lib

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

default: setflags jconfig.h jpeglib.lib

all: setflags jconfig.h jpeglib.lib \
     cjpeg.exe djpeg.exe jpegtran.exe rdjpgcom.exe wrjpgcom.exe

setflags:
    set PATH=$(TOOLSBIN)
    set INCLUDE=$(TOOLSINC)
    set LIB=$(TOOLSLIB)
    @echo.

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

jpeglib.lib: $(COMOBJ) $(DECOBJ) $(SHAOBJ)
    $(LIB) $(LIBFLAGS) -out:$@ $**
    @echo.

cjpeg.exe: $(COBJECTS) jpeglib.lib $(SYSLIBS)
    $(LINK) $(LINKFLAGS) $**
    @echo.

djpeg.exe: $(DOBJECTS) jpeglib.lib $(SYSLIBS)
    $(LINK) $(LINKFLAGS) $**
    @echo.

jpegtran.exe: $(TOBJECTS) jpeglib.lib $(SYSLIBS)
    $(LINK) $(LINKFLAGS) $**
    @echo.

rdjpgcom.exe: rdjpgcom.obj $(SYSLIBS)
    $(LINK) $(LINKFLAGS) $**
    @echo.

wrjpgcom.exe: wrjpgcom.obj $(SYSLIBS)
    $(LINK) $(LINKFLAGS) $**
    @echo.

clean:
    -del *.obj
    -del *.exe
    -del *.lib
    -del testout*.*

test: cjpeg.exe djpeg.exe jpegtran.exe
    -del testout*.*
    djpeg -dct int -ppm -outfile testout.ppm  testorig.jpg
    djpeg -dct int -gif -outfile testout.gif  testorig.jpg
    cjpeg -dct int -outfile testout.jpg  testimg.ppm
    djpeg -dct int -ppm -outfile testoutp.ppm testprog.jpg
    cjpeg -dct int -progressive -opt -outfile testoutp.jpg testimg.ppm
    jpegtran -outfile testoutt.jpg testprog.jpg
    fc /b testimg.ppm testout.ppm
    fc /b testimg.gif testout.gif
    fc /b testimg.jpg testout.jpg
    fc /b testimg.ppm testoutp.ppm
    fc /b testimgp.jpg testoutp.jpg
    fc /b testorig.jpg testoutt.jpg

!endif    # !if NTMAKEENV
