home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / jpeg / jpegv4a.tar / SETUP < prev    next >
Text File  |  1993-02-18  |  28KB  |  551 lines

  1. SETUP instructions for the Independent JPEG Group's JPEG software
  2. =================================================================
  3.  
  4. This file explains how to configure and compile the JPEG software.  We have
  5. tried to make this software extremely portable and flexible, so that it can be
  6. adapted to almost any environment.  The downside of this decision is that the
  7. installation process is not very automatic; you will need at least a little
  8. familiarity with C programming and program build procedures for your system.
  9.  
  10. This file contains general instructions, then sections of specific hints for
  11. certain systems.  You may save yourself considerable time if you scan the
  12. whole file before starting to do anything.
  13.  
  14. Before installing the software you must unpack the distributed source code.
  15. Since you are reading this file, you have probably already succeeded in this
  16. task.  However, there is one potential trap if you are on a non-Unix system:
  17. you may need to convert these files to the local standard text file format
  18. (for example, if you are on MS-DOS you probably have to convert LF end-of-line
  19. to CR/LF).  If so, apply the conversion to all the files EXCEPT those whose
  20. names begin with "test".  The test files contain binary data; if you change
  21. them in any way then the self-test will give bad results.
  22.  
  23.  
  24. STEP 1: PREPARE A MAKEFILE
  25. ==========================
  26.  
  27. First, select a makefile and copy it to "Makefile" (or whatever your version
  28. of make uses as the default makefile name; for example, "makefile.mak" for
  29. old versions of Borland C).  We include several standard makefiles in the
  30. distribution:
  31.  
  32.     makefile.ansi:    for Unix systems with ANSI-compatible C compilers.
  33.     makefile.unix:    for Unix systems with non-ANSI C compilers.
  34.     makefile.mc5:    for Microsoft C 5.x under MS-DOS.
  35.     makefile.mc6:    for Microsoft C 6.x and up under MS-DOS.
  36.     makefile.bcc:    for Borland C (Turbo C) under MS-DOS.
  37.     makefile.icc:    for Intel's Code Builder C under MS-DOS.
  38.     makefile.manx:    for Manx Aztec C on Amigas.
  39.     makefile.sas:    for SAS C on Amigas.
  40.     makcjpeg.st:    project file for Atari ST/STE/TT Pure C or Turbo C.
  41.     makdjpeg.st:    project file for Atari ST/STE/TT Pure C or Turbo C.
  42.     makljpeg.st:    project file for Atari ST/STE/TT Pure C or Turbo C.
  43.     makefile.mms:    for VAX/VMS systems with MMS.
  44.     makefile.vms:    for VAX/VMS systems without MMS.
  45.  
  46. If you don't see a makefile for your system, we recommend starting from either
  47. makefile.ansi or makefile.unix, depending on whether your compiler accepts
  48. ANSI C or not.  Actually you should start with makefile.ansi whenever your
  49. compiler supports ANSI-style function definitions; you don't need full ANSI
  50. compatibility.  The difference between the two makefiles is that makefile.unix
  51. preprocesses the source code to convert function definitions to old-style C.
  52. (Our thanks to Peter Deutsch of Aladdin Enterprises for the ansi2knr program.)
  53.  
  54. If you don't know whether your compiler supports ANSI-style function
  55. definitions, then take a look at ckconfig.c.  It is a test program that will
  56. help you figure out this fact, as well as some other facts you'll need in
  57. later steps.  You must compile and execute ckconfig.c by hand; the makefiles
  58. don't provide any support for this.  ckconfig.c may not compile the first try
  59. (in fact, the whole idea is for it to fail if anything is going to).  If you
  60. get compile errors, fix them by editing ckconfig.c according to the directions
  61. given in ckconfig.c.  Once you get it to run, select a makefile according to
  62. the advice it prints out, and make any other changes it recommends.
  63.  
  64. Look over the selected Makefile and adjust options as needed.  In particular
  65. you may want to change the CC and CFLAGS definitions.  For instance, if you
  66. are using GCC, set CC=gcc.  If you had to use any compiler switches to get
  67. ckconfig.c to work, make sure the same switches are in CFLAGS.
  68.  
  69. If you are on a system that doesn't use makefiles, you'll need to set up
  70. project files (or whatever you do use) to compile all the source files and
  71. link them into executable files cjpeg and djpeg.  See the file lists in any of
  72. the makefiles to find out which files go into each program.  As a last resort,
  73. you can make a batch script that just compiles everything and links it all
  74. together; makefile.vms is an example of this (it's for VMS systems that have
  75. no make-like utility).
  76.  
  77.  
  78. STEP 2: EDIT JCONFIG.H
  79. ======================
  80.  
  81. Look over jconfig.h and adjust #defines to reflect the properties of your
  82. system and C compiler.  If you prefer, you can usually leave jconfig.h
  83. unmodified and add -Dsymbol switches to the Makefile's CFLAGS definition.
  84. (This is already done if you used a compiler-specific makefile in step 1.)
  85. However, putting the switches in the Makefile is a bad idea if you are going
  86. to incorporate the JPEG software into other programs --- you'd need to include
  87. the same -D switches in the other programs' Makefiles.  Better to change
  88. jconfig.h.
  89.  
  90. If you have an ANSI-compliant C compiler, no changes should be necessary
  91. except perhaps for RIGHT_SHIFT_IS_UNSIGNED and TWO_FILE_COMMANDLINE.  For
  92. older compilers other changes may be needed, depending on what ANSI features
  93. are supported.
  94.  
  95. If you don't know enough about C programming to understand the questions in
  96. jconfig.h, then use ckconfig.c to figure out what to change.  (See description
  97. of ckconfig.c in step 1.)
  98.  
  99. A note about TWO_FILE_COMMANDLINE: defining this selects the command line
  100. syntax in which the input and output files are both named on the command line.
  101. If it's not defined, the output image goes to standard output, and the input
  102. can optionally come from standard input.  You MUST use two-file style on any
  103. system that doesn't cope well with binary data fed through stdin/stdout; this
  104. is true for most MS-DOS compilers, for example.  If you're not on a Unix
  105. system, it's probably safest to assume you need two-file style.  (But if your
  106. compiler provides either the Posix-standard fdopen() library routine or a
  107. Microsoft-compatible setmode() routine, you can use the Unix command line
  108. style, by defining USE_FDOPEN or USE_SETMODE respectively.)
  109.  
  110.  
  111. STEP 3: SELECT SYSTEM-DEPENDENT FILES
  112. =====================================
  113.  
  114. A few places in the JPEG software are so system-dependent that we have to
  115. provide several different implementations and let you select the one you need.
  116.  
  117. The only system-dependent file in the current version is jmemsys.c.  This file
  118. controls use of temporary files for big images that won't fit in main memory.
  119. You'll notice there is no file named jmemsys.c in the distribution; you must
  120. select one of the provided versions and copy, rename, or link it to jmemsys.c.
  121. Here are the provided versions:
  122.  
  123.     jmemansi.c    This is a reasonably portable version that should
  124.             work on most ANSI and near-ANSI C compilers.  It uses
  125.             the ANSI-standard library routine tmpfile(), which not
  126.             all non-ANSI systems have.  On some systems tmpfile()
  127.             may put the temporary file in a non-optimal location;
  128.             if you don't like what it does, use jmemname.c.
  129.  
  130.     jmemname.c    This version constructs the temp file name by itself.
  131.             For anything except a Unix machine, you'll need to
  132.             configure the select_file_name() routine appropriately;
  133.             see the comments near the head of jmemname.c.
  134.             If you use this version, define NEED_SIGNAL_CATCHER
  135.             in jconfig.h or in the Makefile to make sure the temp
  136.             files are removed if the program is aborted.
  137.  
  138.     jmemnobs.c    (That stands for No Backing Store :-).  This will
  139.             compile on almost any system, but it assumes you
  140.             have enough main memory or virtual memory to hold
  141.             the biggest images you need to work with.
  142.  
  143.     jmemdos.c    This should be used in most MS-DOS installations; see
  144.             the system-specific notes about MS-DOS for more info.
  145.             IMPORTANT: if you use this, also copy jmemdos.h to
  146.             jmemsys.h, replacing the standard version.  ALSO,
  147.             include the assembly file jmemdosa.asm in the programs.
  148.             (This last is already done if you used one of the
  149.             supplied MS-DOS-specific makefiles.)
  150.  
  151. If you have plenty of (real or virtual) main memory, just use jmemnobs.c.
  152. "Plenty" means at least ten bytes for every pixel in the largest images
  153. you plan to process, so a lot of systems don't meet this criterion.
  154. If yours doesn't, try jmemansi.c first.  If that doesn't compile, you'll have
  155. to use jmemname.c; be sure to adjust select_file_name() for local conditions.
  156. You may also need to change unlink() to remove() in close_backing_store().
  157.  
  158. Except with jmemnobs.c, you need to adjust the #define DEFAULT_MAX_MEM to a
  159. reasonable value for your system (either by editing jmemsys.c, or by adding
  160. a -D switch to the Makefile).  This value limits the amount of data space the
  161. program will attempt to allocate.  Code and static data space isn't counted,
  162. so the actual memory needs for cjpeg or djpeg are typically 100 to 150Kb more
  163. than the max-memory setting.  Larger max-memory settings reduce the amount of
  164. I/O needed to process a large image, but too large a value can result in
  165. "insufficient memory" failures.  On most Unix machines (and other systems with
  166. virtual memory), just set DEFAULT_MAX_MEM to several million and forget it.
  167. At the other end of the spectrum, for MS-DOS machines you probably can't go
  168. much above 300K to 400K.  (On MS-DOS the value refers to conventional memory;
  169. extended/expanded memory is handled separately by jmemdos.c.)
  170.  
  171.  
  172. STEP 4: MAKE
  173. ============
  174.  
  175. Now you should be able to "make" the software.
  176.  
  177. If you have trouble with missing system include files or inclusion of the
  178. wrong ones, look at jinclude.h (or use ckconfig.c, if you are not a C expert).
  179.  
  180. If your compiler complains about big_sarray_control and big_barray_control
  181. being undefined structures, you should be able to shut it up by adding
  182. -DINCOMPLETE_TYPES_BROKEN to CFLAGS (or add #define INCOMPLETE_TYPES_BROKEN
  183. to jconfig.h).  If you don't have a getenv() library routine, define NO_GETENV.
  184.  
  185. There are a fair number of routines that do not use all of their parameters;
  186. some compilers will issue warnings about this, which you can ignore.  Any
  187. other warning deserves investigation.
  188.  
  189.  
  190. STEP 5: TEST
  191. ============
  192.  
  193. As a quick test of functionality we've included a small sample image in
  194. several forms:
  195.     testorig.jpg    A reduced section of the well-known Lenna picture.
  196.     testimg.ppm    The output of djpeg testorig.jpg
  197.     testimg.gif    The output of djpeg -gif testorig.jpg
  198.     testimg.jpg    The output of cjpeg testimg.ppm
  199. (The two .jpg files aren't identical since JPEG is lossy.)  If you can
  200. generate duplicates of the testimg.* files then you probably have working
  201. programs.
  202.  
  203. With most of the makefiles, "make test" will perform the necessary
  204. comparisons.  If you started with makefile.ansi or makefile.unix, and you
  205. defined TWO_FILE_COMMANDLINE, then change the makefile's test script to use
  206. two-file syntax (i.e., delete the ">" character from the invocations of cjpeg
  207. and djpeg).  The other makefiles will work with either command-line syntax.
  208.  
  209. If you're using a makefile that doesn't provide the test option, run djpeg and
  210. cjpeg by hand to generate testout.ppm, testout.gif, and testout.jpg, then
  211. compare these to testimg.* with whatever binary file comparison tool you have.
  212. The files should be bit-for-bit identical.
  213.  
  214. If the cjpeg test run fails with "Missing Huffman code table entry", it's a
  215. good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED.  Go back to step 2
  216. and run ckconfig.c.  (This is a good plan for any other test failure, too.)
  217.  
  218. If you are using Unix (one-file) command line style on a non-Unix system,
  219. it's a good idea to check that binary I/O through stdin/stdout actually works.
  220. You should get the same results from "djpeg <testorig.jpg >out.ppm" as from
  221. "djpeg -outfile out.ppm  testorig.jpg".  Note that the non-Unix makefiles use
  222. the latter style and therefore do not exercise stdin/stdout.  If this test
  223. fails, try recompiling jcmain.c & jdmain.c with USE_SETMODE and/or USE_FDOPEN.
  224.  
  225. If your choice of jmemsys.c was anything other than jmemnobs.c, you should
  226. test that temporary-file usage works.  Try "djpeg -gif -max 0 testorig.jpg"
  227. and make sure its output matches testimg.gif.  If you have any really large
  228. images handy, try compressing them with -optimize and/or decompressing with
  229. -gif to make sure your DEFAULT_MAX_MEM setting is not too large.
  230.  
  231. NOTE: this is far from an exhaustive test of the JPEG software; some modules,
  232. such as 1-pass color quantization, are not exercised at all.  It's just a quick
  233. test to give you some confidence that you haven't missed something major.
  234.  
  235.  
  236. STEP 6: INSTALLATION
  237. ====================
  238.  
  239. Once you're done with the above steps, you can install the software by copying
  240. the executable files (cjpeg and djpeg) to wherever you normally install
  241. programs.  On Unix systems, you'll also want to put cjpeg.1 and djpeg.1 in the
  242. corresponding manual directory.  (The makefiles don't support this step since
  243. there's such a wide variety of installation procedures on different systems.)
  244.  
  245. To learn to use the programs, read the file USAGE (or manual pages cjpeg(1)
  246. and djpeg(1) on Unix).  Note that the man pages cjpeg.1/djpeg.1 only describe
  247. the Unix-style command line syntax; if you want to use these files with a
  248. version that uses two-file command line syntax, you'll have to modify the text
  249. accordingly.  The USAGE file describes both styles.
  250.  
  251.  
  252. OPTIMIZATION
  253. ============
  254.  
  255. Unless you own a Cray, you'll probably be interested in making the JPEG
  256. software go as fast as possible.  This section covers some machine-dependent
  257. optimizations you may want to try.  We suggest that before trying any of this,
  258. you first get the basic installation to pass the self-test (step 5 above).
  259. Repeat the self-test after any optimization to make sure that you haven't
  260. broken anything.
  261.  
  262. The JPEG DCT routines perform a lot of multiplications.  These multiplications
  263. must yield 32-bit results, but none of their input values are more than 16
  264. bits wide.  On many machines, notably the 680x0 and 80x86 CPUs, a 16x16=>32
  265. bit multiply instruction is faster than a full 32x32=>32 bit multiply.
  266. Unfortunately there is no portable way to specify such a multiplication in C,
  267. but some compilers can generate one when you use the right combination of
  268. casts.  See the MULTIPLY macro definitions in jfwddct.c and jrevdct.c.
  269. If your compiler makes "int" be 32 bits and "short" be 16 bits, defining
  270. SHORTxSHORT_32 is fairly likely to work.  When experimenting with alternate
  271. definitions, be sure to test not only whether the code still works (use the
  272. self-test step), but also whether it is actually faster --- on some compilers,
  273. alternate definitions may compute the right answer, yet be slower than the
  274. default.  Timing cjpeg on a large PPM input file is the best way to check
  275. this, as the DCT will be the largest fraction of the runtime in that mode.
  276. (Note: some of the distributed compiler-specific makefiles already contain
  277. -D switches to select an appropriate MULTIPLY definition.)
  278.  
  279. If access to "short" arrays is slow on your machine, it may be a win to define
  280. type DCTELEM as int rather than as JCOEF (which is normally defined as short).
  281. This will cause the DCT routines to operate on int arrays instead of short
  282. arrays.  If shorts are slow and you have lots of memory to burn, you might
  283. even make JCOEF itself be int.
  284.  
  285. If your compiler can compile function calls in-line, make sure the INLINE
  286. macro in jconfig.h is defined as the keyword that marks a function
  287. inline-able.  Some compilers have a switch that tells the compiler to inline
  288. any function it thinks is profitable (e.g., -finline-functions for gcc).
  289. Enabling such a switch is likely to make the compiled code bigger but faster.
  290.  
  291. In general, it's worth trying the maximum optimization level of your compiler,
  292. and experimenting with any optional optimizations such as loop unrolling.
  293. (Unfortunately, far too many compilers have optimizer bugs ... be prepared to
  294. back off if the code fails self-test.)  If you do any experimentation along
  295. these lines, please report the optimal settings to jpeg-info@uunet.uu.net so
  296. we can mention them in future releases.  Be sure to specify your machine and
  297. compiler version.
  298.  
  299.  
  300. OPTIONAL STUFF
  301. ==============
  302.  
  303. Progress monitor:
  304.  
  305. If you like, you can #define PROGRESS_REPORT (in jconfig.h or in the Makefile)
  306. to enable display of percent-done progress reports.  The routines provided in
  307. jcmain.c/jdmain.c merely print percentages to stderr, but you can customize
  308. them to do something fancier.
  309.  
  310. Utah RLE file format support:
  311.  
  312. We distribute the software with support for RLE image files (Utah Raster
  313. Toolkit format) disabled, because the RLE support won't compile without the
  314. Utah library.  If you have URT version 3.0, you can enable RLE support as
  315. follows:
  316.     1.  #define RLE_SUPPORTED in jconfig.h or in the Makefile.
  317.     2.  Add a -I option to CFLAGS in the Makefile for the directory
  318.         containing the URT .h files (typically the "include"
  319.         subdirectory of the URT distribution).
  320.     3.  Add -L... -lrle to LDLIBS in the Makefile, where ... specifies
  321.         the directory containing the URT "librle.a" file (typically the
  322.         "lib" subdirectory of the URT distribution).
  323.  
  324. JPEG library:
  325.  
  326. If you want to incorporate the JPEG code as subroutines in a larger program,
  327. we recommend that you make libjpeg.a, then link that into your surrounding
  328. program.  See file README for more info.
  329.  
  330. CAUTION: When you use the JPEG code as subroutines, we recommend that you make
  331. any required configuration changes by modifying jconfig.h, not by adding -D
  332. switches to the Makefile.  Otherwise you must be sure to provide the same -D
  333. switches when compiling any program that includes the JPEG .h files, to ensure
  334. that the parameter structures are interpreted the same way.  (This is only
  335. critical for the first few symbols mentioned in jconfig.h, down through
  336. NEED_FAR_POINTERS.)
  337.  
  338. Removing code:
  339.  
  340. If you need to make a smaller version of the JPEG software, some optional
  341. functions can be removed at compile time.  See the xxx_SUPPORTED #defines in
  342. jconfig.h.  If at all possible, we recommend that you leave in decoder support
  343. for all valid JPEG files, to ensure that you can read anyone's output.
  344. Restricting your encoder, or removing optional functions like block smoothing,
  345. won't hurt compatibility.  Taking out support for image file formats that you
  346. don't use is the most painless way to make the programs smaller.
  347.  
  348.  
  349. NOTES FOR SPECIFIC SYSTEMS
  350. ==========================
  351.  
  352. We welcome reports on changes needed for systems not mentioned here.
  353. Submit 'em to jpeg-info@uunet.uu.net.  Also, if ckconfig.c is wrong about
  354. how to configure the JPEG software for your system, please let us know.
  355.  
  356.  
  357. Amiga:
  358.  
  359. Makefiles are provided for Manx Aztec C and SAS C.  I have also heard from
  360. people who have compiled with the free DICE compiler, using makefile.ansi as a
  361. starting point (set "CC= dcc" and "CFLAGS= -c -DAMIGA -DTWO_FILE_COMMANDLINE
  362. -DNEED_SIGNAL_CATCHER" in the makefile).  For all compilers, we recommend you
  363. use jmemname.c as the system-dependent memory manager.  Assuming you have
  364. -DAMIGA in the makefile, jmemname.c will put temporary files in JPEGTMP:.
  365. Change jmemname.c if you don't like this.
  366.  
  367.  
  368. Atari:
  369.  
  370. The project files provided should work as-is with Pure C.  For Turbo C, change
  371. library filenames "PC..." to "TC..." in the project files for cjpeg.ttp and
  372. djpeg.ttp.  Don't forget to select a jmemsys.c file, see Step 3 (we recommend
  373. jmemansi.c).  Also adjust the DEFAULT_MAX_MEM setting --- you probably want it
  374. to be a couple hundred K less than your normal free memory.  Note that you
  375. must make jpeg.lib before making cjpeg.ttp or cjpeg.ttp.  You'll have to
  376. perform the self-test (Step 5) by hand.
  377.  
  378. There is a bug in some older versions of the Turbo C library which causes the
  379. space used by temporary files created with "tmpfile()" not to be freed after
  380. an abnormal program exit.  If you check your disk afterwards, you will find
  381. cluster chains that are allocated but not used by a file.  This should not
  382. happen in cjpeg or djpeg, since we enable a signal catcher to explicitly close
  383. temp files before exiting.  But if you use the JPEG library with your own
  384. code, be sure to supply a signal catcher, or else use a different
  385. system-dependent memory manager.
  386.  
  387.  
  388. Cray:
  389.  
  390. Should you be so fortunate as to be running JPEG on a Cray YMP, there is a
  391. compiler bug in Cray's Standard C versions prior to 3.1.  You'll need to
  392. insert a line reading "#pragma novector" just before the loop    
  393.     for (i = 1; i <= (int) htbl->bits[l]; i++)
  394.       huffsize[p++] = (char) l;
  395. in fix_huff_tbl (in V4A, line 42 of jchuff.c and line 39 of jdhuff.c).  The
  396. usual symptom of not adding this line is a core-dump.  See Cray's SPR 48222.
  397.  
  398.  
  399. HP/Apollo DOMAIN:
  400.  
  401. With system release 10.4 or later, makefile.ansi should work OK.  If you have
  402. version 10.3.anything, you need to figure out whether you have the ANSI C
  403. compiler (version 6.7 or later) and whether you've installed the ANSI C
  404. include files (if so, the first line of <stdio.h> will mention ANSI C).
  405. If you have the ANSI C compiler but not the ANSI C include files, use
  406. makefile.ansi and add -DNONANSI_INCLUDES to CFLAGS.  If you have both,
  407. then makefile.ansi should work as is.  If neither, use makefile.unix.
  408.  
  409.  
  410. HP-UX:
  411.  
  412. If you have HP-UX 7.05 or later with the "software development" C compiler,
  413. then you can use makefile.ansi.  Add "-Aa" to the CFLAGS line in the makefile
  414. to make the compiler work in ANSI mode.  If you have a pre-7.05 system, or if
  415. you are using the non-ANSI C compiler delivered with a minimum HP-UX 8.0
  416. system, then you must use makefile.unix (and do NOT add -Aa).  Also, adding
  417. "-lmalloc" to LDLIBS is recommended if you have libmalloc.a (it seems not to
  418. be present in minimum 8.0).
  419.  
  420. On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior
  421. to A.08.07.  If you get complaints about "not a typedef name", you'll have to
  422. convert the code to K&R style (i.e., use makefile.unix).
  423.  
  424.  
  425. Macintosh MPW:
  426.  
  427. We don't directly support MPW in the current release, but Larry Rosenstein
  428. reports that the JPEG code can be ported without very much trouble.  There's
  429. useful notes and conversion scripts in his kit for porting PBMPLUS to MPW.
  430. You can obtain the kit by FTP to ftp.apple.com, file /pub/lsr/pbmplus-port*.
  431.  
  432.  
  433. Macintosh Think C:
  434.  
  435. You'll have to prepare project files for cjpeg and djpeg; we don't include
  436. those in the distribution since they are not text files.  The COBJECTS and
  437. DOBJECTS lists in makefile.unix show which files should be included in each
  438. project.  Also add the ANSI and Unix C libraries in a separate segment.  You
  439. may need to divide the JPEG files into more than one segment; you can do this
  440. pretty much as you please.
  441.  
  442. If you have Think C version 5.0 you need not modify jconfig.h; instead you
  443. should turn on both the ANSI Settings and Language Extensions option buttons
  444. (so that both __STDC__ and THINK_C are predefined).  With version 4.0 you must
  445. edit jconfig.h.  (You can #define HAVE_STDC to do the right thing for all
  446. options except const; you must also #define const.)
  447.  
  448. jcmain and jdmain are set up to provide the usual command-line interface
  449. by means of Think's ccommand() library routine.  A more Mac-like interface
  450. is in the works.
  451.  
  452.  
  453. MS-DOS, generic comments:
  454.  
  455. The JPEG code is designed to be compiled with 80x86 "small" or "medium" memory
  456. models (i.e., data pointers are 16 bits unless explicitly declared "far"; code
  457. pointers can be either size).  You should be able to use small model to
  458. compile cjpeg or djpeg by itself, but you will probably have to go to medium
  459. model if you include the JPEG code in a larger application.  This shouldn't
  460. hurt performance much.  You *will* take a noticeable performance hit if you
  461. compile in a large-data memory model, and you should avoid "huge" model if at
  462. all possible.  Be sure that NEED_FAR_POINTERS is defined by jconfig.h or by
  463. the Makefile if you use a small-data model; be sure it is NOT defined if you
  464. use a large-data memory model.  (As distributed, jconfig.h defines
  465. NEED_FAR_POINTERS if MSDOS is defined.)
  466.  
  467. The DOS-specific memory manager, jmemdos.c, should be used if possible.
  468. (Be sure to install jmemdos.h and jmemdosa.asm along with it.)  If you
  469. can't use jmemdos.c for some reason --- for example, because you don't have
  470. a Microsoft-compatible assembler to assemble jmemdosa.asm --- you'll have
  471. to fall back to jmemansi.c or jmemname.c.  IMPORTANT: if you use either of
  472. the latter two files, you will have to compile in a large-data memory model
  473. in order to get the right stdio library.  Too bad.
  474.  
  475. None of the above advice applies if you are using a 386 flat-memory-space
  476. environment, such as DJGPP or Watcom C.  (And you should use one if you have
  477. it, as performance will be much better than 8086-compatible code!)  For
  478. flat-memory-space compilers, do NOT define NEED_FAR_POINTERS, and do NOT use
  479. jmemdos.c.  Use jmemnobs.c if the environment supplies adequate virtual
  480. memory, otherwise use jmemansi.c or jmemname.c.
  481.  
  482. Most MS-DOS compilers treat stdin/stdout as text files, so you must use
  483. two-file command line style.  But if your compiler has either fdopen() or
  484. setmode(), you can use one-file style if you like.  To do this, define
  485. USE_FDOPEN or USE_SETMODE so that stdin/stdout will be set to binary mode.
  486. (USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.)  You
  487. should test that I/O through stdin/stdout produces the same results as I/O
  488. to explicitly named files... the "make test" procedures in the DOS-specific
  489. makefiles do NOT use stdin/stdout.
  490.  
  491. If you add more switches to CFLAGS in the DOS-specific makefiles, you are
  492. likely to run up against DOS' 128-byte command line length limit.  In that
  493. case, remove some "-Dsymbol" switches from CFLAGS and instead put
  494. corresponding "#define symbol" lines at the head of jinclude.h.
  495.  
  496.  
  497. MS-DOS, Borland C:
  498.  
  499. Be sure to convert all the source files to DOS text format (CR/LF newlines).
  500. Although Borland C will often work OK with unmodified Unix (LF newlines)
  501. source files, sometimes it will give bogus compile errors.
  502. "Illegal character '#'" is the most common such error.
  503.  
  504. Some versions of Borland's MAKE erroneously display the warning message about
  505. creating jmemsys.c, even after you have done so.  If this happens to you,
  506. delete the four lines beginning with "jmemsys.c:" from the Makefile.
  507.  
  508. If you want one-file command line style, define USE_SETMODE.  fdopen() does
  509. not work correctly.
  510.  
  511.  
  512. MS-DOS, DJGPP:
  513.  
  514. Use makefile.ansi and jmemnobs.c, and put "-UMSDOS" in CFLAGS to undo the
  515. compiler's automatic definition of MSDOS.  Also put either "-DUSE_SETMODE" or
  516. "-DTWO_FILE_COMMANDLINE" in CFLAGS, depending on whether you prefer one-file
  517. or two-file command line style.  You'll also need to put the object-file lists
  518. into response files in order to circumvent DOS's 128-byte command line length
  519. limit at the final linking step.
  520.  
  521.  
  522. MS-DOS, Microsoft C:
  523.  
  524. Old versions of MS C fail with an "out of macro expansion space" error
  525. because they can't cope with the macro TRACEMS8 (defined in jpegdata.h).
  526. If this happens to you, the easiest solution is to change TRACEMS8 to
  527. expand to nothing.  You'll lose the ability to dump out JPEG coefficient
  528. tables with djpeg -debug -debug, but at least you can compile.
  529.  
  530. Original MS C 6.0 is buggy; it compiles incorrect code unless you turn off
  531. optimization (remove -O from CFLAGS).  That problem seems to have been fixed
  532. in 6.00A and later versions.  6.00A still generates a bogus "conditional
  533. expression is constant" warning in jrdppm.c, but the emitted code seems OK.
  534.  
  535. If you want one-file command line style, define USE_SETMODE.  fdopen() does
  536. not work correctly, at least not in 6.00A.
  537.  
  538.  
  539. SGI:
  540.  
  541. Use makefile.ansi, but set "AR2= ar -ts" rather than "AR2= ranlib".  Also
  542. make any changes recommended by ckconfig.c.
  543.  
  544.  
  545. Sun:
  546.  
  547. Don't forget to add -DBSD to CFLAGS.  If you are using GCC on SunOS 4.0.1 or
  548. earlier, you will need to add -DNONANSI_INCLUDES to CFLAGS (your compiler may
  549. be ANSI, but your system include files aren't).  I've gotten conflicting
  550. reports on whether this is still necessary on SunOS 4.1 or later.
  551.