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 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 = libpng16 25 PNGMAJ = 16 26 27 prefix=/usr/local 28 INCPATH=$(prefix)/include 29 LIBPATH=$(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. 39 DESTDIR= 40 41 DI=$(DESTDIR)$(INCPATH) 42 DL=$(DESTDIR)$(LIBPATH) 43 44 WARNMORE = 45 CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5 46 CFLAGS = -W -Wall -O2 # $(WARNMORE) -g 47 LDFLAGS = -L. -L$(ZLIBLIB) -lpng16 -lz -lm 48 49 # Variables 50 OBJS = 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 58 all: $(LIBNAME).a pngtest$(E) 59 60 include scripts/pnglibconf.mak 61 REMOVE = $(RM_F) 62 DFNFLAGS = $(DEFS) $(CPPFLAGS) 63 64 $(LIBNAME).a: $(OBJS) 65 $(AR_RC) $@ $(OBJS) 66 $(RANLIB) $@ 67 68 test: pngtest$(E) 69 ./pngtest$(E) 70 71 pngtest$(E): pngtest.o $(LIBNAME).a 72 $(LD) -o $@ pngtest.o $(LDFLAGS) 73 74 install: $(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 97 clean: 98 $(RM_F) *.o $(LIBNAME).a pngtest pngout.png pnglibconf.h 99 100 png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 101 pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 102 pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 103 pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 104 pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 105 pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 106 pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 107 pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 108 pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 109 pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 110 pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 111 pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 112 pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 113 pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 114 pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 115 116 pngtest.o: png.h pngconf.h pnglibconf.h 117