
PREF_CCFLAGS 	= $(CCOPTFLAG) ;		# Turn optimisation on
#PREF_CCFLAGS	= $(CCDEBUGFLAG) ;		# Debugging flags
PREF_LINKFLAGS	= $(LINKDEBUGFLAG) ;

# Run configure if it seems to be needed
if $(UNIX) {
	DEFINES += "unix" ;			# libtiff assumes this
	# Genfile actually creates libtiff/tif_config.h and libtiff/tiffconf.h:
	GenFileNND libtiff/tif_config.h :
	          "(cd $(SUBDIR); chmod +x configure ; ./configure --disable-old-jpeg --disable-pixarlog --disable-zlib --disable-jbig)" : configure ;
#	          "(cd $(SUBDIR); chmod +x configure ; ./configure --disable-jpeg --disable-old-jpeg --disable-pixarlog --disable-zlib --disable-jbig)" : configure ;
	# Workaround Jam problem of two products from one action:
	FakeFile libtiff/tiffconf.h : libtiff/tif_config.h ;
}

# else copy them
if $(NT) {
	File libtiff/tiffconf.h :     libtiff/tiffconf.vc.h ;
	File libtiff/tif_config.h :   libtiff/tif_config.vc.h ;
}

ObjectKeep port/getopt.c ;

# support library for generation utilities
#Library libport.lib : [ CatPaths port : getopt.c strcasecmp.c strtoul.c ] ;
if $(UNIX) {
	Library libport.lib : [ CatPaths port : strcasecmp.c ] ;
} else {
	Library libport.lib : [ CatPaths port : getopt.c strcasecmp.c ] ;
}

# generation utilities
Main mkg3states : libtiff/mkg3states.c ;
LinkLibraries mkg3states : libport.lib ;
GenFileND libtiff/tif_fax3sm.c : mkg3states -c const [ NormPaths libtiff/tif_fax3sm.c ] ;

# tiff library
LIBSRCS = tif_fax3.c tif_aux.c tif_close.c tif_codec.c tif_fax3sm.c tif_predict.c
        tif_compress.c tif_dir.c tif_dirinfo.c tif_dirread.c tif_dirwrite.c 
        tif_dumpmode.c tif_error.c tif_getimage.c tif_flush.c tif_luv.c
        tif_lzw.c tif_next.c tif_open.c tif_packbits.c tif_print.c 
        tif_read.c tif_swab.c tif_strip.c tif_thunder.c tif_tile.c 
        tif_version.c tif_warning.c tif_write.c tif_extension.c
        tif_jpeg.c tif_ojpeg.c ;

if $(UNIX) {
	LIBSRCS += tif_unix.c ;
} else {
	LIBSRCS += tif_msdos.c ;
}

# Optional codecs not included
# tif_zip.c
# tif_pixarlog.c
Library libtiff.lib : [ CatPaths libtiff : $(LIBSRCS) ] : : : $(JPEGINC) libtiff : ;

#Library library : sources : flags : defines : hdrpaths : objects

# copy header file to lib directory
File tiffconf.h    : libtiff/tiffconf.h ;
#File tif_config.h  : libtiff/tif_config.h ;
File tiffvers.h    : libtiff/tiffvers.h ;
File tiffio.h      : libtiff/tiffio.h ;
File tiff.h        : libtiff/tiff.h ;
# Because we're copying them, Jam doesn't scan them, so
# we have to set the co-dependencies explicitly :-(
NIncludes tiff.h : tiffconf.h ;
NIncludes tiffio.h : tiff.h tiffvers.h ;

# Compile some of the tools
SubInclude tools ;

