home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / compresn / jpegv3sr / setup < prev    next >
Text File  |  1992-03-17  |  18KB  |  369 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 under MS-DOS.
  36.     makefile.bcc:  for Borland C (Turbo C) under MS-DOS.
  37.     makefile.pwc:  for Mix Software's Power C under MS-DOS.
  38.     makefile.manx: for Manx Aztec C on Amigas.
  39.     makefile.sas:  for SAS C on Amigas.
  40.     makefile.mms:  for VAX/VMS systems with MMS.
  41.     makefile.vms:  for VAX/VMS systems without MMS.
  42.  
  43. If you don't see a makefile for your system, we recommend starting from either
  44. makefile.ansi or makefile.unix, depending on whether your compiler accepts
  45. ANSI C or not.  Actually you should start with makefile.ansi whenever your
  46. compiler supports ANSI-style function definitions; you don't need full ANSI
  47. compatibility.  The difference between the two makefiles is that makefile.unix
  48. preprocesses the source code to convert function definitions to old-style C.
  49. (Our thanks to Peter Deutsch of Aladdin Enterprises for the ansi2knr program.)
  50.  
  51. If you don't know whether your compiler supports ANSI-style function
  52. definitions, then take a look at ckconfig.c.  It is a test program that will
  53. help you figure out this fact, as well as some other facts you'll need in
  54. later steps.  You must compile and execute ckconfig.c by hand; the makefiles
  55. don't provide any support for this.  ckconfig.c may not compile the first try
  56. (in fact, the whole idea is for it to fail if anything is going to).  If you
  57. get compile errors, fix them by editing ckconfig.c according to the directions
  58. given in ckconfig.c.  Once you get it to run, select a makefile according to
  59. the advice it prints out, and make any other changes it recommends.
  60.  
  61. Look over the selected Makefile and adjust options as needed.  In particular
  62. you may want to change the CC and CFLAGS definitions.  For instance, if you
  63. are using GCC, set CC=gcc.  If you had to use any compiler switches to get
  64. ckconfig.c to work, make sure the same switches are in CFLAGS.
  65.  
  66. If you are on a system that doesn't use makefiles, you'll need to set up
  67. project files (or whatever you do use) to compile all the source files and
  68. link them into executable files cjpeg and djpeg.  See the file lists in any of
  69. the makefiles to find out which files go into each program.  As a last resort,
  70. you can make a batch script that just compiles everything and links it all
  71. together; makefile.vms is an example of this (it's for VMS systems that have
  72. no make-like utility).
  73.  
  74.  
  75. STEP 2: EDIT JCONFIG.H
  76. ======================
  77.  
  78. Look over jconfig.h and adjust #defines to reflect the properties of your
  79. system and C compiler.  (If you prefer, you can usually leave jconfig.h
  80. unmodified and add -Dsymbol switches to the Makefile's CFLAGS definition.)
  81.  
  82. If you have an ANSI-compliant C compiler, no changes should be necessary
  83. except perhaps for RIGHT_SHIFT_IS_UNSIGNED and TWO_FILE_COMMANDLINE.  For
  84. older compilers other changes may be needed, depending on what ANSI features
  85. are supported.
  86.  
  87. If you don't know enough about C programming to understand the questions in
  88. jconfig.h, then use ckconfig.c to figure out what to change.  (See description
  89. of ckconfig.c in step 1.)
  90.  
  91. A note about TWO_FILE_COMMANDLINE: defining this selects the command line
  92. syntax in which the input and output files are both named on the command line.
  93. If it's not defined, the output image goes to standard output, and the input
  94. can optionally come from standard input.  You MUST use two-file style on any
  95. system that doesn't cope well with binary data fed through stdin/stdout; this
  96. is true for most MS-DOS compilers, for example.  If you're not on a Unix
  97. system, it's probably safest to assume you need two-file style.
  98.  
  99.  
  100. STEP 3: SELECT SYSTEM-DEPENDENT FILES
  101. =====================================
  102.  
  103. The only system-dependent file in the current version is jmemsys.c.  This file
  104. controls use of temporary files for big images that won't fit in main memory.
  105. You'll notice there is no file by that name in the distribution; you must
  106. select one of the provided versions and copy, rename, or link it to jmemsys.c.
  107. Here are the provided versions:
  108.  
  109.     jmemansi.c    This is a reasonably portable version that should
  110.             work on most ANSI and near-ANSI C compilers.  It uses
  111.             the ANSI-standard library routine tmpfile(), which not
  112.             all pre-ANSI systems have.  On some systems tmpfile()
  113.             may put the temporary file in a non-optimal location;
  114.             if you don't like what it does, use jmemname.c.
  115.  
  116.     jmemname.c    This version constructs the temp file name by itself.
  117.             For anything except a Unix machine, you'll need to
  118.             configure the select_file_name() routine appropriately;
  119.             see the comments near the head of jmemname.c.
  120.             If you use this version, define NEED_SIGNAL_CATCHER
  121.             in jconfig.h or in the Makefile to make sure the temp
  122.             files are removed if the program is aborted.
  123.  
  124.     jmemnobs.c    (That stands for No Backing Store :-).  This will
  125.             compile on almost any system, but it assumes you
  126.             have enough main memory or virtual memory to hold
  127.             the biggest images you need to work with.
  128.  
  129.     jmemdos.c    This should be used in most MS-DOS installations; see
  130.             the system-specific notes about MS-DOS for more info.
  131.             IMPORTANT: if you use this, also copy jmemdos.h to
  132.             jmemsys.h, replacing the standard version.  ALSO,
  133.             include the assembly file jmemdosa.asm in the programs.
  134.             (This last is already done if you used one of the
  135.             supplied MS-DOS-specific makefiles.)
  136.  
  137. If you have plenty of (real or virtual) main memory, just use jmemnobs.c.
  138. "Plenty" means at least ten bytes for every pixel in the largest images
  139. you plan to process, so a lot of systems don't meet this criterion.
  140. If yours doesn't, try jmemansi.c first.  If that doesn't compile, you'll have
  141. to use jmemname.c; be sure to adjust select_file_name() for local conditions.
  142. You may also need to change unlink() to remove() in close_backing_store().
  143.  
  144. Except with jmemnobs.c, you need to adjust the #define DEFAULT_MAX_MEM to a
  145. reasonable value for your system (either by editing jmemsys.c, or by adding
  146. a -D switch to the Makefile).  This value limits the amount of data space the
  147. program will attempt to allocate.  Code and static data space isn't counted,
  148. so the actual memory needs for cjpeg or djpeg are typically 100 to 150Kb more
  149. than the max-memory setting.  Larger max-memory settings reduce the amount of
  150. I/O needed to process a large image, but too large a value can result in
  151. "insufficient memory" failures.  On most Unix machines (and other systems with
  152. virtual memory), just set DEFAULT_MAX_MEM to several million and forget it.
  153. At the other end of the spectrum, for MS-DOS machines you probably can't go
  154. much above 300K to 400K.
  155.  
  156.  
  157. STEP 4: MAKE
  158. ============
  159.  
  160. Now you should be able to "make" the software.
  161.  
  162. If you have trouble with missing system include files or inclusion of the
  163. wrong ones, look at jinclude.h (or use ckconfig.c, if you are not a C expert).
  164.  
  165. If your compiler complains about big_sarray_control and big_barray_control
  166. being undefined structures, you should be able to shut it up by adding
  167. -DINCOMPLETE_TYPES_BROKEN to CFLAGS (or add #define INCOMPLETE_TYPES_BROKEN
  168. to jconfig.h).
  169.  
  170. There are a fair number of routines that do not use all of their parameters;
  171. some compilers will issue warnings about this, which you can ignore.  Any
  172. other warning deserves investigation.
  173.  
  174.  
  175. STEP 5: TEST
  176. ============
  177.  
  178. As a quick test of functionality we've included a small sample image in
  179. several forms:
  180.     testorig.jpg    A reduced section of the well-known Lenna picture.
  181.     testimg.ppm    The output of djpeg testorig.jpg
  182.     testimg.gif    The output of djpeg -G testorig.jpg
  183.     testimg.jpg    The output of cjpeg testimg.ppm
  184. (The two .jpg files aren't identical since JPEG is lossy.)  If you can
  185. generate duplicates of the testimg.* files then you probably have working
  186. programs.
  187.  
  188. With most of the makefiles, "make test" will perform the necessary
  189. comparisons.  If you're using a makefile that doesn't provide this option, run
  190. djpeg and cjpeg to generate testout.ppm, testout.gif, and testout.jpg, then
  191. compare these to testimg.* with whatever binary file comparison tool you have.
  192. The files should be bit-for-bit identical.
  193.  
  194. If your choice of jmemsys.c was anything other than jmemnobs.c, you should
  195. also test that temporary-file usage works.  Try "djpeg -G -m 0 testorig.jpg"
  196. and make sure its output matches testimg.gif.  If you have any really large
  197. images handy, try compressing them with -o and/or decompressing with -G
  198. to make sure your DEFAULT_MAX_MEM setting is not too large.
  199.  
  200. NOTE: this is far from an exhaustive test of the JPEG software; some modules,
  201. such as fast color quantization, are not exercised at all.  It's just a quick
  202. test to give you some confidence that you haven't missed something major.
  203.  
  204. If the test passes, you can copy the executable files cjpeg and djpeg to
  205. wherever you normally install programs.  Read the file USAGE to learn more
  206. about using the programs.
  207.  
  208.  
  209. OPTIONAL STUFF
  210. ==============
  211.  
  212. We distribute the software with support for RLE image files (Utah Raster
  213. Toolkit format) disabled, because the RLE support won't compile without the
  214. Utah library.  If you have URT version 3.0, you can enable RLE support as
  215. follows:
  216.     1.  #define RLE_SUPPORTED in jconfig.h or in the Makefile.
  217.     2.  Add a -I option to CFLAGS in the Makefile for the directory
  218.         containing the URT .h files (typically the "include"
  219.         subdirectory of the URT distribution).
  220.     3.  Add -L... -lrle to LDLIBS in the Makefile, where ... specifies
  221.         the directory containing the URT "librle.a" file (typically the
  222.         "lib" subdirectory of the URT distribution).
  223.  
  224. If you want to incorporate the JPEG code as subroutines in a larger program,
  225. we recommend that you make libjpeg.a.  (See file README for more info.)
  226.  
  227. CAUTION: When you use the JPEG code as subroutines, we recommend that you make
  228. any required configuration changes by modifying jconfig.h, not by adding -D
  229. switches to the Makefile.  Otherwise you must be sure to provide the same -D
  230. switches when compiling any program that includes the JPEG .h files.
  231.  
  232. If you need to make a smaller version of the JPEG software, some optional
  233. functions can be removed at compile time.  See the xxx_SUPPORTED #defines in
  234. jconfig.h.  If at all possible, we recommend that you leave in decoder support
  235. for all valid JPEG files, to ensure that you can read anyone's output.
  236. Restricting your encoder, or removing optional functions like block smoothing,
  237. won't hurt compatibility.  Taking out support for image file formats that you
  238. don't use is the most painless way to make the programs smaller.
  239.  
  240.  
  241. NOTES FOR SPECIFIC SYSTEMS
  242. ==========================
  243.  
  244. We welcome reports on changes needed for systems not mentioned here.
  245. Submit 'em to jpeg-info@uunet.uu.net.  Also, ckconfig.c is fairly new and not
  246. yet thoroughly tested; if it's wrong about how to configure the JPEG software
  247. for your system, please let us know.
  248.  
  249.  
  250. Amiga:
  251.  
  252. Makefiles are provided for Manx Aztec C and SAS C.  I have also heard from
  253. people who have compiled with the free DICE compiler, using makefile.ansi as a
  254. starting point (set "CC= dcc" and "CFLAGS= -c -DAMIGA -DTWO_FILE_COMMANDLINE
  255. -DNEED_SIGNAL_CATCHER" in the makefile).  For all compilers, we recommend you
  256. use jmemname.c as the system-dependent memory manager.  Assuming you have
  257. -DAMIGA in the makefile, jmemname.c will put temporary files in JPEGTMP:.
  258. Change jmemname.c if you don't like this.
  259.  
  260.  
  261. Cray:
  262.  
  263. Should you be so fortunate as to be running JPEG on a Cray YMP, there is a
  264. compiler bug in Cray's Standard C versions prior to 3.1.  You'll need to
  265. insert a line reading "#pragma novector" just before the loop    
  266.     for (i = 1; i <= (int) htbl->bits[l]; i++)
  267.       huffsize[p++] = (char) l;
  268. in fix_huff_tbl (in V2, line 42 of jchuff.c and line 38 of jdhuff.c).  The
  269. usual symptom of not adding this line is a core-dump.  See Cray's SPR 48222.
  270.  
  271.  
  272. HP/Apollo DOMAIN:
  273.  
  274. At least in version 10.3.5, the C compiler is ANSI but the system include
  275. files are not.  Use makefile.ansi and add -DNONANSI_INCLUDES to CFLAGS.
  276.  
  277.  
  278. HP-UX:
  279.  
  280. If you have HP-UX 7.05 or later with the "software development" C compiler,
  281. then you can use makefile.ansi.  Add "-Aa" to the CFLAGS line in the makefile
  282. to make the compiler work in ANSI mode.  If you have a pre-7.05 system, or if
  283. you are using the non-ANSI C compiler delivered with a minimum HP-UX 8.0
  284. system, then you must use makefile.unix (and do NOT add -Aa).  Also, adding
  285. "-lmalloc" to LDLIBS is recommended if you have libmalloc.a (it seems not to
  286. be present in minimum 8.0).
  287.  
  288. On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior
  289. to A.08.07.  If you get complaints about "not a typedef name", you'll have to
  290. convert the code to K&R style (i.e., use makefile.unix).
  291.  
  292.  
  293. Macintosh Think C:
  294.  
  295. You'll have to prepare project files for cjpeg and djpeg; we don't include
  296. those in the distribution since they are not text files.  The COBJECTS and
  297. DOBJECTS lists in makefile.unix show which files should be included in each
  298. project.  Also add the ANSI and Unix C libraries in a separate segment.  You
  299. may need to divide the JPEG files into more than one segment; you can do this
  300. pretty much as you please.
  301.  
  302. If you have Think C version 5.0 you need not modify jconfig.h; instead you
  303. should turn on both the ANSI Settings and Language Extensions option buttons
  304. (so that both __STDC__ and THINK_C are predefined).  With version 4.0 you must
  305. edit jconfig.h.  (You can #define HAVE_STDC to do the right thing for all
  306. options except const; you must also #define const.)
  307.  
  308. jcmain and jdmain are set up to provide the usual command-line interface
  309. by means of Think's ccommand() library routine.  Anybody want to write a
  310. more Mac-like interface for us?
  311.  
  312.  
  313. MS-DOS, generic comments:
  314.  
  315. The JPEG code is designed to be compiled with 80x86 "small" or "medium" memory
  316. models (i.e., data pointers are 16 bits unless explicitly declared "far"; code
  317. pointers can be either size).  You should be able to use small model to
  318. compile cjpeg or djpeg by itself, but you will probably have to go to medium
  319. model if you include the JPEG code in a larger application.  This shouldn't
  320. hurt performance much.  You *will* take a noticeable performance hit if you
  321. compile in a large-data memory model, and you should avoid "huge" model if at
  322. all possible.  Be sure that NEED_FAR_POINTERS is defined by jconfig.h or by
  323. the Makefile if you use a small-data model; be sure it is NOT defined if you
  324. use a large-data memory model.  (As distributed, jconfig.h defines
  325. NEED_FAR_POINTERS if MSDOS is defined.)
  326.  
  327. The DOS-specific memory manager, jmemdos.c, should be used if possible.
  328. (Be sure to install jmemdos.h and jmemdosa.asm along with it.)  If you
  329. can't use jmemdos.c for some reason --- for example, because you don't have
  330. a Microsoft-compatible assembler to assemble jmemdosa.asm --- you'll have
  331. to fall back to jmemansi.c or jmemname.c.  IMPORTANT: if you use either of
  332. those files, you will have to compile in a large-data memory model in order
  333. to get the right stdio library.  Too bad.
  334.  
  335. None of the above advice applies if you are using a 386 flat-memory-space
  336. environment, such as DJGPP or Watcom C.  For these compilers, do NOT define
  337. NEED_FAR_POINTERS, and do NOT use jmemdos.c.  Use jmemnobs.c if the
  338. environment supplies adequate virtual memory, otherwise use jmemansi.c or
  339. jmemname.c.
  340.  
  341.  
  342. MS-DOS, DJGPP:
  343.  
  344. The file egetopt.c conflicts with some library routines in DJGPP 1.05.
  345. Remove #include "egetopt.c" from jcmain.c and jdmain.c, and in each of
  346. those files change the egetopt(...) call to getopt(...).  This will be
  347. fixed more cleanly in some future version.  Use makefile.ansi, and put
  348. "-DTWO_FILE_COMMANDLINE" (but *not* -DMSDOS) in CFLAGS.
  349.  
  350.  
  351. MS-DOS, Microsoft C:
  352.  
  353. Some versions of MS C fail with an "out of macro expansion space" error
  354. because they can't cope with the macro TRACEMS8 (defined in jpegdata.h).
  355. If this happens to you, the easiest solution is to change TRACEMS8 to
  356. expand to nothing.  You'll lose the ability to dump out JPEG coefficient
  357. tables with djpeg -d -d, but at least you can compile.
  358.  
  359. makefile.mc6 (MS C 6.x makefile) has not been tested since jmemdosa.asm
  360. was added; we'd appreciate hearing whether it works or not.
  361.  
  362.  
  363. Sun:
  364.  
  365. Don't forget to add -DBSD to CFLAGS.  If you are using GCC on SunOS 4.0.1 or
  366. earlier, you will need to add -DNONANSI_INCLUDES to CFLAGS (your compiler may
  367. be ANSI, but your system include files aren't).  I've gotten conflicting
  368. reports on whether this is still necessary on SunOS 4.1 or later.
  369.