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 # # # # # # # # # # # # # # # # # 15 prefix=/usr/local 16 exec_prefix=$(prefix) 17 18 # Library name: 19 LIBNAME = libpng16 20 PNGMAJ = 16 21 RELEASE = 10 22 23 # Shared library names: 24 LIBSO=$(LIBNAME).dll 25 LIBSOMAJ=$(LIBNAME).dll.$(PNGMAJ) 26 LIBSOREL=$(PNGMAJ).$(RELEASE) 27 OLDSO=libpng.dll 28 29 # Where the zlib library and include files are located. 30 #ZLIBLIB=../zlib 31 #ZLIBINC=../zlib 32 ZLIBLIB=/usr/local/lib 33 ZLIBINC=/usr/local/include 34 35 # Compiler, linker, lib and other tools 36 CC = gcc 37 LD = $(CC) 38 AR_RC = ar rcs 39 RANLIB = ranlib 40 RM_F = rm -rf 41 MKDIR_P=mkdir -p 42 LN_SF=ln -sf 43 44 #ARCH = -march=pentium3 45 #ARCH = -march=i686 46 ARCH = 47 CPPFLAGS = # -DPNG_DEBUG=5 48 CFLAGS = -W -Wall -O2 $(ARCH) # -g 49 LDFLAGS = 50 LIBS = -lz -lm 51 52 # File extensions 53 EXEEXT=.exe 54 55 INCPATH=$(prefix)/include 56 LIBPATH=$(exec_prefix)/lib 57 MANPATH=$(prefix)/man 58 BINPATH=$(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 69 DESTDIR= 70 71 DB=$(DESTDIR)$(BINPATH) 72 DI=$(DESTDIR)$(INCPATH) 73 DL=$(DESTDIR)$(LIBPATH) 74 DM=$(DESTDIR)$(MANPATH) 75 76 # Variables 77 OBJS = 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 82 all: static shared 83 84 # see scripts/pnglibconf.mak for more options 85 pnglibconf.h: scripts/pnglibconf.h.prebuilt 86 cp scripts/pnglibconf.h.prebuilt $@ 87 88 .c.o: 89 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< 90 91 static: libpng.a pngtest$(EXEEXT) 92 93 shared: $(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 102 libpng.a: $(OBJS) 103 $(AR_RC) $@ $(OBJS) 104 $(RANLIB) $@ 105 106 install-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 114 install-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 120 libpng.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 127 libpng-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 136 install-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 151 install-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 162 install-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 169 install: install-static install-shared install-man install-config 170 171 test: pngtest$(EXEEXT) 172 ./pngtest$(EXEEXT) 173 174 pngtest$(EXEEXT): pngtest.o libpng.a 175 $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest.o libpng.a $(LIBS) 176 177 clean: 178 $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h $(LIBSO) \ 179 $(LIBSOMAJ) libpng-config 180 181 png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 182 pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 183 pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 184 pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 185 pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 186 pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 187 pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 188 pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 189 pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 190 pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 191 pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 192 pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 193 pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 194 pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 195 pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 196 197 pngtest.o: png.h pngconf.h pnglibconf.h 198