Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 1 | |
Glenn Randers-Pehrson | 6667601 | 2010-10-16 07:18:09 -0500 | [diff] [blame] | 2 | Installing libpng |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 3 | |
Glenn Randers-Pehrson | ddfebd3 | 2006-02-22 09:19:25 -0600 | [diff] [blame] | 4 | On Unix/Linux and similar systems, you can simply type |
| 5 | |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 6 | ./configure [--prefix=/path] |
Glenn Randers-Pehrson | ddfebd3 | 2006-02-22 09:19:25 -0600 | [diff] [blame] | 7 | make check |
| 8 | make install |
| 9 | |
| 10 | and ignore the rest of this document. |
| 11 | |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 12 | If configure does not work on your system, or if you have a need to |
| 13 | change configure.ac or Makefile.am, and you have a reasonably |
| 14 | up-to-date set of tools, running ./autogen.sh in a git clone before |
| 15 | running ./configure may fix the problem. To be really sure that you |
| 16 | aren't using any of the included pre-built scripts, you can do this: |
Glenn Randers-Pehrson | 6667601 | 2010-10-16 07:18:09 -0500 | [diff] [blame] | 17 | |
Glenn Randers-Pehrson | 6612114 | 2010-10-16 07:22:19 -0500 | [diff] [blame] | 18 | ./configure --enable-maintainer-mode |
Glenn Randers-Pehrson | 6667601 | 2010-10-16 07:18:09 -0500 | [diff] [blame] | 19 | make maintainer-clean |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 20 | ./autogen.sh --maintainer --clean |
| 21 | ./autogen.sh --maintainer |
Glenn Randers-Pehrson | 6612114 | 2010-10-16 07:22:19 -0500 | [diff] [blame] | 22 | ./configure [--prefix=/path] [other options] |
Glenn Randers-Pehrson | 6667601 | 2010-10-16 07:18:09 -0500 | [diff] [blame] | 23 | make |
| 24 | make install |
| 25 | make check |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 26 | |
| 27 | Instead, you can use one of the custom-built makefiles in the |
Glenn Randers-Pehrson | ddfebd3 | 2006-02-22 09:19:25 -0600 | [diff] [blame] | 28 | "scripts" directory |
| 29 | |
| 30 | cp scripts/makefile.system makefile |
| 31 | make test |
| 32 | make install |
| 33 | |
Glenn Randers-Pehrson | 9d27a1b | 2009-11-15 07:59:06 -0600 | [diff] [blame] | 34 | The files that are presently available in the scripts directory |
| 35 | are listed and described in scripts/README.txt. |
| 36 | |
Glenn Randers-Pehrson | ddfebd3 | 2006-02-22 09:19:25 -0600 | [diff] [blame] | 37 | Or you can use one of the "projects" in the "projects" directory. |
| 38 | |
| 39 | Before installing libpng, you must first install zlib, if it |
| 40 | is not already on your system. zlib can usually be found |
| 41 | wherever you got libpng. zlib can be placed in another directory, |
| 42 | at the same level as libpng. |
| 43 | |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 44 | If your system already has a preinstalled zlib you will still need |
| 45 | to have access to the zlib.h and zconf.h include files that |
| 46 | correspond to the version of zlib that's installed. |
| 47 | |
| 48 | If you wish to test with a particular zlib that is not first in the |
| 49 | standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS, |
| 50 | and LD_LIBRARY_PATH in your environment before running "make test" |
| 51 | or "make distcheck": |
| 52 | |
| 53 | ZLIBLIB=/path/to/lib export ZLIBLIB |
| 54 | ZLIBINC=/path/to/include export ZLIBINC |
| 55 | CPPFLAGS="-I$ZLIBINC" export CPPFLAGS |
| 56 | LDFLAGS="-L$ZLIBLIB" export LDFLAGS |
| 57 | LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH |
| 58 | |
| 59 | If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC |
| 60 | in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test". |
| 61 | |
Glenn Randers-Pehrson | 5b754aa | 2009-08-26 12:16:18 -0500 | [diff] [blame] | 62 | If you want to use "cmake" (see www.cmake.org), type |
Glenn Randers-Pehrson | 7edd458 | 2006-12-07 19:16:44 -0600 | [diff] [blame] | 63 | |
| 64 | cmake . -DCMAKE_INSTALL_PREFIX=/path |
| 65 | make |
| 66 | make install |
| 67 | |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 68 | You can rename the directories that you downloaded (they |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 69 | might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.7" |
| 70 | or "zlib127") so that you have directories called "zlib" and "libpng". |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 71 | |
| 72 | Your directory structure should look like this: |
| 73 | |
| 74 | .. (the parent directory) |
| 75 | libpng (this directory) |
| 76 | INSTALL (this file) |
| 77 | README |
| 78 | *.h |
| 79 | *.c |
Glenn Randers-Pehrson | be199c1 | 2009-11-12 13:57:42 -0600 | [diff] [blame] | 80 | CMakeLists.txt => "cmake" script |
Glenn Randers-Pehrson | 22ad8f0 | 2009-11-14 07:25:31 -0600 | [diff] [blame] | 81 | configuration files: |
| 82 | configure.ac, configure, Makefile.am, Makefile.in, |
Glenn Randers-Pehrson | 39515c9 | 2010-08-28 06:21:35 -0500 | [diff] [blame] | 83 | autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in, |
| 84 | libpng-config.in, aclocal.m4, config.h.in, config.sub, |
Glenn Randers-Pehrson | 22ad8f0 | 2009-11-14 07:25:31 -0600 | [diff] [blame] | 85 | depcomp, install-sh, mkinstalldirs, test-pngtest.sh |
Glenn Randers-Pehrson | 860ab2b | 1999-10-14 07:43:10 -0500 | [diff] [blame] | 86 | contrib |
| 87 | gregbook |
Glenn Randers-Pehrson | 871b1d0 | 2013-03-02 14:58:22 -0600 | [diff] [blame] | 88 | libtests |
Glenn Randers-Pehrson | be199c1 | 2009-11-12 13:57:42 -0600 | [diff] [blame] | 89 | pngminim |
Glenn Randers-Pehrson | 6d8f3b0 | 1999-10-23 08:39:18 -0500 | [diff] [blame] | 90 | pngminus |
| 91 | pngsuite |
Glenn Randers-Pehrson | db66d44 | 2000-06-23 21:38:16 -0500 | [diff] [blame] | 92 | visupng |
Glenn Randers-Pehrson | fbbb5ec | 2001-01-15 22:01:20 -0600 | [diff] [blame] | 93 | projects |
Glenn Randers-Pehrson | be199c1 | 2009-11-12 13:57:42 -0600 | [diff] [blame] | 94 | visualc71 |
Glenn Randers-Pehrson | 6667601 | 2010-10-16 07:18:09 -0500 | [diff] [blame] | 95 | vstudio |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 96 | scripts |
| 97 | makefile.* |
Glenn Randers-Pehrson | be199c1 | 2009-11-12 13:57:42 -0600 | [diff] [blame] | 98 | *.def (module definition files) |
Glenn Randers-Pehrson | 8c66786 | 2010-08-24 16:16:35 -0500 | [diff] [blame] | 99 | etc. |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 100 | pngtest.png |
| 101 | etc. |
| 102 | zlib |
| 103 | README |
| 104 | *.h |
| 105 | *.c |
| 106 | contrib |
| 107 | etc. |
| 108 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 109 | If the line endings in the files look funny, you may wish to get the other |
| 110 | distribution of libpng. It is available in both tar.gz (UNIX style line |
| 111 | endings) and zip (DOS style line endings) formats. |
| 112 | |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 113 | If you are building libpng with MSVC, you can enter the |
Glenn Randers-Pehrson | be199c1 | 2009-11-12 13:57:42 -0600 | [diff] [blame] | 114 | libpng projects\visualc6 or visualc71 directory and follow the instructions |
| 115 | in README.txt. |
Glenn Randers-Pehrson | d436672 | 2000-06-04 14:29:29 -0500 | [diff] [blame] | 116 | |
Glenn Randers-Pehrson | a2aebb5 | 2009-11-14 17:58:32 -0600 | [diff] [blame] | 117 | Otherwise enter the zlib directory and follow the instructions in zlib/README, |
Glenn Randers-Pehrson | ddfebd3 | 2006-02-22 09:19:25 -0600 | [diff] [blame] | 118 | then come back here and run "configure" or choose the appropriate |
| 119 | makefile.sys in the scripts directory. |
Glenn Randers-Pehrson | db66d44 | 2000-06-23 21:38:16 -0500 | [diff] [blame] | 120 | |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 121 | Copy the file (or files) that you need from the |
| 122 | scripts directory into this directory, for example |
| 123 | |
Glenn Randers-Pehrson | 860ab2b | 1999-10-14 07:43:10 -0500 | [diff] [blame] | 124 | MSDOS example: copy scripts\makefile.msc makefile |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 125 | UNIX example: cp scripts/makefile.std makefile |
| 126 | |
| 127 | Read the makefile to see if you need to change any source or |
| 128 | target directories to match your preferences. |
| 129 | |
Glenn Randers-Pehrson | 10973a5 | 2010-10-16 19:40:09 -0500 | [diff] [blame] | 130 | Then read pnglibconf.dfa to see if you want to make any configuration |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 131 | changes. |
| 132 | |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 133 | Then just run "make" which will create the libpng library in |
| 134 | this directory and "make test" which will run a quick test that reads |
| 135 | the "pngtest.png" file and writes a "pngout.png" file that should be |
| 136 | identical to it. Look for "9782 zero samples" in the output of the |
| 137 | test. For more confidence, you can run another test by typing |
| 138 | "pngtest pngnow.png" and looking for "289 zero samples" in the output. |
| 139 | Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare |
Glenn Randers-Pehrson | 6d8f3b0 | 1999-10-23 08:39:18 -0500 | [diff] [blame] | 140 | your output with the result shown in contrib/pngsuite/README. |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 141 | |
| 142 | Most of the makefiles will allow you to run "make install" to |
| 143 | put the library in its final resting place (if you want to |
| 144 | do that, run "make install" in the zlib directory first if necessary). |
Glenn Randers-Pehrson | d1e8c86 | 2002-06-20 06:54:34 -0500 | [diff] [blame] | 145 | Some also allow you to run "make test-installed" after you have |
Glenn Randers-Pehrson | 0cc2f95 | 2002-10-03 06:32:37 -0500 | [diff] [blame] | 146 | run "make install". |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 147 | |
Glenn Randers-Pehrson | f3abb2c | 2010-10-17 12:51:53 -0500 | [diff] [blame] | 148 | Further information can be found in the README and libpng-manual.txt |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 149 | files, in the individual makefiles, in png.h, and the manual pages |
| 150 | libpng.3 and png.5. |
Glenn Randers-Pehrson | c2d8399 | 2011-11-16 14:30:24 -0600 | [diff] [blame] | 151 | |
| 152 | Using the ./configure script -- 16 December 2002. |
| 153 | ================================================= |
| 154 | |
| 155 | The ./configure script should work compatibly with what scripts/makefile.* |
| 156 | did, however there are some options you might need to add to configure |
| 157 | explicitly, which previously was done semi-automatically (if you didn't edit |
| 158 | scripts/makefile.* yourself, that is) |
| 159 | |
| 160 | CFLAGS="-Wall -O -funroll-loops \ |
| 161 | -malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \ |
| 162 | --with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include |
| 163 | |
| 164 | You can alternatively specify --includedir=/usr/include, /usr/local/include, |
| 165 | /usr/include/libpng%NN%, or whatever. |
| 166 | |
| 167 | If you find that the configure script is out-of-date or is not supporting |
| 168 | your platform properly, try running autogen.sh to regenerate "configure", |
| 169 | "Makefile.in", and the other configuration files. Then try configure again. |
| 170 | |