lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | # makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX |
| 2 | # assembler code |
| 3 | # Copyright 2002 Greg Roelofs and Glenn Randers-Pehrson |
| 4 | # Copyright 1998-2001 Greg Roelofs |
| 5 | # Copyright 1996-1997 Andreas Dilger |
| 6 | # For conditions of distribution and use, see copyright notice in png.h |
| 7 | |
| 8 | # CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. |
| 9 | |
| 10 | # WARNING: The assembler code in pnggccrd.c may not be thread safe. |
| 11 | |
| 12 | # NOTE: When testing MMX performance on a multitasking system, make sure |
| 13 | # there are no floating-point programs (e.g., SETI@Home) running in |
| 14 | # the background! Context switches between MMX and FPU are expensive. |
| 15 | |
| 16 | LIBNAME = libpng12 |
| 17 | PNGMAJ = 0 |
| 18 | PNGMIN = 1.2.5 |
| 19 | PNGVER = $(PNGMAJ).$(PNGMIN) |
| 20 | |
| 21 | CC=gcc |
| 22 | |
| 23 | # where "make install" puts libpng12.a, libpng12.so*, |
| 24 | # libpng12/png.h and libpng12/pngconf.h |
| 25 | # Prefix must be a full pathname. |
| 26 | prefix=/usr/local |
| 27 | |
| 28 | # Where the zlib library and include files are located. |
| 29 | #ZLIBLIB=/usr/local/lib |
| 30 | #ZLIBINC=/usr/local/include |
| 31 | ZLIBLIB=../zlib |
| 32 | ZLIBINC=../zlib |
| 33 | |
| 34 | ALIGN= |
| 35 | # for i386: |
| 36 | #ALIGN=-malign-loops=2 -malign-functions=2 |
| 37 | |
| 38 | WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ |
| 39 | -Wmissing-declarations -Wtraditional -Wcast-align \ |
| 40 | -Wstrict-prototypes -Wmissing-prototypes #-Wconversion |
| 41 | |
| 42 | # for pgcc version 2.95.1, -O3 is buggy; don't use it. |
| 43 | |
| 44 | # Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety |
| 45 | ### for generic gcc: |
| 46 | CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \ |
| 47 | -O3 $(ALIGN) -funroll-loops \ |
| 48 | -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 |
| 49 | ### for gcc 2.95.2 on 686: |
| 50 | #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ |
| 51 | # -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ |
| 52 | # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer |
| 53 | ### for gcc 2.7.2.3 on 486 and up: |
| 54 | #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ |
| 55 | # -m486 -malign-double -ffast-math \ |
| 56 | # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer |
| 57 | |
| 58 | LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm |
| 59 | LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm |
| 60 | |
| 61 | RANLIB=ranlib |
| 62 | #RANLIB=echo |
| 63 | |
| 64 | INCPATH=$(prefix)/include |
| 65 | LIBPATH=$(prefix)/lib |
| 66 | MANPATH=$(prefix)/man |
| 67 | BINPATH=$(prefix)/bin |
| 68 | |
| 69 | # override DESTDIR= on the make install command line to easily support |
| 70 | # installing into a temporary location. Example: |
| 71 | # |
| 72 | # make install DESTDIR=/tmp/build/libpng |
| 73 | # |
| 74 | # If you're going to install into a temporary location |
| 75 | # via DESTDIR, $(DESTDIR)$(prefix) must already exist before |
| 76 | # you execute make install. |
| 77 | DESTDIR= |
| 78 | |
| 79 | DB=$(DESTDIR)$(BINPATH) |
| 80 | DI=$(DESTDIR)$(INCPATH) |
| 81 | DL=$(DESTDIR)$(LIBPATH) |
| 82 | DM=$(DESTDIR)$(MANPATH) |
| 83 | |
| 84 | OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ |
| 85 | pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ |
| 86 | pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o |
| 87 | |
| 88 | OBJSDLL = $(OBJS:.o=.pic.o) |
| 89 | |
| 90 | .SUFFIXES: .c .o .pic.o |
| 91 | |
| 92 | .c.pic.o: |
| 93 | $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c |
| 94 | |
| 95 | all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config |
| 96 | |
| 97 | libpng.a: $(OBJS) |
| 98 | ar rc $@ $(OBJS) |
| 99 | $(RANLIB) $@ |
| 100 | |
| 101 | libpng.pc: |
| 102 | cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc |
| 103 | |
| 104 | libpng-config: |
| 105 | ( cat scripts/libpng-config-head.in; \ |
| 106 | echo prefix=\"$(prefix)\"; \ |
| 107 | echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ |
| 108 | echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \ |
| 109 | echo L_opts=\"-L$(LIBPATH)\"; \ |
| 110 | echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ |
| 111 | echo libs=\"-lpng12 -lz -lm\"; \ |
| 112 | cat scripts/libpng-config-body.in ) > libpng-config |
| 113 | chmod +x libpng-config |
| 114 | |
| 115 | pnggccrd.o: pnggccrd.c png.h pngconf.h |
| 116 | $(CC) -c $(CFLAGS) -o $@ $*.c |
| 117 | |
| 118 | pnggccrd.pic.o: pnggccrd.c png.h pngconf.h |
| 119 | $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c |
| 120 | |
| 121 | $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) |
| 122 | ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so |
| 123 | |
| 124 | $(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) |
| 125 | ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) |
| 126 | |
| 127 | $(LIBNAME).so.$(PNGVER): $(OBJSDLL) |
| 128 | $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \ |
| 129 | -o $(LIBNAME).so.$(PNGVER) \ |
| 130 | $(OBJSDLL) |
| 131 | |
| 132 | libpng.so.3.$(PNGMIN): $(OBJSDLL) |
| 133 | $(CC) -shared -Wl,-soname,libpng.so.3 \ |
| 134 | -o libpng.so.3.$(PNGMIN) \ |
| 135 | $(OBJSDLL) |
| 136 | |
| 137 | pngtest: pngtest.o $(LIBNAME).so |
| 138 | $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) |
| 139 | |
| 140 | pngtest-static: pngtest.o libpng.a |
| 141 | $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) |
| 142 | |
| 143 | test: pngtest pngtest-static |
| 144 | @echo "" |
| 145 | @echo " Running pngtest dynamically linked with $(LIBNAME).so:" |
| 146 | @echo "" |
| 147 | ./pngtest |
| 148 | @echo "" |
| 149 | @echo " Running pngtest statically linked with libpng.a:" |
| 150 | @echo "" |
| 151 | ./pngtest-static |
| 152 | |
| 153 | install-headers: png.h pngconf.h |
| 154 | -@if [ ! -d $(DI) ]; then mkdir $(DI); fi |
| 155 | -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi |
| 156 | cp png.h pngconf.h $(DI)/$(LIBNAME) |
| 157 | chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h |
| 158 | -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h |
| 159 | -@/bin/rm -f $(DI)/libpng |
| 160 | (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) |
| 161 | |
| 162 | install-static: install-headers libpng.a |
| 163 | -@if [ ! -d $(DL) ]; then mkdir $(DL); fi |
| 164 | cp libpng.a $(DL)/$(LIBNAME).a |
| 165 | chmod 644 $(DL)/$(LIBNAME).a |
| 166 | -@/bin/rm -f $(DL)/libpng.a |
| 167 | (cd $(DL); ln -sf $(LIBNAME).a libpng.a) |
| 168 | |
| 169 | install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ |
| 170 | libpng.so.3.$(PNGMIN) |
| 171 | -@if [ ! -d $(DL) ]; then mkdir $(DL); fi |
| 172 | -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so |
| 173 | -@/bin/rm -f $(DL)/libpng.so |
| 174 | -@/bin/rm -f $(DL)/libpng.so.3 |
| 175 | -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* |
| 176 | cp $(LIBNAME).so.$(PNGVER) $(DL) |
| 177 | cp libpng.so.3.$(PNGMIN) $(DL) |
| 178 | chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) |
| 179 | chmod 755 $(DL)/libpng.so.3.$(PNGMIN) |
| 180 | (cd $(DL); \ |
| 181 | ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \ |
| 182 | ln -sf libpng.so.3 libpng.so; \ |
| 183 | ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ |
| 184 | ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) |
| 185 | -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi |
| 186 | -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc |
| 187 | -@/bin/rm -f $(DL)/pkgconfig/libpng.pc |
| 188 | cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc |
| 189 | chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc |
| 190 | (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) |
| 191 | |
| 192 | install-man: libpng.3 libpngpf.3 png.5 |
| 193 | -@if [ ! -d $(DM) ]; then mkdir $(DM); fi |
| 194 | -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi |
| 195 | -@/bin/rm -f $(DM)/man3/libpng.3 |
| 196 | -@/bin/rm -f $(DM)/man3/libpngpf.3 |
| 197 | cp libpng.3 $(DM)/man3 |
| 198 | cp libpngpf.3 $(DM)/man3 |
| 199 | -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi |
| 200 | -@/bin/rm -f $(DM)/man5/png.5 |
| 201 | cp png.5 $(DM)/man5 |
| 202 | |
| 203 | install-config: libpng-config |
| 204 | -@if [ ! -d $(DB) ]; then mkdir $(DB); fi |
| 205 | -@/bin/rm -f $(DB)/libpng-config |
| 206 | -@/bin/rm -f $(DB)/$(LIBNAME)-config |
| 207 | cp libpng-config $(DB)/$(LIBNAME)-config |
| 208 | chmod 755 $(DB)/$(LIBNAME)-config |
| 209 | (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) |
| 210 | |
| 211 | install: install-static install-shared install-man install-config |
| 212 | |
| 213 | # If you installed in $(DESTDIR), test-installed won't work until you |
| 214 | # move the library to its final location. |
| 215 | |
| 216 | test-installed: |
| 217 | $(CC) -I$(ZLIBINC) \ |
| 218 | `$(BINPATH)/libpng12-config --cflags` pngtest.c \ |
| 219 | -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ |
| 220 | -o pngtesti `$(BINPATH)/libpng12-config --ldflags` |
| 221 | ./pngtesti pngtest.png |
| 222 | |
| 223 | clean: |
| 224 | /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \ |
| 225 | $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \ |
| 226 | libpng.so.3.$(PNGMIN) \ |
| 227 | libpng.pc |
| 228 | |
| 229 | DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO |
| 230 | writelock: |
| 231 | chmod a-w *.[ch35] $(DOCS) scripts/* |
| 232 | |
| 233 | png.o png.pic.o: png.h pngconf.h png.c |
| 234 | pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c |
| 235 | pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c |
| 236 | pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c |
| 237 | pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c |
| 238 | pngset.o pngset.pic.o: png.h pngconf.h pngset.c |
| 239 | pngget.o pngget.pic.o: png.h pngconf.h pngget.c |
| 240 | pngread.o pngread.pic.o: png.h pngconf.h pngread.c |
| 241 | pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c |
| 242 | pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c |
| 243 | pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c |
| 244 | pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c |
| 245 | pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c |
| 246 | pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c |
| 247 | pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c |
| 248 | |
| 249 | pngtest.o: png.h pngconf.h pngtest.c |