1# makefile for libpng.a and libpng16.so on Linux ELF with gcc 2# Copyright (C) 2020-2024 Cosmin Truta 3# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 Greg Roelofs and 4# Glenn Randers-Pehrson 5# Copyright (C) 1996, 1997 Andreas Dilger 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# Library name: 12LIBNAME=libpng16 13PNGMAJ=16 14 15# Shared library names: 16LIBSO=$(LIBNAME).so 17LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) 18 19# Utilities: 20CC=gcc 21AR=ar 22RANLIB=ranlib 23LN_SF=ln -sf 24CP=cp 25RM_F=rm -f 26 27# Where the zlib library and include files are located. 28#ZLIBLIB=/usr/local/lib 29#ZLIBINC=/usr/local/include 30ZLIBLIB=../zlib 31ZLIBINC=../zlib 32 33# Compiler and linker flags 34NOHWOPT=-DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \ 35 -DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 36WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ 37 -Wmissing-declarations -Wtraditional -Wcast-align \ 38 -Wstrict-prototypes -Wmissing-prototypes # -Wconversion 39DEFS=$(NOHWOPT) 40CPPFLAGS=-I$(ZLIBINC) $(DEFS) # -DPNG_DEBUG=5 41CFLAGS=-O3 -funroll-loops -Wall -Wextra -Wundef # $(WARNMORE) -g 42ARFLAGS=rc 43LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm # -g 44LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm # -g 45 46# Pre-built configuration 47# See scripts/pnglibconf.mak for more options 48PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt 49 50# File lists 51OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \ 52 pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \ 53 pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o 54 55OBJSDLL = $(OBJS:.o=.pic.o) 56 57.SUFFIXES: .c .o .pic.o 58 59.c.o: 60 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< 61 62.c.pic.o: 63 $(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c 64 65all: libpng.a $(LIBSO) pngtest pngtest-static 66 67pnglibconf.h: $(PNGLIBCONF_H_PREBUILT) 68 $(CP) $(PNGLIBCONF_H_PREBUILT) $@ 69 70libpng.a: $(OBJS) 71 $(AR) $(ARFLAGS) $@ $(OBJS) 72 $(RANLIB) $@ 73 74$(LIBSO): $(LIBSOMAJ) 75 $(LN_SF) $(LIBSOMAJ) $(LIBSO) 76 77$(LIBSOMAJ): $(OBJSDLL) 78 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ) $(OBJSDLL) 79 80pngtest: pngtest.o $(LIBSO) 81 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) 82 83pngtest-static: pngtest.o libpng.a 84 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) 85 86test: pngtest pngtest-static 87 @echo "" 88 @echo " Running pngtest dynamically linked with $(LIBSO):" 89 @echo "" 90 ./pngtest 91 @echo "" 92 @echo " Running pngtest statically linked with libpng.a:" 93 @echo "" 94 ./pngtest-static 95 96install: 97 @echo "The $@ target is no longer supported by this makefile." 98 @false 99 100install-static: 101 @echo "The $@ target is no longer supported by this makefile." 102 @false 103 104install-shared: 105 @echo "The $@ target is no longer supported by this makefile." 106 @false 107 108clean: 109 $(RM_F) $(OBJS) $(OBJSDLL) libpng.a 110 $(RM_F) $(LIBSO) $(LIBSOMAJ)* pnglibconf.h 111 $(RM_F) pngtest*.o pngtest pngtest-static pngout.png 112 113# DO NOT DELETE THIS LINE -- make depend depends on it. 114 115png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 116pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 117pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 118pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 119pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 120pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 121pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 122pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 123pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 124pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 125pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 126pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 127pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 128pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 129pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 130 131pngtest.o: png.h pngconf.h pnglibconf.h 132