# makefile for libpng using emscripten # Copyright (C) 2000, 2014, 2019-2025 Cosmin Truta # Copyright (C) 2021 Kirk Roerig # Copyright (C) 2008, 2014 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h # Location of the zlib library and include files ZLIBINC = ../zlib ZLIBLIB = ../zlib # Compiler, linker, lib and other tools CC = emcc LD = $(CC) AR = emar RANLIB = emranlib CP = cp RM_F = rm -f STDC = -pedantic-errors # -std=c99 WARN = -Wall -Wextra -Wundef WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \ -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes LOCAL_CPPFLAGS = CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5 ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS) LOCAL_CFLAGS = $(STDC) $(WARN) $(WARNMORE) CFLAGS = -O2 ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS) ARFLAGS = rc LDFLAGS = -L$(ZLIBLIB) PNGTEST_LDFLAGS = --preload-file=pngtest.png LIBS = -lz -lm # Pre-built configuration # See scripts/pnglibconf/pnglibconf.mak for more options PNGLIBCONF_H_PREBUILT = pnglibconf.h.prebuilt # File lists OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o \ pngrio.o pngrtran.o pngrutil.o pngset.o pngsimd.o \ pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o # Targets all: libpng.a pngtest pnglibconf.h: $(PNGLIBCONF_H_PREBUILT) $(CP) $(PNGLIBCONF_H_PREBUILT) $@ .c.o: $(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c libpng.a: $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) $(RANLIB) $@ test: pngtest node ./pngtest pngtest: pngtest.o libpng.a $(LD) $(LDFLAGS) $(PNGTEST_LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS) clean: $(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.h $(RM_F) pngtest.data pngtest.wasm # TODO: # Use the compiler to generate dependency files (e.g. "$(CC) -MD") and # include those files here, for the benefit of the Make implementations # that support the GNU Make syntax extensions. png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngsimd.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h pngtarget.h pngtest.o: png.h pngconf.h pnglibconf.h