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