makefile.linux 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. # makefile for libpng.a and libpng16.so on Linux ELF with gcc
  2. # Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 Greg Roelofs and
  3. # Glenn Randers-Pehrson
  4. # Copyright (C) 1996, 1997 Andreas Dilger
  5. #
  6. # This code is released under the libpng license.
  7. # For conditions of distribution and use, see the disclaimer
  8. # and license in png.h
  9. # Library name:
  10. LIBNAME = libpng16
  11. PNGMAJ = 16
  12. RELEASE = 20
  13. # Shared library names:
  14. LIBSO=$(LIBNAME).so
  15. LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
  16. LIBSOREL=$(LIBSOMAJ).$(RELEASE)
  17. OLDSO=libpng.so
  18. # Utilities:
  19. AR_RC=ar rc
  20. CC=gcc
  21. MKDIR_P=mkdir -p
  22. LN_SF=ln -sf
  23. RANLIB=ranlib
  24. CP=cp
  25. RM_F=/bin/rm -f
  26. # where "make install" puts libpng16.a, libpng16.so*,
  27. # libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
  28. # Prefix must be a full pathname.
  29. prefix=/usr/local
  30. exec_prefix=$(prefix)
  31. # Where the zlib library and include files are located.
  32. #ZLIBLIB=/usr/local/lib
  33. #ZLIBINC=/usr/local/include
  34. ZLIBLIB=../zlib
  35. ZLIBINC=../zlib
  36. ALIGN=
  37. # for i386:
  38. #ALIGN=-malign-loops=2 -malign-functions=2
  39. WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
  40. -Wmissing-declarations -Wtraditional -Wcast-align \
  41. -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
  42. # for pgcc version 2.95.1, -O3 is buggy; don't use it.
  43. CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
  44. CFLAGS= -W -Wall -O3 -funroll-loops \
  45. $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
  46. LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
  47. LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
  48. INCPATH=$(prefix)/include
  49. LIBPATH=$(exec_prefix)/lib
  50. MANPATH=$(prefix)/man
  51. BINPATH=$(exec_prefix)/bin
  52. # override DESTDIR= on the make install command line to easily support
  53. # installing into a temporary location. Example:
  54. #
  55. # make install DESTDIR=/tmp/build/libpng
  56. #
  57. # If you're going to install into a temporary location
  58. # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
  59. # you execute make install.
  60. DESTDIR=
  61. DB=$(DESTDIR)$(BINPATH)
  62. DI=$(DESTDIR)$(INCPATH)
  63. DL=$(DESTDIR)$(LIBPATH)
  64. DM=$(DESTDIR)$(MANPATH)
  65. # Pre-built configuration
  66. # See scripts/pnglibconf.mak for more options
  67. PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
  68. OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
  69. pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
  70. pngwtran.o pngmem.o pngerror.o pngpread.o
  71. OBJSDLL = $(OBJS:.o=.pic.o)
  72. .SUFFIXES: .c .o .pic.o
  73. .c.o:
  74. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  75. .c.pic.o:
  76. $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
  77. all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
  78. pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
  79. $(CP) $(PNGLIBCONF_H_PREBUILT) $@
  80. libpng.a: $(OBJS)
  81. $(AR_RC) $@ $(OBJS)
  82. $(RANLIB) $@
  83. libpng.pc:
  84. cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
  85. -e s!@exec_prefix@!$(exec_prefix)! \
  86. -e s!@libdir@!$(LIBPATH)! \
  87. -e s!@includedir@!$(INCPATH)! \
  88. -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
  89. libpng-config:
  90. ( cat scripts/libpng-config-head.in; \
  91. echo prefix=\"$(prefix)\"; \
  92. echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
  93. echo L_opts=\"-L$(LIBPATH)\"; \
  94. echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
  95. echo libs=\"-lpng16 -lz -lm\"; \
  96. cat scripts/libpng-config-body.in ) > libpng-config
  97. chmod +x libpng-config
  98. $(LIBSO): $(LIBSOMAJ)
  99. $(LN_SF) $(LIBSOMAJ) $(LIBSO)
  100. $(LIBSOMAJ): $(OBJSDLL)
  101. $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ) $(OBJSDLL)
  102. pngtest: pngtest.o $(LIBSO)
  103. $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
  104. pngtest-static: pngtest.o libpng.a
  105. $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
  106. test: pngtest pngtest-static
  107. @echo ""
  108. @echo " Running pngtest dynamically linked with $(LIBSO):"
  109. @echo ""
  110. ./pngtest
  111. @echo ""
  112. @echo " Running pngtest statically linked with libpng.a:"
  113. @echo ""
  114. ./pngtest-static
  115. install-headers: png.h pngconf.h pnglibconf.h
  116. -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
  117. -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
  118. cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
  119. chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
  120. -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
  121. -@$(RM_F) $(DI)/libpng
  122. (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
  123. install-static: install-headers libpng.a
  124. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  125. cp libpng.a $(DL)/$(LIBNAME).a
  126. chmod 644 $(DL)/$(LIBNAME).a
  127. -@$(RM_F) $(DL)/libpng.a
  128. (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
  129. install-shared: install-headers $(LIBSOMAJ) libpng.pc
  130. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  131. -@$(RM_F) $(DL)/$(LIBSO)
  132. -@$(RM_F) $(DL)/$(LIBSOREL)
  133. -@$(RM_F) $(DL)/$(OLDSO)
  134. cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
  135. chmod 755 $(DL)/$(LIBSOREL)
  136. (cd $(DL); \
  137. $(LN_SF) $(LIBSOREL) $(LIBSO); \
  138. $(LN_SF) $(LIBSO) $(OLDSO))
  139. -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
  140. -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
  141. -@$(RM_F) $(DL)/pkgconfig/libpng.pc
  142. cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
  143. chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
  144. (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
  145. install-man: libpng.3 libpngpf.3 png.5
  146. -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
  147. -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
  148. -@$(RM_F) $(DM)/man3/libpng.3
  149. -@$(RM_F) $(DM)/man3/libpngpf.3
  150. cp libpng.3 $(DM)/man3
  151. cp libpngpf.3 $(DM)/man3
  152. -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
  153. -@$(RM_F) $(DM)/man5/png.5
  154. cp png.5 $(DM)/man5
  155. install-config: libpng-config
  156. -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
  157. -@$(RM_F) $(DB)/libpng-config
  158. -@$(RM_F) $(DB)/$(LIBNAME)-config
  159. cp libpng-config $(DB)/$(LIBNAME)-config
  160. chmod 755 $(DB)/$(LIBNAME)-config
  161. (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
  162. install: install-static install-shared install-man install-config
  163. # If you installed in $(DESTDIR), test-installed won't work until you
  164. # move the library to its final location. Use test-dd to test it
  165. # before then.
  166. test-dd:
  167. echo
  168. echo Testing installed dynamic shared library in $(DL).
  169. $(CC) -I$(DI) $(CPPFLAGS) \
  170. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  171. -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
  172. -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
  173. ./pngtestd pngtest.png
  174. test-installed:
  175. $(CC) $(CPPFLAGS) \
  176. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  177. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
  178. -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
  179. ./pngtesti pngtest.png
  180. clean:
  181. $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
  182. $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
  183. libpng.pc pnglibconf.h
  184. DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
  185. writelock:
  186. chmod a-w *.[ch35] $(DOCS) scripts/*
  187. # DO NOT DELETE THIS LINE -- make depend depends on it.
  188. png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  189. pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  190. pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  191. pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  192. pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  193. pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  194. pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  195. pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  196. pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  197. pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  198. pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  199. pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  200. pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  201. pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  202. pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  203. pngtest.o: png.h pngconf.h pnglibconf.h