makefile.linux 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 = 37
  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 $(ALIGN) # $(WARNMORE) -g
  45. LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
  46. LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
  47. INCPATH=$(prefix)/include
  48. LIBPATH=$(exec_prefix)/lib
  49. MANPATH=$(prefix)/man
  50. BINPATH=$(exec_prefix)/bin
  51. # override DESTDIR= on the make install command line to easily support
  52. # installing into a temporary location. Example:
  53. #
  54. # make install DESTDIR=/tmp/build/libpng
  55. #
  56. # If you're going to install into a temporary location
  57. # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
  58. # you execute make install.
  59. DESTDIR=
  60. DB=$(DESTDIR)$(BINPATH)
  61. DI=$(DESTDIR)$(INCPATH)
  62. DL=$(DESTDIR)$(LIBPATH)
  63. DM=$(DESTDIR)$(MANPATH)
  64. # Pre-built configuration
  65. # See scripts/pnglibconf.mak for more options
  66. PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
  67. OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
  68. pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
  69. pngwtran.o pngmem.o pngerror.o pngpread.o
  70. OBJSDLL = $(OBJS:.o=.pic.o)
  71. .SUFFIXES: .c .o .pic.o
  72. .c.o:
  73. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  74. .c.pic.o:
  75. $(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
  76. all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
  77. pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
  78. $(CP) $(PNGLIBCONF_H_PREBUILT) $@
  79. libpng.a: $(OBJS)
  80. $(AR_RC) $@ $(OBJS)
  81. $(RANLIB) $@
  82. libpng.pc:
  83. cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
  84. -e s!@exec_prefix@!$(exec_prefix)! \
  85. -e s!@libdir@!$(LIBPATH)! \
  86. -e s!@includedir@!$(INCPATH)! \
  87. -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
  88. libpng-config:
  89. ( cat scripts/libpng-config-head.in; \
  90. echo prefix=\"$(prefix)\"; \
  91. echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
  92. echo L_opts=\"-L$(LIBPATH)\"; \
  93. echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
  94. echo libs=\"-lpng16 -lz -lm\"; \
  95. cat scripts/libpng-config-body.in ) > libpng-config
  96. chmod +x libpng-config
  97. $(LIBSO): $(LIBSOMAJ)
  98. $(LN_SF) $(LIBSOMAJ) $(LIBSO)
  99. $(LIBSOMAJ): $(OBJSDLL)
  100. $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ) $(OBJSDLL)
  101. pngtest: pngtest.o $(LIBSO)
  102. $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
  103. pngtest-static: pngtest.o libpng.a
  104. $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
  105. test: pngtest pngtest-static
  106. @echo ""
  107. @echo " Running pngtest dynamically linked with $(LIBSO):"
  108. @echo ""
  109. ./pngtest
  110. @echo ""
  111. @echo " Running pngtest statically linked with libpng.a:"
  112. @echo ""
  113. ./pngtest-static
  114. install-headers: png.h pngconf.h pnglibconf.h
  115. -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
  116. -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
  117. cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
  118. chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
  119. -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
  120. -@$(RM_F) $(DI)/libpng
  121. (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
  122. install-static: install-headers libpng.a
  123. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  124. cp libpng.a $(DL)/$(LIBNAME).a
  125. chmod 644 $(DL)/$(LIBNAME).a
  126. -@$(RM_F) $(DL)/libpng.a
  127. (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
  128. install-shared: install-headers $(LIBSOMAJ) libpng.pc
  129. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  130. -@$(RM_F) $(DL)/$(LIBSO)
  131. -@$(RM_F) $(DL)/$(LIBSOREL)
  132. -@$(RM_F) $(DL)/$(OLDSO)
  133. cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
  134. chmod 755 $(DL)/$(LIBSOREL)
  135. (cd $(DL); \
  136. $(LN_SF) $(LIBSOREL) $(LIBSO); \
  137. $(LN_SF) $(LIBSO) $(OLDSO))
  138. -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
  139. -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
  140. -@$(RM_F) $(DL)/pkgconfig/libpng.pc
  141. cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
  142. chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
  143. (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
  144. install-man: libpng.3 libpngpf.3 png.5
  145. -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
  146. -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
  147. -@$(RM_F) $(DM)/man3/libpng.3
  148. -@$(RM_F) $(DM)/man3/libpngpf.3
  149. cp libpng.3 $(DM)/man3
  150. cp libpngpf.3 $(DM)/man3
  151. -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
  152. -@$(RM_F) $(DM)/man5/png.5
  153. cp png.5 $(DM)/man5
  154. install-config: libpng-config
  155. -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
  156. -@$(RM_F) $(DB)/libpng-config
  157. -@$(RM_F) $(DB)/$(LIBNAME)-config
  158. cp libpng-config $(DB)/$(LIBNAME)-config
  159. chmod 755 $(DB)/$(LIBNAME)-config
  160. (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
  161. install: install-static install-shared install-man install-config
  162. # If you installed in $(DESTDIR), test-installed won't work until you
  163. # move the library to its final location. Use test-dd to test it
  164. # before then.
  165. test-dd:
  166. echo
  167. echo Testing installed dynamic shared library in $(DL).
  168. $(CC) -I$(DI) $(CPPFLAGS) \
  169. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  170. -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
  171. -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
  172. ./pngtestd pngtest.png
  173. test-installed:
  174. $(CC) $(CPPFLAGS) \
  175. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  176. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
  177. -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
  178. ./pngtesti pngtest.png
  179. clean:
  180. $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
  181. $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
  182. libpng.pc pnglibconf.h
  183. DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
  184. writelock:
  185. chmod a-w *.[ch35] $(DOCS) scripts/*
  186. # DO NOT DELETE THIS LINE -- make depend depends on it.
  187. png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  188. pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  189. pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  190. pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  191. pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  192. pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  193. pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  194. pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  195. pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  196. pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  197. pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  198. pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  199. pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  200. pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  201. pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  202. pngtest.o: png.h pngconf.h pnglibconf.h