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