1# 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-2014 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 = 10 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 = 47CPPFLAGS = # -DPNG_DEBUG=5 48CFLAGS = -W -Wall -O2 $(ARCH) # -g 49LDFLAGS = 50LIBS = -lz -lm 51 52# File extensions 53EXEEXT=.exe 54 55INCPATH=$(prefix)/include 56LIBPATH=$(exec_prefix)/lib 57MANPATH=$(prefix)/man 58BINPATH=$(exec_prefix)/bin 59 60# override DESTDIR= on the make install command line to easily support 61# installing into a temporary location. Example: 62# 63# make install DESTDIR=/tmp/build/libpng 64# 65# If you're going to install into a temporary location 66# via DESTDIR, $(DESTDIR)$(prefix) must already exist before 67# you execute make install. 68 69DESTDIR= 70 71DB=$(DESTDIR)$(BINPATH) 72DI=$(DESTDIR)$(INCPATH) 73DL=$(DESTDIR)$(LIBPATH) 74DM=$(DESTDIR)$(MANPATH) 75 76# Variables 77OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \ 78 pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \ 79 pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o 80 81# Targets 82all: static shared 83 84# see scripts/pnglibconf.mak for more options 85pnglibconf.h: scripts/pnglibconf.h.prebuilt 86 cp scripts/pnglibconf.h.prebuilt $@ 87 88.c.o: 89 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< 90 91static: libpng.a pngtest$(EXEEXT) 92 93shared: $(LIBSOMAJ) 94 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSO) 95 96$(LIBSO): $(LIBSOMAJ) 97 $(LN_SF) $(LIBSOMAJ) $(LIBSO) 98 99$(LIBSOMAJ): 100 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ) 101 102libpng.a: $(OBJS) 103 $(AR_RC) $@ $(OBJS) 104 $(RANLIB) $@ 105 106install-headers: png.h pngconf.h pnglibconf.h 107 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi 108 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi 109 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) 110 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h 111 -@$(RM_F) $(DI)/libpng 112 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) 113 114install-static: install-headers libpng.a 115 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi 116 cp libpng.a $(DL)/$(LIBNAME).a 117 -@$(RM_F) $(DL)/libpng.a 118 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) 119 120libpng.pc: 121 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \ 122 -e s!@exec_prefix@!$(exec_prefix)! \ 123 -e s!@libdir@!$(LIBPATH)! \ 124 -e s!@includedir@!$(INCPATH)! \ 125 -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc 126 127libpng-config: 128 ( cat scripts/libpng-config-head.in; \ 129 echo prefix=\"$(prefix)\"; \ 130 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ 131 echo L_opts=\"-L$(LIBPATH)\"; \ 132 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ 133 echo libs=\"-lpng16 -lz -lm\"; \ 134 cat scripts/libpng-config-body.in ) > libpng-config 135 136install-shared: install-headers $(LIBSOMAJ) libpng.pc 137 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi 138 -@$(RM_F) $(DL)/$(LIBSO) 139 -@$(RM_F) $(DL)/$(OLDSO) 140 cp $(LIBSO) $(DL)/$(LIBSOREL) 141 (cd $(DL); \ 142 $(LN_SF) $(LIBSOREL) $(LIBSO); \ 143 $(LN_SF) $(LIBSO) $(OLDSO)) 144 145 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi 146 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc 147 -@$(RM_F) $(DL)/pkgconfig/libpng.pc 148 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc 149 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) 150 151install-man: libpng.3 libpngpf.3 png.5 152 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi 153 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi 154 -@$(RM_F) $(DM)/man3/libpng.3 155 -@$(RM_F) $(DM)/man3/libpngpf.3 156 cp libpng.3 $(DM)/man3 157 cp libpngpf.3 $(DM)/man3 158 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi 159 -@$(RM_F) $(DM)/man5/png.5 160 cp png.5 $(DM)/man5 161 162install-config: libpng-config 163 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi 164 -@$(RM_F) $(DB)/libpng-config 165 -@$(RM_F) $(DB)/$(LIBNAME)-config 166 cp libpng-config $(DB)/$(LIBNAME)-config 167 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) 168 169install: install-static install-shared install-man install-config 170 171test: pngtest$(EXEEXT) 172 ./pngtest$(EXEEXT) 173 174pngtest$(EXEEXT): pngtest.o libpng.a 175 $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest.o libpng.a $(LIBS) 176 177clean: 178 $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h $(LIBSO) \ 179 $(LIBSOMAJ) libpng-config 180 181png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 182pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 183pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 184pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 185pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 186pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 187pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 188pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 189pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 190pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 191pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 192pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 193pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 194pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 195pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 196 197pngtest.o: png.h pngconf.h pnglibconf.h 198