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