1INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software 2 3Copyright (C) 1991-1994, Thomas G. Lane. 4This file is part of the Independent JPEG Group's software. 5For conditions of distribution and use, see the accompanying README file. 6 7 8This file explains how to configure and install the IJG software. We have 9tried to make this software extremely portable and flexible, so that it can be 10adapted to almost any environment. The downside of this decision is that the 11installation process is complicated. We have provided shortcuts to simplify 12the task on common systems. But in any case, you will need at least a little 13familiarity with C programming and program build procedures for your system. 14 15If you are only using this software as part of a larger program, the larger 16program's installation procedure may take care of configuring the IJG code. 17For example, Ghostscript's installation script will configure the IJG code. 18You don't need to read this file if you just want to compile Ghostscript. 19 20If you are on a Unix machine, you may not need to read this file at all. 21Try doing 22 ./configure 23 make 24 make test 25If that doesn't complain, do 26 make install 27(better do "make -n install" first to see if the makefile will put the files 28where you want them). Read further if you run into snags or want to customize 29the code for your system. 30 31 32TABLE OF CONTENTS 33----------------- 34 35Before you start 36Configuring the software: 37 using the automatic "configure" script 38 using one of the supplied jconfig and makefile files 39 by hand 40Building the software 41Testing the software 42Installing the software 43Optional stuff 44Optimization 45Hints for specific systems 46 47 48BEFORE YOU START 49================ 50 51Before installing the software you must unpack the distributed source code. 52Since you are reading this file, you have probably already succeeded in this 53task. However, there is a potential for error if you needed to convert the 54files to the local standard text file format (for example, if you are on 55MS-DOS you may have converted LF end-of-line to CR/LF). You must apply 56such conversion to all the files EXCEPT those whose names begin with "test". 57The test files contain binary data; if you change them in any way then the 58self-test will give bad results. 59 60Please check the last section of this file to see if there are hints for the 61specific machine or compiler you are using. 62 63 64CONFIGURING THE SOFTWARE 65======================== 66 67To configure the IJG code for your system, you need to create two files: 68 * jconfig.h: contains values for system-dependent #define symbols. 69 * Makefile: controls the compilation process. 70(On a non-Unix machine, you may create "project files" or some other 71substitute for a Makefile. jconfig.h is needed in any environment.) 72 73We provide three different ways to generate these files: 74 * On a Unix system, you can just run the "configure" script. 75 * We provide sample jconfig files and makefiles for popular machines; 76 if your machine matches one of the samples, just copy the right sample 77 files to jconfig.h and Makefile. 78 * If all else fails, read the instructions below and make your own files. 79 80 81Configuring the software using the automatic "configure" script 82--------------------------------------------------------------- 83 84If you are on a Unix machine, you can just type 85 ./configure 86and let the configure script construct appropriate configuration files. 87If you're using "csh" on an old version of System V, you might need to type 88 sh configure 89instead to prevent csh from trying to execute configure itself. 90Expect configure to run for a few minutes, particularly on slower machines; 91it works by compiling a series of test programs. 92 93Configure was created with GNU Autoconf and it follows the usual conventions 94for GNU configure scripts. It makes a few assumptions that you may want to 95override. You can do this by providing optional switches to configure: 96 97* Configure will use gcc (GNU C compiler) if it's available, otherwise cc. 98To force a particular compiler to be selected, use the CC option, for example 99 ./configure CC='cc' 100The same method can be used to include any unusual compiler switches. 101For example, on HP-UX you probably want to say 102 ./configure CC='cc -Aa' 103to get HP's compiler to run in ANSI mode. 104 105* Configure will set up the makefile so that "make install" will install files 106into /usr/local/bin, /usr/local/man, etc. You can specify an installation 107prefix other than "/usr/local" by giving configure the option "--prefix=PATH". 108 109* If you don't have a lot of swap space, you may need to enable the IJG 110software's internal virtual memory mechanism. To do this, give the option 111"--with-maxmem=N" where N is the default maxmemory limit in megabytes. 112This is discussed in more detail under "Selecting a memory manager", below. 113You probably don't need to worry about this on reasonably-sized Unix machines, 114unless you plan to process very large images. 115 116Configure has some other features that are useful if you are cross-compiling 117or working in a network of multiple machine types; but if you need those 118features, you probably already know how to use them. 119 120 121Configuring the software using one of the supplied jconfig and makefile files 122----------------------------------------------------------------------------- 123 124If you have one of these systems, you can just use the provided configuration 125files: 126 127Makefile jconfig file System and/or compiler 128 129makefile.manx jconfig.manx Amiga, Manx Aztec C 130makefile.sas jconfig.sas Amiga, SAS C 131mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C 132makefile.bcc jconfig.bcc MS-DOS, Borland C (Turbo C) 133makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C) 134makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C version 6.x and up 135makefile.mms jconfig.vms Digital VMS, with MMS software 136makefile.vms jconfig.vms Digital VMS, without MMS software 137 138Copy the proper jconfig file to jconfig.h and the makefile to Makefile 139(or whatever your system uses as the standard makefile name). For the 140Atari, we provide three project files; see the Atari hints below. 141 142 143Configuring the software by hand 144-------------------------------- 145 146First, generate a jconfig.h file. If you are moderately familiar with C, 147the comments in jconfig.doc should be enough information to do this; just 148copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may 149prefer to use the ckconfig.c program. You will need to compile and execute 150ckconfig.c by hand --- we hope you know at least enough to do that. 151ckconfig.c may not compile the first try (in fact, the whole idea is for it 152to fail if anything is going to). If you get compile errors, fix them by 153editing ckconfig.c according to the directions given in ckconfig.c. Once 154you get it to run, it will write a suitable jconfig.h file, and will also 155print out some advice about which makefile to use. 156 157You may also want to look at the canned jconfig files, if there is one for a 158system similar to yours. 159 160Second, select a makefile and copy it to Makefile (or whatever your system 161uses as the standard makefile name). The most generic makefiles we provide 162are 163 makefile.ansi: if your C compiler supports function prototypes 164 makefile.unix: if not. 165(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES" 166in jconfig.h.) You may want to start from one of the other makefiles if 167there is one for a system similar to yours. 168 169Look over the selected Makefile and adjust options as needed. In particular 170you may want to change the CC and CFLAGS definitions. For instance, if you 171are using GCC, set CC=gcc. If you had to use any compiler switches to get 172ckconfig.c to work, make sure the same switches are in CFLAGS. 173 174If you are on a system that doesn't use makefiles, you'll need to set up 175project files (or whatever you do use) to compile all the source files and 176link them into executable files cjpeg, djpeg, rdjpgcom, and wrjpgcom. See 177the file lists in any of the makefiles to find out which files go into each 178program. Note that the provided makefiles all make a "library" file libjpeg 179first, but you don't have to do that if you don't want to; the file lists 180identify which source files are actually needed for compression, 181decompression, or both. As a last resort, you can make a batch script that 182just compiles everything and links it all together; makefile.vms is an 183example of this (it's for VMS systems that have no make-like utility). 184 185Here are comments about some specific configuration decisions you'll 186need to make: 187 188Command line style 189------------------ 190 191cjpeg and djpeg can use a Unix-like command line style which supports 192redirection and piping, like this: 193 cjpeg inputfile >outputfile 194 cjpeg <inputfile >outputfile 195 source program | cjpeg >outputfile 196The simpler "two file" command line style is just 197 cjpeg inputfile outputfile 198You may prefer the two-file style, particularly if you don't have pipes. 199 200You MUST use two-file style on any system that doesn't cope well with binary 201data fed through stdin/stdout; this is true for some MS-DOS compilers, for 202example. If you're not on a Unix system, it's safest to assume you need 203two-file style. (But if your compiler provides either the Posix-standard 204fdopen() library routine or a Microsoft-compatible setmode() routine, you 205can safely use the Unix command line style, by defining USE_FDOPEN or 206USE_SETMODE respectively.) 207 208To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE". 209 210Selecting a memory manager 211-------------------------- 212 213The IJG code is capable of working on images that are too big to fit in main 214memory; data is swapped out to temporary files as necessary. However, the 215code to do this is rather system-dependent. We provide four different 216memory managers: 217 218* jmemansi.c This version uses the ANSI-standard library routine tmpfile(), 219 which not all non-ANSI systems have. On some systems 220 tmpfile() may put the temporary file in a non-optimal 221 location; if you don't like what it does, use jmemname.c. 222 223* jmemname.c This version creates named temporary files. For anything 224 except a Unix machine, you'll need to configure the 225 select_file_name() routine appropriately; see the comments 226 near the head of jmemname.c. If you use this version, define 227 NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files 228 are removed if the program is aborted. 229 230* jmemnobs.c (That stands for No Backing Store :-).) This will compile on 231 almost any system, but it assumes you have enough main memory 232 or virtual memory to hold the biggest images you work with. 233 234* jmemdos.c This should be used with most 16-bit MS-DOS compilers. 235 See the system-specific notes about MS-DOS for more info. 236 IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in 237 jconfig.h, and include the assembly file jmemdosa.asm in the 238 programs. The supplied makefiles and jconfig files for 239 MS-DOS compilers already do both. 240 241To use a particular memory manager, change the SYSDEPMEM variable in your 242makefile to equal the corresponding object file name (for example, jmemansi.o 243or jmemansi.obj for jmemansi.c). 244 245If you have plenty of (real or virtual) main memory, just use jmemnobs.c. 246"Plenty" means about ten bytes for every pixel in the largest images 247you plan to process, so a lot of systems don't meet this criterion. 248If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have 249to use jmemname.c; be sure to adjust select_file_name() for local conditions. 250You may also need to change unlink() to remove() in close_backing_store(). 251 252Except with jmemnobs.c, you need to adjust the DEFAULT_MAX_MEM setting to a 253reasonable value for your system (either by adding a #define for 254DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile). 255This value limits the amount of data space the program will attempt to 256allocate. Code and static data space isn't counted, so the actual memory 257needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory 258setting. Larger max-memory settings reduce the amount of I/O needed to 259process a large image, but too large a value can result in "insufficient 260memory" failures. On most Unix machines (and other systems with virtual 261memory), just set DEFAULT_MAX_MEM to several million and forget it. At the 262other end of the spectrum, for MS-DOS machines you probably can't go much 263above 300K to 400K. (On MS-DOS the value refers to conventional memory only. 264Extended/expanded memory is handled separately by jmemdos.c.) 265 266 267BUILDING THE SOFTWARE 268===================== 269 270Now you should be able to compile the software. Just say "make" (or 271whatever's necessary to start the compilation). Have a cup of coffee. 272 273Here are some things that could go wrong: 274 275If your compiler complains about undefined structures, you should be able to 276shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h. 277 278If you have trouble with missing system include files or inclusion of the 279wrong ones, read jinclude.h. This shouldn't happen if you used configure 280or ckconfig.c to set up jconfig.h. 281 282There are a fair number of routines that do not use all of their parameters; 283some compilers will issue warnings about this, which you can ignore. There 284are also a few configuration checks that may give "unreachable code" warnings. 285Any other warning deserves investigation. 286 287If you don't have a getenv() library routine, define NO_GETENV. 288 289Also see the system-specific hints, below. 290 291 292TESTING THE SOFTWARE 293==================== 294 295As a quick test of functionality we've included a small sample image in 296several forms: 297 testorig.jpg Starting point for the djpeg tests. 298 testimg.ppm The output of djpeg testorig.jpg 299 testimg.gif The output of djpeg -gif testorig.jpg 300 testimg.jpg The output of cjpeg testimg.ppm 301(The two .jpg files aren't identical since JPEG is lossy.) If you can 302generate duplicates of the testimg.* files then you probably have working 303programs. 304 305With most of the makefiles, "make test" will perform the necessary 306comparisons. 307 308If you're using a makefile that doesn't provide the test option, run djpeg 309and cjpeg by hand to generate testout.ppm, testout.gif, and testout.jpg, 310then compare these to testimg.* with whatever binary file comparison tool 311you have. The files should be bit-for-bit identical. 312 313If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you 314need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t. 315Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely 316configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE 317as long should take care of that one. 318 319If the cjpeg test run fails with "Missing Huffman code table entry", it's a 320good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the 321configuration step and run ckconfig.c. (This is a good plan for any other 322test failure, too.) 323 324If you are using Unix (one-file) command line style on a non-Unix system, 325it's a good idea to check that binary I/O through stdin/stdout actually 326works. You should get the same results from "djpeg <testorig.jpg >out.ppm" 327as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all 328use the latter style and therefore do not exercise stdin/stdout! If this 329check fails, try recompiling cjpeg.c and djpeg.c with USE_SETMODE or 330USE_FDOPEN. If it still doesn't work, better use two-file style. 331(rdjpgcom.c and wrjpgcom.c will also need to be recompiled.) 332 333If you chose a memory manager other than jmemnobs.c, you should test that 334temporary-file usage works. Try "djpeg -gif -max 0 testorig.jpg" and make 335sure its output matches testimg.gif. If you have any really large images 336handy, try compressing them with -optimize and/or decompressing with -gif to 337make sure your DEFAULT_MAX_MEM setting is not too large. 338 339NOTE: this is far from an exhaustive test of the JPEG software; some modules, 340such as 1-pass color quantization, are not exercised at all. It's just a 341quick test to give you some confidence that you haven't missed something 342major. 343 344 345INSTALLING THE SOFTWARE 346======================= 347 348Once you're done with the above steps, you can install the software by 349copying the executable files (cjpeg, djpeg, rdjpgcom, and wrjpgcom) to 350wherever you normally install programs. On Unix systems, you'll also want 351to put the man pages (cjpeg.1, djpeg.1, rdjpgcom.1, wrjpgcom.1) in the 352man-page directory. The canned makefiles don't support this step since 353there's such a wide variety of installation procedures on different systems. 354 355If you generated a Makefile with the "configure" script, you can just say 356 make install 357to install the programs and their man pages into the standard places. 358(You'll probably need to be root to do this.) We recommend first saying 359 make -n install 360to see where configure thought the files should go. You may need to edit 361the Makefile, particularly if your system's conventions for man page 362filenames don't match what configure expects. 363 364If you want to install the library file libjpeg.a and the include files j*.h 365(for use in compiling other programs besides cjpeg/djpeg), then say 366 make install-lib 367 368 369OPTIONAL STUFF 370============== 371 372Progress monitor: 373 374If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display 375of percent-done progress reports. The routines provided in cjpeg.c/djpeg.c 376merely print percentages to stderr, but you can customize them to do 377something fancier. 378 379Utah RLE file format support: 380 381We distribute the software with support for RLE image files (Utah Raster 382Toolkit format) disabled, because the RLE support won't compile without the 383Utah library. If you have URT version 3.1 or later, you can enable RLE 384support as follows: 385 1. #define RLE_SUPPORTED in jconfig.h. 386 2. Add a -I option to CFLAGS in the Makefile for the directory 387 containing the URT .h files (typically the "include" 388 subdirectory of the URT distribution). 389 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies 390 the directory containing the URT "librle.a" file (typically the 391 "lib" subdirectory of the URT distribution). 392 393Removing code: 394 395If you need to make a smaller version of the JPEG software, some optional 396functions can be removed at compile time. See the xxx_SUPPORTED #defines in 397jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in 398decoder support for all valid JPEG files, to ensure that you can read anyone's 399output. Taking out support for image file formats that you don't use is the 400most painless way to make the programs smaller. Another possibility is to 401remove some of the DCT methods: in particular, the "IFAST" method may not be 402enough faster than the others to be worth keeping on your machine. (If you 403do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST 404to a supported method, by adding a #define in jconfig.h.) 405 406 407OPTIMIZATION 408============ 409 410Unless you own a Cray, you'll probably be interested in making the JPEG 411software go as fast as possible. This section covers some machine-dependent 412optimizations you may want to try. We suggest that before trying any of 413this, you first get the basic installation to pass the self-test step. 414Repeat the self-test after any optimization to make sure that you haven't 415broken anything. 416 417The integer DCT routines perform a lot of multiplications. These 418multiplications must yield 32-bit results, but none of their input values 419are more than 16 bits wide. On many machines, notably the 680x0 and 80x86 420CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32 421bit multiply. Unfortunately there is no portable way to specify such a 422multiplication in C, but some compilers can generate one when you use the 423right combination of casts. See the MULTIPLYxxx macro definitions in 424jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits, 425defining SHORTxSHORT_32 is fairly likely to work. When experimenting with 426alternate definitions, be sure to test not only whether the code still works 427(use the self-test), but also whether it is actually faster --- on some 428compilers, alternate definitions may compute the right answer, yet be slower 429than the default. Timing cjpeg on a large PPM input file is the best way to 430check this, as the DCT will be the largest fraction of the runtime in that 431mode. (Note: some of the distributed compiler-specific jconfig files 432already contain #define switches to select appropriate MULTIPLYxxx 433definitions.) 434 435If your machine has sufficiently fast floating point hardware, you may find 436that the float DCT method is faster than the integer DCT methods, even 437after tweaking the integer multiply macros. In that case you may want to 438make the float DCT be the default method. (The only objection to this is 439that float DCT results may vary slightly across machines.) To do that, add 440"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change 441the default, you should redefine JDCT_FASTEST, which is the method selected 442by djpeg's -fast switch. Don't forget to update the documentation files 443(usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done. 444 445If access to "short" arrays is slow on your machine, it may be a win to 446define type JCOEF as int rather than short. This will cost a good deal of 447memory though, particularly in some multi-pass modes, so don't do it unless 448you have memory to burn and short is REALLY slow. 449 450If your compiler can compile function calls in-line, make sure the INLINE 451macro in jmorecfg.h is defined as the keyword that marks a function 452inline-able. Some compilers have a switch that tells the compiler to inline 453any function it thinks is profitable (e.g., -finline-functions for gcc). 454Enabling such a switch is likely to make the compiled code bigger but faster. 455 456In general, it's worth trying the maximum optimization level of your compiler, 457and experimenting with any optional optimizations such as loop unrolling. 458(Unfortunately, far too many compilers have optimizer bugs ... be prepared to 459back off if the code fails self-test.) If you do any experimentation along 460these lines, please report the optimal settings to jpeg-info@uunet.uu.net so 461we can mention them in future releases. Be sure to specify your machine and 462compiler version. 463 464 465HINTS FOR SPECIFIC SYSTEMS 466========================== 467 468We welcome reports on changes needed for systems not mentioned here. Submit 469'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong 470about how to configure the JPEG software for your system, please let us know. 471 472 473Acorn RISC OS: 474 475(Thanks to Simon Middleton for these hints on compiling with Desktop C.) 476After renaming the files according to Acorn conventions, take a copy of 477makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and 478change these definitions as indicated: 479 480CFLAGS= -throwback -IC: -Wn 481LDLIBS=C:o.Stubs 482SYSDEPMEM=jmemansi.o 483LN=Link 484AR=LibFile -c -o 485 486Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the 487lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h' 488dependency section. 489 490Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE 491and CHAR_IS_UNSIGNED. 492 493Run the makefile using !AMU not !Make. If you want to use the 'clean' and 494'test' makefile entries then you will have to fiddle with the syntax a bit 495and rename the test files. 496 497 498Amiga: 499 500SAS C 6.50 reportedly is too buggy to compile the IJG code properly. 501A patch to update to 6.51 is available from SAS or AmiNet FTP sites. 502 503 504Atari ST/STE/TT: 505 506Copy the project files makcjpeg.st, makdjpeg.st, and makljpeg.st to cjpeg.prj, 507djpeg.prj, and libjpeg.prj respectively. The project files should work as-is 508with Pure C. For Turbo C, change library filenames "PC..." to "TC..." in 509cjpeg.prj and djpeg.prj. Note that libjpeg.prj selects jmemansi.c as the 510recommended memory manager. You'll probably want to adjust the 511DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K less than 512your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into jconfig.h 513to do this. 514 515To use the 68881/68882 coprocessor for the floating point DCT, add the 516compiler option "-8" to the project files and replace PCFLTLIB.LIB with 517PC881LIB.LIB in cjpeg.prj and djpeg.prj. Or if you don't have a 518coprocessor, you may prefer to remove the float DCT code by undefining 519DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float 520code will be too slow to be useful). In that case, you can delete 521PCFLTLIB.LIB from the project files. 522 523Note that you must make libjpeg.lib before making cjpeg.ttp or djpeg.ttp. 524You'll have to perform the self-test by hand. 525 526We haven't bothered to include project files for rdjpgcom and wrjpgcom. 527Those source files should just be compiled by themselves; they don't 528depend on the JPEG library. 529 530There is a bug in some older versions of the Turbo C library which causes the 531space used by temporary files created with "tmpfile()" not to be freed after 532an abnormal program exit. If you check your disk afterwards, you will find 533cluster chains that are allocated but not used by a file. This should not 534happen in cjpeg or djpeg, since we enable a signal catcher to explicitly close 535temp files before exiting. But if you use the JPEG library with your own 536code, be sure to supply a signal catcher, or else use a different 537system-dependent memory manager. 538 539 540Cray: 541 542Should you be so fortunate as to be running JPEG on a Cray YMP, there is a 543compiler bug in old versions of Cray's Standard C (prior to 3.1). If you 544still have an old compiler, you'll need to insert a line reading 545"#pragma novector" just before the loop 546 for (i = 1; i <= (int) htbl->bits[l]; i++) 547 huffsize[p++] = (char) l; 548in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c). 549[This bug may or may not still occur with the current IJG code, but it's 550probably a dead issue anyway...] 551 552 553HP-UX: 554 555If you have HP-UX 7.05 or later with the "software development" C compiler, 556you should run the compiler in ANSI mode. If using the configure script, 557say 558 ./configure CC='cc -Aa' 559(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add 560"-Aa" to the CFLAGS line in the makefile. 561 562If you have a pre-7.05 system, or if you are using the non-ANSI C compiler 563delivered with a minimum HP-UX system, then you must use makefile.unix 564(and do NOT add -Aa); or just run configure without the CC option. 565 566On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior 567to A.08.07. If you get complaints about "not a typedef name", you'll have to 568use makefile.unix, or run configure without the CC option. 569 570 571Macintosh, MPW: 572 573We don't directly support MPW in the current release, but Larry Rosenstein 574ported an earlier version of the IJG code without very much trouble. There's 575useful notes and conversion scripts in his kit for porting PBMPLUS to MPW. 576You can obtain the kit by FTP to ftp.apple.com, files /pub/lsr/pbmplus-port*. 577 578 579Macintosh, Metrowerks CodeWarrior: 580 581Metrowerks release DR2 has problems with the IJG code; don't use it. Release 582DR3.5 or later should be OK. 583 584The command-line-style interface can be used by defining USE_CCOMMAND and 585TWO_FILE_COMMANDLINE (see next entry for more details). 586 587On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended 588float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power 589of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. 590 591 592Macintosh, Think C: 593 594The supplied user-interface files (cjpeg.c and djpeg.c) are set up to provide 595a Unix-style command line interface. You can use this interface on the Mac 596by means of Think's ccommand() library routine. However, a much better 597Mac-style user interface has been prepared by Jim Brunner. You can obtain 598the additional source code needed for that user interface by FTP to 599sumex-aim.stanford.edu, file /info-mac/dev/src/jpeg-convert-c.hqx. Jim's 600documentation also includes more detailed build instructions for Think C. 601(Jim is working on updating this code to work with v5 of the IJG library, 602but it wasn't ready as of v5 release time. Should be out before too long.) 603 604If you want to build the minimal command line version, proceed as follows. 605You'll have to prepare project files for the programs; we don't include any 606in the distribution since they are not text files. Use the file lists in 607any of the supplied makefiles as a guide. Also add the ANSI and Unix C 608libraries in a separate segment. You may need to divide the JPEG files into 609more than one segment; we recommend dividing compression and decompression 610modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is 611called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout 612don't handle binary data correctly. 613 614On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float. 615jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2. 616Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint. 617 618 619MIPS R3000: 620 621MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O 622if you have that compiler version. (Use "cc -V" to check the version.) 623Note that the R3000 chip is found in workstations from DEC and others. 624 625 626MS-DOS, generic comments for 16-bit compilers: 627 628The IJG code is designed to be compiled in 80x86 "small" or "medium" memory 629models (i.e., data pointers are 16 bits unless explicitly declared "far"; 630code pointers can be either size). You may be able to use small model to 631compile cjpeg or djpeg by itself, but you will probably have to use medium 632model for any larger application. This won't make much difference in 633performance. You *will* take a noticeable performance hit if you use a 634large-data memory model, and you should avoid "huge" model if at all 635possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use 636a small-data memory model; be sure it is NOT defined if you use a large-data 637model. (The supplied makefiles and jconfig files for Borland and Microsoft C 638compile in medium model and define NEED_FAR_POINTERS.) 639 640The DOS-specific memory manager, jmemdos.c, should be used if possible. 641It needs some assembly-code routines which are in jmemdosa.asm; make sure 642your makefile assembles that file and includes it in the library. If you 643don't have a suitable assembler, you can get pre-assembled object files for 644jmemdosa by FTP from ftp.uu.net: graphics/jpeg/jdosaobj.zip. 645 646When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set 647MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your 648C library's far-heap malloc() can't allocate blocks that large, reduce 649MAX_ALLOC_CHUNK to whatever it can handle. 650 651If you can't use jmemdos.c for some reason --- for example, because you 652don't have an assembler to assemble jmemdosa.asm --- you'll have to fall 653back to jmemansi.c or jmemname.c. You'll probably still need to set 654MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc() 655more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c, 656you will have to compile in a large-data memory model in order to get the 657right stdio library. Too bad. 658 659wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB 660work area to hold the comment text. If your C library's malloc can't 661handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c. 662 663Most MS-DOS compilers treat stdin/stdout as text files, so you must use 664two-file command line style. But if your compiler has either fdopen() or 665setmode(), you can use one-file style if you like. To do this, define 666USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode. 667(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You 668should test that I/O through stdin/stdout produces the same results as I/O 669to explicitly named files... the "make test" procedures in the supplied 670makefiles do NOT use stdin/stdout. 671 672 673MS-DOS, generic comments for 32-bit compilers: 674 675None of the above comments about memory models apply if you are using a 67632-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you 677should use one if you have it, as performance will be much better than 6788086-compatible code!) For flat-memory-space compilers, do NOT define 679NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the 680environment supplies adequate virtual memory, otherwise use jmemansi.c or 681jmemname.c. 682 683You'll still need to be careful about binary I/O through stdin/stdout. 684See the last paragraph of the previous section. 685 686 687MS-DOS, Borland C: 688 689If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. 690jconfig.bcc includes #define USE_SETMODE. (fdopen does not work correctly.) 691 692Be sure to convert all the source files to DOS text format (CR/LF newlines). 693Although Borland C will often work OK with unmodified Unix (LF newlines) 694source files, sometimes it will give bogus compile errors. 695"Illegal character '#'" is the most common such error. 696 697 698MS-DOS, DJGPP: 699 700Use a recent version of DJGPP (1.11 or better). If you prefer two-file 701command line style, change the supplied jconfig.dj to define 702TWO_FILE_COMMANDLINE. makefile.dj is set up to generate only COFF files 703(cjpeg, djpeg, etc) when you say make. After testing, say "make exe" to 704make executables with stub.exe, or "make standalone" if you want executables 705that include go32. You will probably need to tweak the makefile's pointer to 706go32.exe to do "make standalone". 707 708 709MS-DOS, Microsoft C: 710 711If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE. 712jconfig.mc6 includes #define USE_SETMODE. (fdopen does not work correctly.) 713 714Old versions of MS C fail with an "out of macro expansion space" error 715because they can't cope with the macro TRACEMS8 (defined in jerror.h). 716If this happens to you, the easiest solution is to change TRACEMS8 to 717expand to nothing. You'll lose the ability to dump out JPEG coefficient 718tables with djpeg -debug -debug, but at least you can compile. 719 720Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn 721off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it 722still generates bad code if you enable loop optimizations (-Ol or -Ox). 723 724MS C 8.0 reportedly fails to compile jquant1.c if optimization is turned off 725(yes, off). 726 727 728SGI: 729 730Set "AR2= ar -ts" rather than "AR2= ranlib" in the Makefile. If you are 731using configure, you should say 732 ./configure RANLIB='ar -ts' 733 734 735VMS: 736 737On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1" 738qualifier with MMS when building the JPEG package. 739 740VAX/VMS v5.5-1 may have problems with the test step of the build procedure 741reporting differences when it compares the original and test GIF and JPG 742images. If the error points to the last block of the files, it is most 743likely bogus and may be safely ignored. It seems to be because the files 744are Stream_LF and Backup/Compare has difficulty with the (presumably) null 745padded files. This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1. 746