blob: f987378009856bde14e8c371a6852799d2fa2d4d [file] [log] [blame]
The Android Open Source Project893912b2009-03-03 19:30:05 -08001
Chris Craikca2bf812013-07-29 15:28:30 -07002Installing libpng
The Android Open Source Project893912b2009-03-03 19:30:05 -08003
4On Unix/Linux and similar systems, you can simply type
5
6 ./configure [--prefix=/path]
7 make check
8 make install
9
10and ignore the rest of this document.
11
Chris Craikca2bf812013-07-29 15:28:30 -070012If configure does not work on your system, or if you have a need to
13change configure.ac or Makefile.am, and you have a reasonably
14up-to-date set of tools, running ./autogen.sh in a git clone before
15running ./configure may fix the problem. To be really sure that you
16aren't using any of the included pre-built scripts, you can do this:
17
18 ./configure --enable-maintainer-mode
19 make maintainer-clean
20 ./autogen.sh --maintainer --clean
21 ./autogen.sh --maintainer
22 ./configure [--prefix=/path] [other options]
23 make
24 make install
25 make check
The Android Open Source Project893912b2009-03-03 19:30:05 -080026
27Instead, you can use one of the custom-built makefiles in the
28"scripts" directory
29
30 cp scripts/makefile.system makefile
31 make test
32 make install
33
Patrick Scott5f6bd842010-06-28 16:55:16 -040034The files that are presently available in the scripts directory
35are listed and described in scripts/README.txt.
36
The Android Open Source Project893912b2009-03-03 19:30:05 -080037Or you can use one of the "projects" in the "projects" directory.
38
The Android Open Source Project893912b2009-03-03 19:30:05 -080039Before installing libpng, you must first install zlib, if it
40is not already on your system. zlib can usually be found
41wherever you got libpng. zlib can be placed in another directory,
42at the same level as libpng.
43
Chris Craikca2bf812013-07-29 15:28:30 -070044If your system already has a preinstalled zlib you will still need
45to have access to the zlib.h and zconf.h include files that
46correspond to the version of zlib that's installed.
47
48If you wish to test with a particular zlib that is not first in the
49standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
50and LD_LIBRARY_PATH in your environment before running "make test"
51or "make distcheck":
52
53ZLIBLIB=/path/to/lib export ZLIBLIB
54ZLIBINC=/path/to/include export ZLIBINC
55CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
56LDFLAGS="-L$ZLIBLIB" export LDFLAGS
57LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
58
59If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
60in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
61
Patrick Scott5f6bd842010-06-28 16:55:16 -040062If you want to use "cmake" (see www.cmake.org), type
63
64 cmake . -DCMAKE_INSTALL_PREFIX=/path
65 make
66 make install
67
The Android Open Source Project893912b2009-03-03 19:30:05 -080068You can rename the directories that you downloaded (they
Chris Craikca2bf812013-07-29 15:28:30 -070069might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.7"
70or "zlib127") so that you have directories called "zlib" and "libpng".
The Android Open Source Project893912b2009-03-03 19:30:05 -080071
72Your 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
Patrick Scott5f6bd842010-06-28 16:55:16 -040080 CMakeLists.txt => "cmake" script
81 configuration files:
82 configure.ac, configure, Makefile.am, Makefile.in,
Chris Craikca2bf812013-07-29 15:28:30 -070083 autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
84 libpng-config.in, aclocal.m4, config.h.in, config.sub,
Patrick Scott5f6bd842010-06-28 16:55:16 -040085 depcomp, install-sh, mkinstalldirs, test-pngtest.sh
The Android Open Source Project893912b2009-03-03 19:30:05 -080086 contrib
87 gregbook
Chris Craikca2bf812013-07-29 15:28:30 -070088 libtests
Patrick Scott5f6bd842010-06-28 16:55:16 -040089 pngminim
The Android Open Source Project893912b2009-03-03 19:30:05 -080090 pngminus
91 pngsuite
92 visupng
93 projects
Patrick Scott5f6bd842010-06-28 16:55:16 -040094 visualc71
Chris Craikca2bf812013-07-29 15:28:30 -070095 vstudio
The Android Open Source Project893912b2009-03-03 19:30:05 -080096 scripts
97 makefile.*
Patrick Scott5f6bd842010-06-28 16:55:16 -040098 *.def (module definition files)
Chris Craikca2bf812013-07-29 15:28:30 -070099 etc.
The Android Open Source Project893912b2009-03-03 19:30:05 -0800100 pngtest.png
101 etc.
102 zlib
103 README
104 *.h
105 *.c
106 contrib
107 etc.
108
109If the line endings in the files look funny, you may wish to get the other
110distribution of libpng. It is available in both tar.gz (UNIX style line
111endings) and zip (DOS style line endings) formats.
112
113If you are building libpng with MSVC, you can enter the
Patrick Scott5f6bd842010-06-28 16:55:16 -0400114libpng projects\visualc6 or visualc71 directory and follow the instructions
115in README.txt.
The Android Open Source Project893912b2009-03-03 19:30:05 -0800116
Patrick Scott5f6bd842010-06-28 16:55:16 -0400117Otherwise enter the zlib directory and follow the instructions in zlib/README,
The Android Open Source Project893912b2009-03-03 19:30:05 -0800118then come back here and run "configure" or choose the appropriate
119makefile.sys in the scripts directory.
120
The Android Open Source Project893912b2009-03-03 19:30:05 -0800121Copy the file (or files) that you need from the
122scripts directory into this directory, for example
123
124 MSDOS example: copy scripts\makefile.msc makefile
125 UNIX example: cp scripts/makefile.std makefile
126
127Read the makefile to see if you need to change any source or
128target directories to match your preferences.
129
Chris Craikca2bf812013-07-29 15:28:30 -0700130Then read pnglibconf.dfa to see if you want to make any configuration
The Android Open Source Project893912b2009-03-03 19:30:05 -0800131changes.
132
133Then just run "make" which will create the libpng library in
134this directory and "make test" which will run a quick test that reads
135the "pngtest.png" file and writes a "pngout.png" file that should be
136identical to it. Look for "9782 zero samples" in the output of the
137test. For more confidence, you can run another test by typing
138"pngtest pngnow.png" and looking for "289 zero samples" in the output.
139Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
140your output with the result shown in contrib/pngsuite/README.
141
142Most of the makefiles will allow you to run "make install" to
143put the library in its final resting place (if you want to
144do that, run "make install" in the zlib directory first if necessary).
145Some also allow you to run "make test-installed" after you have
146run "make install".
147
Chris Craikca2bf812013-07-29 15:28:30 -0700148Further information can be found in the README and libpng-manual.txt
The Android Open Source Project893912b2009-03-03 19:30:05 -0800149files, in the individual makefiles, in png.h, and the manual pages
150libpng.3 and png.5.
Patrick Scott5f6bd842010-06-28 16:55:16 -0400151
Patrick Scott5f6bd842010-06-28 16:55:16 -0400152Using the ./configure script -- 16 December 2002.
153=================================================
154
Patrick Scott5f6bd842010-06-28 16:55:16 -0400155The ./configure script should work compatibly with what scripts/makefile.*
Chris Craikca2bf812013-07-29 15:28:30 -0700156did, however there are some options you might need to add to configure
157explicitly, which previously was done semi-automatically (if you didn't edit
Patrick Scott5f6bd842010-06-28 16:55:16 -0400158scripts/makefile.* yourself, that is)
159
Patrick Scott5f6bd842010-06-28 16:55:16 -0400160CFLAGS="-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
164You can alternatively specify --includedir=/usr/include, /usr/local/include,
Chris Craikca2bf812013-07-29 15:28:30 -0700165/usr/include/libpng%NN%, or whatever.
Patrick Scott5f6bd842010-06-28 16:55:16 -0400166
Chris Craikca2bf812013-07-29 15:28:30 -0700167If you find that the configure script is out-of-date or is not supporting
168your platform properly, try running autogen.sh to regenerate "configure",
169"Makefile.in", and the other configuration files. Then try configure again.
Patrick Scott5f6bd842010-06-28 16:55:16 -0400170