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:
|
---|
12 | LIBNAME=libpng16
|
---|
13 | PNGMAJ=16
|
---|
14 |
|
---|
15 | # Shared library names:
|
---|
16 | LIBSO=$(LIBNAME).so
|
---|
17 | LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
|
---|
18 |
|
---|
19 | # Utilities:
|
---|
20 | CC=gcc
|
---|
21 | AR=ar
|
---|
22 | RANLIB=ranlib
|
---|
23 | LN_SF=ln -sf
|
---|
24 | CP=cp
|
---|
25 | RM_F=rm -f
|
---|
26 |
|
---|
27 | # Where the zlib library and include files are located.
|
---|
28 | #ZLIBLIB=/usr/local/lib
|
---|
29 | #ZLIBINC=/usr/local/include
|
---|
30 | ZLIBLIB=../zlib
|
---|
31 | ZLIBINC=../zlib
|
---|
32 |
|
---|
33 | # Compiler and linker flags
|
---|
34 | NOHWOPT=-DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
|
---|
35 | -DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
|
---|
36 | WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
---|
37 | -Wmissing-declarations -Wtraditional -Wcast-align \
|
---|
38 | -Wstrict-prototypes -Wmissing-prototypes # -Wconversion
|
---|
39 | DEFS=$(NOHWOPT)
|
---|
40 | CPPFLAGS=-I$(ZLIBINC) $(DEFS) # -DPNG_DEBUG=5
|
---|
41 | CFLAGS=-O3 -funroll-loops -Wall -Wextra -Wundef # $(WARNMORE) -g
|
---|
42 | ARFLAGS=rc
|
---|
43 | LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm # -g
|
---|
44 | LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm # -g
|
---|
45 |
|
---|
46 | # Pre-built configuration
|
---|
47 | # See scripts/pnglibconf.mak for more options
|
---|
48 | PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
|
---|
49 |
|
---|
50 | # File lists
|
---|
51 | OBJS = 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 |
|
---|
55 | OBJSDLL = $(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 |
|
---|
65 | all: libpng.a $(LIBSO) pngtest pngtest-static
|
---|
66 |
|
---|
67 | pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
|
---|
68 | $(CP) $(PNGLIBCONF_H_PREBUILT) $@
|
---|
69 |
|
---|
70 | libpng.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 |
|
---|
80 | pngtest: pngtest.o $(LIBSO)
|
---|
81 | $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
---|
82 |
|
---|
83 | pngtest-static: pngtest.o libpng.a
|
---|
84 | $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
|
---|
85 |
|
---|
86 | test: 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 |
|
---|
96 | install:
|
---|
97 | @echo "The $@ target is no longer supported by this makefile."
|
---|
98 | @false
|
---|
99 |
|
---|
100 | install-static:
|
---|
101 | @echo "The $@ target is no longer supported by this makefile."
|
---|
102 | @false
|
---|
103 |
|
---|
104 | install-shared:
|
---|
105 | @echo "The $@ target is no longer supported by this makefile."
|
---|
106 | @false
|
---|
107 |
|
---|
108 | clean:
|
---|
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 |
|
---|
115 | png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
116 | pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
117 | pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
118 | pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
119 | pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
120 | pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
121 | pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
122 | pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
123 | pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
124 | pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
125 | pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
126 | pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
127 | pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
128 | pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
129 | pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
---|
130 |
|
---|
131 | pngtest.o: png.h pngconf.h pnglibconf.h
|
---|