Skip to content

Commit

Permalink
build: Update scripts/makefile.*
Browse files Browse the repository at this point in the history
Apply the following updates:
 * Tidy up the compiler flag definitions.
 * Update the Darwin, Linux and MSYS makefiles to match the compiler
   flags used in scripts/makefile.clang and scripts/makefile.gcc.
 * Add the `pngtest-static` target in the Darwin makefile, following
   on the Linux makefile.
 * Rewrite some of the implicit make rules to match one another more
   consistently.
 * Make corrections in the copyright years to match git log.
  • Loading branch information
ctruta committed Jan 21, 2025
1 parent 36a16fd commit 9cc729b
Show file tree
Hide file tree
Showing 25 changed files with 127 additions and 129 deletions.
11 changes: 4 additions & 7 deletions scripts/makefile.32sunu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# makefile for libpng on Solaris 2.x with cc
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
Expand Down Expand Up @@ -36,13 +36,10 @@ SUN_LD_FLAGS=-fast -xtarget=ultra
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include

WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=$(SUN_CC_FLAGS) # $(WARNMORE) -g
CFLAGS=$(SUN_CC_FLAGS) # -g
ARFLAGS=rc
LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm
LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm # -g

OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
Expand All @@ -53,7 +50,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c
Expand Down
11 changes: 4 additions & 7 deletions scripts/makefile.64sunu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# makefile for libpng on Solaris 2.x with cc
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
Expand Down Expand Up @@ -36,13 +36,10 @@ SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include

WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=$(SUN_CC_FLAGS) # $(WARNMORE) -g
CFLAGS=$(SUN_CC_FLAGS) # -g
ARFLAGS=rc
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm # -g

OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
Expand All @@ -53,7 +50,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c
Expand Down
7 changes: 3 additions & 4 deletions scripts/makefile.aix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng using gcc (generic, static library)
# Copyright (C) 2000, 2020-2024 Cosmin Truta
# Copyright (C) 2000, 2020-2025 Cosmin Truta
# Copyright (C) 2002, 2006-2009, 2014 Glenn Randers-Pehrson
# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc)
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
Expand All @@ -22,9 +22,8 @@ RM_F = rm -f
LIBNAME = libpng16
PNGMAJ = 16

WARNMORE =
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS = -O2 -Wall -Wextra -Wundef # $(WARNMORE) -g
CFLAGS = -O2 # -g
ARFLAGS = rc
LDFLAGS = -L. -L$(ZLIBLIB) -lpng16 -lz -lm # -g

Expand All @@ -35,7 +34,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \

# Targets
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

all: $(LIBNAME).a pngtest

Expand Down
4 changes: 2 additions & 2 deletions scripts/makefile.atari
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng
# Copyright (C) 2022 Cosmin Truta
# Copyright (C) 2022-2025 Cosmin Truta
# Copyright (C) 2002, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
Expand Down Expand Up @@ -28,7 +28,7 @@ OBJS = $(LBR)(png.o) $(LBR)(pngerror.o) $(LBR)(pngget.o) $(LBR)(pngmem.o) \
all: $(LBR) pngtest.ttp

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c

$(LBR): $(OBJS)

Expand Down
10 changes: 3 additions & 7 deletions scripts/makefile.beos
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# makefile for libpng on BeOS x86 ELF with gcc
# modified from makefile.linux by Sander Stoks
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2020-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2008, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1999 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
Expand Down Expand Up @@ -33,14 +33,10 @@ ALIGN=
# For i386:
# ALIGN=-malign-loops=2 -malign-functions=2

WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion

# On BeOS, -O1 is actually better than -O3. This is a known bug but it's
# still here in R4.5
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=-O1 -funroll-loops $(ALIGN) -Wall -Wextra -Wundef # $(WARNMORE) -g
CFLAGS=-O1 -funroll-loops $(ALIGN) # -g
ARFLAGS=rc
# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz
LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz # -g
Expand All @@ -58,7 +54,7 @@ OBJSDLL = $(OBJS)
.SUFFIXES: .c .o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

all: libpng.a $(LIBSO) pngtest

Expand Down
56 changes: 36 additions & 20 deletions scripts/makefile.darwin
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng on Darwin / macOS
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2014, 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2004, 2006, 2008, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 2001 Christoph Pfisterer
# derived from makefile.linux:
Expand All @@ -10,10 +10,6 @@
# For conditions of distribution and use, see the disclaimer
# and license in png.h

# Where the zlib library and include files are located
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include

# Library name:
LIBNAME=libpng16
PNGMAJ=16
Expand All @@ -30,13 +26,22 @@ LN_SF=ln -sf
CP=cp
RM_F=rm -f

NOHWOPT=-DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
DEFS=$(NOHWOPT)
CPPFLAGS=-I$(ZLIBINC) $(DEFS)
CFLAGS=-O3 -funroll-loops -Wall -Wextra -Wundef
ARFLAGS=rc
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
STDC = -pedantic-errors
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS = $(NOHWOPT)
CPPFLAGS = # -DPNG_DEBUG=5
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O3 -funroll-loops # -g
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = -L. -lpng16 -lz # -g
LDFLAGS_A = libpng.a -lz -lm # -g

# Pre-built configuration
# See scripts/pnglibconf.mak for more options
Expand All @@ -52,12 +57,12 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c

