makefile.linux 7.9 KB

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