1 # makefile for libpng using gcc (generic, static library) 2 # Copyright (C) 2002, 2006-2009 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 12 ZLIBINC = ../zlib 13 ZLIBLIB = ../zlib 14 15 # Compiler, linker, lib and other tools 16 CC = gcc 17 LD = $(CC) 18 AR_RC = ar rcs 19 MKDIR_P = mkdir -p 20 RANLIB = ranlib 21 RM_F = rm -f 22 LN_SF = ln -f -s 23 24 LIBNAME=libpng12 25 PNGMAJ = 0 26 PNGMIN = 1.2.46 27 PNGVER = $(PNGMAJ).$(PNGMIN) 28 29 prefix=/usr/local 30 INCPATH=$(prefix)/include 31 LIBPATH=$(prefix)/lib 32 33 # override DESTDIR= on the make install command line to easily support 34 # installing into a temporary location. Example: 35 # 36 # make install DESTDIR=/tmp/build/libpng 37 # 38 # If you're going to install into a temporary location 39 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before 40 # you execute make install. 41 DESTDIR= 42 43 DI=$(DESTDIR)$(INCPATH) 44 DL=$(DESTDIR)$(LIBPATH) 45 46 CDEBUG = -g -DPNG_DEBUG=5 47 LDDEBUG = 48 CRELEASE = -O2 49 LDRELEASE = -s 50 WARNMORE=-W -Wall 51 CFLAGS = -D_ALL_SOURCE -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) 52 LDFLAGS = -L. -L$(ZLIBLIB) -lpng12 -lz -lm $(LDRELEASE) 53 54 # File extensions 55 O=.o 56 A=.a 57 E= 58 59 # Variables 60 OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ 61 pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ 62 pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) 63 64 # Targets 65 all: $(LIBNAME)$(A) pngtest$(E) 66 67 $(LIBNAME)$(A): $(OBJS) 68 $(AR_RC) $@ $(OBJS) 69 $(RANLIB) $@ 70 71 test: pngtest$(E) 72 ./pngtest$(E) 73 74 pngtest$(E): pngtest$(O) $(LIBNAME)$(A) 75 $(LD) -o $@ pngtest$(O) $(LDFLAGS) 76 77 install: $(LIBNAME)$(A) 78 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi 79 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi 80 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi 81 -@$(RM_F) $(DI)/$(LIBNAME)/png.h 82 -@$(RM_F) $(DI)/$(LIBNAME)/pngconf.h 83 -@$(RM_F) $(DI)/png.h 84 -@$(RM_F) $(DI)/pngconf.h 85 cp png.h pngconf.h $(DI)/$(LIBNAME) 86 chmod 644 $(DI)/$(LIBNAME)/png.h \ 87 $(DI)/$(LIBNAME)/pngconf.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 97 clean: 98 $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png 99 100 png$(O): png.h pngconf.h 101 pngerror$(O): png.h pngconf.h 102 pngget$(O): png.h pngconf.h 103 pngmem$(O): png.h pngconf.h 104 pngpread$(O): png.h pngconf.h 105 pngread$(O): png.h pngconf.h 106 pngrio$(O): png.h pngconf.h 107 pngrtran$(O): png.h pngconf.h 108 pngrutil$(O): png.h pngconf.h 109 pngset$(O): png.h pngconf.h 110 pngtrans$(O): png.h pngconf.h 111 pngwio$(O): png.h pngconf.h 112 pngwrite$(O): png.h pngconf.h 113 pngwtran$(O): png.h pngconf.h 114 pngwutil$(O): png.h pngconf.h 115 116 pngtest$(O): png.h pngconf.h 117