1# makefile for libpng using gcc (generic, static library) 2# Copyright (C) 2002, 2006-2009, 2014 Glenn Randers-Pehrson 3# Copyright (C) 2000 Cosmin Truta 4# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) 5# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. 6# 7# This code is released under the libpng license. 8# For conditions of distribution and use, see the disclaimer 9# and license in png.h 10 11# Location of the zlib library and include files 12ZLIBINC = ../zlib 13ZLIBLIB = ../zlib 14 15# Compiler, linker, lib and other tools 16CC = gcc 17LD = $(CC) 18AR_RC = ar rcs 19MKDIR_P = mkdir -p 20RANLIB = ranlib 21RM_F = rm -f 22LN_SF = ln -f -s 23 24LIBNAME = libpng16 25PNGMAJ = 16 26 27prefix=/usr/local 28INCPATH=$(prefix)/include 29LIBPATH=$(prefix)/lib 30 31# override DESTDIR= on the make install command line to easily support 32# installing into a temporary location. Example: 33# 34# make install DESTDIR=/tmp/build/libpng 35# 36# If you're going to install into a temporary location 37# via DESTDIR, $(DESTDIR)$(prefix) must already exist before 38# you execute make install. 39DESTDIR= 40 41DI=$(DESTDIR)$(INCPATH) 42DL=$(DESTDIR)$(LIBPATH) 43 44WARNMORE = 45CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5 46CFLAGS = -W -Wall -O2 # $(WARNMORE) -g 47LDFLAGS = -L. -L$(ZLIBLIB) -lpng16 -lz -lm 48 49# Variables 50OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \ 51 pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \ 52 pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o 53 54# Targets 55.c.o: 56 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< 57 58all: $(LIBNAME).a pngtest$(E) 59 60include scripts/pnglibconf.mak 61REMOVE = $(RM_F) 62DFNFLAGS = $(DEFS) $(CPPFLAGS) 63 64$(LIBNAME).a: $(OBJS) 65 $(AR_RC) $@ $(OBJS) 66 $(RANLIB) $@ 67 68test: pngtest$(E) 69 ./pngtest$(E) 70 71pngtest$(E): pngtest.o $(LIBNAME).a 72 $(LD) -o $@ pngtest.o $(LDFLAGS) 73 74install: $(LIBNAME).a 75 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi 76 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi 77 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi 78 -@$(RM_F) $(DI)/$(LIBNAME)/png.h 79 -@$(RM_F) $(DI)/$(LIBNAME)/pngconf.h 80 -@$(RM_F) $(DI)/$(LIBNAME)/pnglibconf.h 81 -@$(RM_F) $(DI)/png.h 82 -@$(RM_F) $(DI)/pngconf.h 83 -@$(RM_F) $(DI)/pnglibconf.h 84 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) 85 chmod 644 $(DI)/$(LIBNAME)/png.h \ 86 $(DI)/$(LIBNAME)/pngconf.h \ 87 $(DI)/$(LIBNAME)/pnglibconf.h 88 -@$(RM_F) -r $(DI)/libpng 89 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) 90 -@$(RM_F) $(DL)/$(LIBNAME).a 91 -@$(RM_F) $(DL)/libpng.a 92 cp $(LIBNAME).a $(DL)/$(LIBNAME).a 93 chmod 644 $(DL)/$(LIBNAME).a 94 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) 95 (cd $(DI); $(LN_SF) libpng/* .;) 96 97clean: 98 $(RM_F) *.o $(LIBNAME).a pngtest pngout.png pnglibconf.h 99 100png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 101pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 102pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 103pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 104pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 105pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 106pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 107pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 108pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 109pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 110pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 111pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 112pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 113pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 114pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 115 116pngtest.o: png.h pngconf.h pnglibconf.h 117