blob: 342c91242ba9b6829992d26cb0d9422a17e23087 [file] [log] [blame]
Glenn Randers-Pehrson871b1d02013-03-02 14:58:22 -06001# makefile for libpng using MSYS/gcc (shared, static library)
2# Copyright (C) 2012 Glenn Randers-Pehrson and Christopher M. Wheeler
3#
4# Portions taken from makefile.linux:
5# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs and
6# Glenn Randers-Pehrson
7# Copyright (C) 2000 Cosmin Truta
8# Copyright (C) 1996, 1997 Andreas Dilger
9# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
10#
11# This code is released under the libpng license.
12# For conditions of distribution and use, see the disclaimer
13# and license in png.h
14# # # # # # # # # # # # # # # # #
15prefix=/usr/local
16exec_prefix=$(prefix)
17
18# Library name:
19LIBNAME = libpng16
20PNGMAJ = 16
21RELEASE = 1
22
23# Shared library names:
24LIBSO=$(LIBNAME).dll
25LIBSOMAJ=$(LIBNAME).dll.$(PNGMAJ)
26LIBSOREL=$(PNGMAJ).$(RELEASE)
27OLDSO=libpng.dll
28
29# Where the zlib library and include files are located.
30#ZLIBLIB=../zlib
31#ZLIBINC=../zlib
32ZLIBLIB=/usr/local/lib
33ZLIBINC=/usr/local/include
34
35# Compiler, linker, lib and other tools
36CC = gcc
37LD = $(CC)
38AR_RC = ar rcs
39RANLIB = ranlib
40RM_F = rm -rf
41MKDIR_P=mkdir -p
42LN_SF=ln -sf
43
44#ARCH = -march=pentium3
45#ARCH = -march=i686
46ARCH =
47CDEBUG = -g -DPNG_DEBUG=5
48LDDEBUG =
49CRELEASE = -O2
50LDRELEASE = -s
51#CFLAGS = -W -Wall $(CDEBUG)
52CFLAGS = -W -Wall $(CRELEASE) $(ARCH)
53#LDFLAGS = $(LDDEBUG)
54LDFLAGS = $(LDRELEASE)
55LIBS = -lz -lm
56
57# File extensions
58O=.o
59A=.a
60EXE=.exe
61
62INCPATH=$(prefix)/include
63LIBPATH=$(exec_prefix)/lib
64MANPATH=$(prefix)/man
65BINPATH=$(exec_prefix)/bin
66
67# override DESTDIR= on the make install command line to easily support
68# installing into a temporary location. Example:
69#
70# make install DESTDIR=/tmp/build/libpng
71#
72# If you're going to install into a temporary location
73# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
74# you execute make install.
75
76DESTDIR=
77
78DB=$(DESTDIR)$(BINPATH)
79DI=$(DESTDIR)$(INCPATH)
80DL=$(DESTDIR)$(LIBPATH)
81DM=$(DESTDIR)$(MANPATH)
82
83# Variables
84OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
85 pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
86 pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
87
88# Targets
89all: static shared
90
91# see scripts/pnglibconf.mak for more options
92pnglibconf.h: scripts/pnglibconf.h.prebuilt
93 cp scripts/pnglibconf.h.prebuilt $@
94
95.c$(O):
96 $(CC) -c $(CFLAGS) -I$(ZLIBINC) $<
97
98static: libpng$(A) pngtest$(EXE)
99
100shared: $(LIBSOMAJ)
101 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSO)
102
103$(LIBSO): $(LIBSOMAJ)
104 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
105
106$(LIBSOMAJ):
107 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ)
108
109libpng$(A): $(OBJS)
110 $(AR_RC) $@ $(OBJS)
111 $(RANLIB) $@
112
113install-headers: png.h pngconf.h pnglibconf.h
114 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
115 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
116 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
117 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
118 -@$(RM_F) $(DI)/libpng
119 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
120
121install-static: install-headers libpng.a
122 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
123 cp libpng.a $(DL)/$(LIBNAME).a
124 -@$(RM_F) $(DL)/libpng.a
125 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
126
127libpng.pc:
128 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
129 -e s!@exec_prefix@!$(exec_prefix)! \
130 -e s!@libdir@!$(LIBPATH)! \
131 -e s!@includedir@!$(INCPATH)! \
132 -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
133
134libpng-config:
135 ( cat scripts/libpng-config-head.in; \
136 echo prefix=\"$(prefix)\"; \
137 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
138 echo L_opts=\"-L$(LIBPATH)\"; \
139 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
140 echo libs=\"-lpng16 -lz -lm\"; \
141 cat scripts/libpng-config-body.in ) > libpng-config
142
143install-shared: install-headers $(LIBSOMAJ) libpng.pc
144 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
145 -@$(RM_F) $(DL)/$(LIBSO)
146 -@$(RM_F) $(DL)/$(OLDSO)
147 cp $(LIBSO) $(DL)/$(LIBSOREL)
148 (cd $(DL); \
149 $(LN_SF) $(LIBSOREL) $(LIBSO); \
150 $(LN_SF) $(LIBSO) $(OLDSO))
151
152 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
153 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
154 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
155 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
156 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
157
158install-man: libpng.3 libpngpf.3 png.5
159 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
160 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
161 -@$(RM_F) $(DM)/man3/libpng.3
162 -@$(RM_F) $(DM)/man3/libpngpf.3
163 cp libpng.3 $(DM)/man3
164 cp libpngpf.3 $(DM)/man3
165 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
166 -@$(RM_F) $(DM)/man5/png.5
167 cp png.5 $(DM)/man5
168
169install-config: libpng-config
170 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
171 -@$(RM_F) $(DB)/libpng-config
172 -@$(RM_F) $(DB)/$(LIBNAME)-config
173 cp libpng-config $(DB)/$(LIBNAME)-config
174 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
175
176install: install-static install-shared install-man install-config
177
178test: pngtest$(EXE)
179 ./pngtest$(EXE)
180
181pngtest$(EXE): pngtest$(O) libpng$(A)
182 $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest$(O) libpng$(A) $(LIBS)
183
184clean:
185 $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png pnglibconf.h $(LIBSO) \
186 $(LIBSOMAJ) libpng-config
187
188png$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
189pngerror$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
190pngget$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
191pngmem$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
192pngpread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
193pngread$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
194pngrio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
195pngrtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
196pngrutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
197pngset$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
198pngtrans$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
199pngwio$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
200pngwrite$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
201pngwtran$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
202pngwutil$(O): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
203
204pngtest$(O): png.h pngconf.h pnglibconf.h