.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fno-common -o $@ $*.c
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -fno-common -o $@ $*.c

all: libpng.a $(LIBSO) pngtest
all: libpng.a $(LIBSO) pngtest pngtest-static

pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
Expand All @@ -71,15 +76,25 @@ $(LIBSO): $(LIBSOMAJ)

$(LIBSOMAJ): $(OBJSDLL)
$(CC) -dynamiclib \
-current_version 16 -compatibility_version 16 \
-o $(LIBSOMAJ) \
$(OBJSDLL) -L$(ZLIBLIB) -lz
-current_version 16 -compatibility_version 16 \
-o $(LIBSOMAJ) \
$(OBJSDLL) -lz

pngtest: pngtest.o $(LIBSO)
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)

test: pngtest
pngtest-static: pngtest.o libpng.a
$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)

test: pngtest pngtest-static
@echo ""
@echo " Running pngtest dynamically linked with $(LIBSO):"
@echo ""
./pngtest
@echo ""
@echo " Running pngtest statically linked with libpng.a:"
@echo ""
./pngtest-static

install:
@echo "The $@ target is no longer supported by this makefile."
Expand All @@ -94,8 +109,9 @@ install-shared:
@false

clean:
$(RM_F) *.o libpng.a pngtest pngout.png
$(RM_F) $(OBJS) $(OBJSDLL) libpng.a
$(RM_F) $(LIBNAME).*dylib pnglibconf.h
$(RM_F) pngtest*.o pngtest pngtest-static pngout.png

# DO NOT DELETE THIS LINE -- make depend depends on it.

Expand Down
6 changes: 3 additions & 3 deletions scripts/makefile.dec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng on DEC Alpha Unix
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2020-2025 Cosmin Truta
# Copyright (C) 2000-2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
Expand Down Expand Up @@ -30,7 +30,7 @@ ZLIBLIB=../zlib
ZLIBINC=../zlib

CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=-std -w1 -O # -g
CFLAGS=-std -w1 -O
ARFLAGS=rc
LDFLAGS=-L$(ZLIBLIB) -rpath $(ZLIBLIB) libpng.a -lz -lm

Expand All @@ -43,7 +43,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

all: $(LIBSO) libpng.a pngtest

Expand Down
6 changes: 3 additions & 3 deletions scripts/makefile.dj2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DJGPP (DOS gcc) makefile for libpng
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2020-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2009-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
Expand All @@ -11,7 +11,7 @@ CC=gcc
AR=ar
RANLIB=ranlib
CPPFLAGS=-I../zlib -DPNG_NO_SNPRINTF
CFLAGS=-O
CFLAGS=-O2 -Wall -Wextra -Wundef
ARFLAGS=rc
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm

Expand All @@ -27,7 +27,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

all: libpng.a pngtest

Expand Down
4 changes: 2 additions & 2 deletions scripts/makefile.freebsd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng under FreeBSD
# Copyright (C) 2020-2022 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2014 Glenn Randers-Pehrson and Andrey A. Chernov
# Copyright (C) 2002, 2007, 2009 Glenn Randers-Pehrson and Andrey A. Chernov
#
Expand Down Expand Up @@ -35,7 +35,7 @@ SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c

.c.o:
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $*.c

pnglibconf.h: ${PNGLIBCONF_H_PREBUILT}
cp ${PNGLIBCONF_H_PREBUILT} $@
Expand Down
4 changes: 2 additions & 2 deletions scripts/makefile.hp64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 1999-2002, 2006, 2009, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
Expand Down Expand Up @@ -56,7 +56,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) +z -o $@ $*.c
Expand Down
10 changes: 3 additions & 7 deletions scripts/makefile.hpgcc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng on HP-UX using GCC with the HP ANSI/C linker.
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006-2008, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 2001, Laurent faillie
# Copyright (C) 1998, 1999 Greg Roelofs
Expand Down Expand Up @@ -37,12 +37,8 @@ ZLIBINC=/opt/zlib/include
# LDSHARED=ld -b
# SHAREDLIB=libz.sl

WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion

CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=-O3 -funroll-loops -Wall -Wextra -Wundef # $(WARNMORE) -g
CFLAGS=-O3 -funroll-loops # -g
ARFLAGS=rc
#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm # -g
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz -lm # -g
Expand All @@ -56,7 +52,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
Expand Down
4 changes: 2 additions & 2 deletions scripts/makefile.hpux
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 1999-2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
Expand Down Expand Up @@ -55,7 +55,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o

.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c

.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) +z -o $@ $*.c
Expand Down
4 changes: 2 additions & 2 deletions scripts/makefile.ibmc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile for libpng (static)
# IBM C version 3.x for Win32 and OS/2
# Copyright (C) 2006, 2014 Glenn Randers-Pehrson
# Copyright (C) 2000, 2020 Cosmin Truta
# Copyright (C) 2000, 2020-2025 Cosmin Truta
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
Expand Down Expand Up @@ -46,7 +46,7 @@ LIBS = libpng$(A) $(ZLIBLIB)/zlib$(A)

# Targets
.c$(O):
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c

all: libpng$(A) pngtest$(E)

Expand Down
Loading

0 comments on commit 9cc729b

Please sign in to comment.