xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | # makefile for libpng using MSYS/gcc (shared, static library) |
| 2 | # Copyright (C) 2019 Cosmin Truta |
| 3 | # Copyright (C) 2012 Glenn Randers-Pehrson and Christopher M. Wheeler |
| 4 | # |
| 5 | # Portions taken from makefile.linux and makefile.gcc: |
| 6 | # Copyright (C) 2000 Cosmin Truta |
| 7 | # Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 Greg Roelofs and |
| 8 | # Glenn Randers-Pehrson |
| 9 | # Copyright (C) 1996, 1997 Andreas Dilger |
| 10 | # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. |
| 11 | # |
| 12 | # This code is released under the libpng license. |
| 13 | # For conditions of distribution and use, see the disclaimer |
| 14 | # and license in png.h |
| 15 | # # # # # # # # # # # # # # # # # |
| 16 | prefix=/usr/local |
| 17 | exec_prefix=$(prefix) |
| 18 | |
| 19 | # Library name: |
| 20 | LIBNAME = libpng16 |
| 21 | PNGMAJ = 16 |
| 22 | RELEASE = 37 |
| 23 | |
| 24 | # Shared library names: |
| 25 | LIBSO=$(LIBNAME).dll |
| 26 | LIBSOMAJ=$(LIBNAME).dll.$(PNGMAJ) |
| 27 | LIBSOREL=$(PNGMAJ).$(RELEASE) |
| 28 | OLDSO=libpng.dll |
| 29 | |
| 30 | # Where the zlib library and include files are located. |
| 31 | #ZLIBLIB=../zlib |
| 32 | #ZLIBINC=../zlib |
| 33 | ZLIBLIB=/usr/local/lib |
| 34 | ZLIBINC=/usr/local/include |
| 35 | |
| 36 | # Compiler, linker, lib and other tools |
| 37 | CC = gcc |
| 38 | LD = $(CC) |
| 39 | AR_RC = ar rcs |
| 40 | RANLIB = ranlib |
| 41 | CP = cp |
| 42 | RM_F = rm -rf |
| 43 | MKDIR_P=mkdir -p |
| 44 | LN_SF=ln -sf |
| 45 | |
| 46 | #ARCH = -march=pentium3 |
| 47 | #ARCH = -march=i686 |
| 48 | ARCH = |
| 49 | CPPFLAGS = # -DPNG_DEBUG=5 |
| 50 | CFLAGS = -W -Wall -O2 $(ARCH) # -g |
| 51 | LDFLAGS = |
| 52 | LIBS = -lz -lm |
| 53 | |
| 54 | # File extensions |
| 55 | EXEEXT=.exe |
| 56 | |
| 57 | INCPATH=$(prefix)/include |
| 58 | LIBPATH=$(exec_prefix)/lib |
| 59 | MANPATH=$(prefix)/man |
| 60 | BINPATH=$(exec_prefix)/bin |
| 61 | |
| 62 | # override DESTDIR= on the make install command line to easily support |
| 63 | # installing into a temporary location. Example: |
| 64 | # |
| 65 | # make install DESTDIR=/tmp/build/libpng |
| 66 | # |
| 67 | # If you're going to install into a temporary location |
| 68 | # via DESTDIR, $(DESTDIR)$(prefix) must already exist before |
| 69 | # you execute make install. |
| 70 | |
| 71 | DESTDIR= |
| 72 | |
| 73 | DB=$(DESTDIR)$(BINPATH) |
| 74 | DI=$(DESTDIR)$(INCPATH) |
| 75 | DL=$(DESTDIR)$(LIBPATH) |
| 76 | DM=$(DESTDIR)$(MANPATH) |
| 77 | |
| 78 | # Pre-built configuration |
| 79 | # See scripts/pnglibconf.mak for more options |
| 80 | PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt |
| 81 | |
| 82 | # Variables |
| 83 | OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \ |
| 84 | pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \ |
| 85 | pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o |
| 86 | |
| 87 | # Targets |
| 88 | all: static shared |
| 89 | |
| 90 | pnglibconf.h: $(PNGLIBCONF_H_PREBUILT) |
| 91 | $(CP) $(PNGLIBCONF_H_PREBUILT) $@ |
| 92 | |
| 93 | .c.o: |
| 94 | $(CC) -c $(CPPFLAGS) $(CFLAGS) $< |
| 95 | |
| 96 | static: libpng.a pngtest$(EXEEXT) |
| 97 | |
| 98 | shared: $(LIBSOMAJ) |
| 99 | $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSO) |
| 100 | |
| 101 | $(LIBSO): $(LIBSOMAJ) |
| 102 | $(LN_SF) $(LIBSOMAJ) $(LIBSO) |
| 103 | |
| 104 | $(LIBSOMAJ): |
| 105 | $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ) |
| 106 | |
| 107 | libpng.a: $(OBJS) |
| 108 | $(AR_RC) $@ $(OBJS) |
| 109 | $(RANLIB) $@ |
| 110 | |
| 111 | install-headers: png.h pngconf.h pnglibconf.h |
| 112 | -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi |
| 113 | -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi |
| 114 | cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) |
| 115 | -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h |
| 116 | -@$(RM_F) $(DI)/libpng |
| 117 | (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) |
| 118 | |
| 119 | install-static: install-headers libpng.a |
| 120 | -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi |
| 121 | cp libpng.a $(DL)/$(LIBNAME).a |
| 122 | -@$(RM_F) $(DL)/libpng.a |
| 123 | (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) |
| 124 | |
| 125 | libpng.pc: |
| 126 | cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \ |
| 127 | -e s!@exec_prefix@!$(exec_prefix)! \ |
| 128 | -e s!@libdir@!$(LIBPATH)! \ |
| 129 | -e s!@includedir@!$(INCPATH)! \ |
| 130 | -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc |
| 131 | |
| 132 | libpng-config: |
| 133 | ( cat scripts/libpng-config-head.in; \ |
| 134 | echo prefix=\"$(prefix)\"; \ |
| 135 | echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ |
| 136 | echo L_opts=\"-L$(LIBPATH)\"; \ |
| 137 | echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ |
| 138 | echo libs=\"-lpng16 -lz -lm\"; \ |
| 139 | cat scripts/libpng-config-body.in ) > libpng-config |
| 140 | |
| 141 | install-shared: install-headers $(LIBSOMAJ) libpng.pc |
| 142 | -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi |
| 143 | -@$(RM_F) $(DL)/$(LIBSO) |
| 144 | -@$(RM_F) $(DL)/$(OLDSO) |
| 145 | cp $(LIBSO) $(DL)/$(LIBSOREL) |
| 146 | (cd $(DL); \ |
| 147 | $(LN_SF) $(LIBSOREL) $(LIBSO); \ |
| 148 | $(LN_SF) $(LIBSO) $(OLDSO)) |
| 149 | |
| 150 | -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi |
| 151 | -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc |
| 152 | -@$(RM_F) $(DL)/pkgconfig/libpng.pc |
| 153 | cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc |
| 154 | (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) |
| 155 | |
| 156 | install-man: libpng.3 libpngpf.3 png.5 |
| 157 | -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi |
| 158 | -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi |
| 159 | -@$(RM_F) $(DM)/man3/libpng.3 |
| 160 | -@$(RM_F) $(DM)/man3/libpngpf.3 |
| 161 | cp libpng.3 $(DM)/man3 |
| 162 | cp libpngpf.3 $(DM)/man3 |
| 163 | -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi |
| 164 | -@$(RM_F) $(DM)/man5/png.5 |
| 165 | cp png.5 $(DM)/man5 |
| 166 | |
| 167 | install-config: libpng-config |
| 168 | -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi |
| 169 | -@$(RM_F) $(DB)/libpng-config |
| 170 | -@$(RM_F) $(DB)/$(LIBNAME)-config |
| 171 | cp libpng-config $(DB)/$(LIBNAME)-config |
| 172 | (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) |
| 173 | |
| 174 | install: install-static install-shared install-man install-config |
| 175 | |
| 176 | test: pngtest$(EXEEXT) |
| 177 | ./pngtest$(EXEEXT) |
| 178 | |
| 179 | pngtest$(EXEEXT): pngtest.o libpng.a |
| 180 | $(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS) |
| 181 | |
| 182 | clean: |
| 183 | $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h $(LIBSO) \ |
| 184 | $(LIBSOMAJ) libpng-config |
| 185 | |
| 186 | png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 187 | pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 188 | pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 189 | pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 190 | pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 191 | pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 192 | pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 193 | pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 194 | pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 195 | pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 196 | pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 197 | pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 198 | pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 199 | pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 200 | pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
| 201 | |
| 202 | pngtest.o: png.h pngconf.h pnglibconf.h |