makefile.linux 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 = 10
  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. RM_F=/bin/rm -f
  25. # where "make install" puts libpng16.a, libpng16.so*,
  26. # libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
  27. # Prefix must be a full pathname.
  28. prefix=/usr/local
  29. exec_prefix=$(prefix)
  30. # Where the zlib library and include files are located.
  31. #ZLIBLIB=/usr/local/lib
  32. #ZLIBINC=/usr/local/include
  33. ZLIBLIB=../zlib
  34. ZLIBINC=../zlib
  35. ALIGN=
  36. # for i386:
  37. #ALIGN=-malign-loops=2 -malign-functions=2
  38. WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
  39. -Wmissing-declarations -Wtraditional -Wcast-align \
  40. -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
  41. # for pgcc version 2.95.1, -O3 is buggy; don't use it.
  42. CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
  43. CFLAGS= -W -Wall -O3 -funroll-loops \
  44. $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
  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. OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
  65. pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
  66. pngwtran.o pngmem.o pngerror.o pngpread.o
  67. OBJSDLL = $(OBJS:.o=.pic.o)
  68. .SUFFIXES: .c .o .pic.o
  69. .c.o:
  70. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  71. .c.pic.o:
  72. $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
  73. all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
  74. # see scripts/pnglibconf.mak for more options
  75. pnglibconf.h: scripts/pnglibconf.h.prebuilt
  76. cp scripts/pnglibconf.h.prebuilt $@
  77. libpng.a: $(OBJS)
  78. $(AR_RC) $@ $(OBJS)
  79. $(RANLIB) $@
  80. libpng.pc:
  81. cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
  82. -e s!@exec_prefix@!$(exec_prefix)! \
  83. -e s!@libdir@!$(LIBPATH)! \
  84. -e s!@includedir@!$(INCPATH)! \
  85. -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
  86. libpng-config:
  87. ( cat scripts/libpng-config-head.in; \
  88. echo prefix=\"$(prefix)\"; \
  89. echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
  90. echo L_opts=\"-L$(LIBPATH)\"; \
  91. echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
  92. echo libs=\"-lpng16 -lz -lm\"; \
  93. cat scripts/libpng-config-body.in ) > libpng-config
  94. chmod +x libpng-config
  95. $(LIBSO): $(LIBSOMAJ)
  96. $(LN_SF) $(LIBSOMAJ) $(LIBSO)
  97. $(LIBSOMAJ): $(OBJSDLL)
  98. $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ) $(OBJSDLL)
  99. pngtest: pngtest.o $(LIBSO)
  100. $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
  101. pngtest-static: pngtest.o libpng.a
  102. $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
  103. test: pngtest pngtest-static
  104. @echo ""
  105. @echo " Running pngtest dynamically linked with $(LIBSO):"
  106. @echo ""
  107. ./pngtest
  108. @echo ""
  109. @echo " Running pngtest statically linked with libpng.a:"
  110. @echo ""
  111. ./pngtest-static
  112. install-headers: png.h pngconf.h pnglibconf.h
  113. -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
  114. -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
  115. cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
  116. chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
  117. -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
  118. -@$(RM_F) $(DI)/libpng
  119. (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
  120. install-static: install-headers libpng.a
  121. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  122. cp libpng.a $(DL)/$(LIBNAME).a
  123. chmod 644 $(DL)/$(LIBNAME).a
  124. -@$(RM_F) $(DL)/libpng.a
  125. (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
  126. install-shared: install-headers $(LIBSOMAJ) libpng.pc
  127. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  128. -@$(RM_F) $(DL)/$(LIBSO)
  129. -@$(RM_F) $(DL)/$(LIBSOREL)
  130. -@$(RM_F) $(DL)/$(OLDSO)
  131. cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
  132. chmod 755 $(DL)/$(LIBSOREL)
  133. (cd $(DL); \
  134. $(LN_SF) $(LIBSOREL) $(LIBSO); \
  135. $(LN_SF) $(LIBSO) $(OLDSO))
  136. -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
  137. -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
  138. -@$(RM_F) $(DL)/pkgconfig/libpng.pc
  139. cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
  140. chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
  141. (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
  142. install-man: libpng.3 libpngpf.3 png.5
  143. -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
  144. -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
  145. -@$(RM_F) $(DM)/man3/libpng.3
  146. -@$(RM_F) $(DM)/man3/libpngpf.3
  147. cp libpng.3 $(DM)/man3
  148. cp libpngpf.3 $(DM)/man3
  149. -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
  150. -@$(RM_F) $(DM)/man5/png.5
  151. cp png.5 $(DM)/man5
  152. install-config: libpng-config
  153. -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
  154. -@$(RM_F) $(DB)/libpng-config
  155. -@$(RM_F) $(DB)/$(LIBNAME)-config
  156. cp libpng-config $(DB)/$(LIBNAME)-config
  157. chmod 755 $(DB)/$(LIBNAME)-config
  158. (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
  159. install: install-static install-shared install-man install-config
  160. # If you installed in $(DESTDIR), test-installed won't work until you
  161. # move the library to its final location. Use test-dd to test it
  162. # before then.
  163. test-dd:
  164. echo
  165. echo Testing installed dynamic shared library in $(DL).
  166. $(CC) -I$(DI) $(CPPFLAGS) \
  167. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  168. -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
  169. -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
  170. ./pngtestd pngtest.png
  171. test-installed:
  172. $(CC) $(CPPFLAGS) \
  173. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  174. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
  175. -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
  176. ./pngtesti pngtest.png
  177. clean:
  178. $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
  179. $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
  180. libpng.pc pnglibconf.h
  181. DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
  182. writelock:
  183. chmod a-w *.[ch35] $(DOCS) scripts/*
  184. # DO NOT DELETE THIS LINE -- make depend depends on it.
  185. png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  186. pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  187. pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  188. pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  189. pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  190. pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  191. pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  192. pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  193. pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  194. pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  195. pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  196. pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  197. pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  198. pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  199. pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  200. pngtest.o: png.h pngconf.h pnglibconf.h