makefile.elf 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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
  3. # and 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. # Modified for Debian by Junichi Uekawa and Josselin Mouette
  10. # Major modifications are:
  11. # * link libpng explicitly with libz and libm
  12. # * $(OLDSO).15 is a symlink rather than a different library
  13. # * versioned symbols
  14. # Library name:
  15. LIBNAME = libpng15
  16. PNGMAJ = 15
  17. # Shared library names:
  18. LIBSO=$(LIBNAME).so
  19. LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
  20. LIBSOREL=$(LIBSOMAJ).$(RELEASE)
  21. OLDSO=libpng.so
  22. OLDSOMAJ=libpng.so.15
  23. # Utilities:
  24. AR_RC=ar rc
  25. CC=gcc
  26. MKDIR_P=mkdir -p
  27. LN_SF=ln -sf
  28. RANLIB=ranlib
  29. RM_F=/bin/rm -f
  30. # where "make install" puts libpng15.a, libpng15.so*,
  31. # libpng15/png.h, libpng15/pngconf.h, and libpng15/pnglibconf.h
  32. # Prefix must be a full pathname.
  33. prefix=/usr/local
  34. exec_prefix=$(prefix)
  35. # Where the zlib library and include files are located.
  36. ZLIBLIB=/usr/local/lib
  37. ZLIBINC=/usr/local/include
  38. # ZLIBLIB=../zlib
  39. # ZLIBINC=../zlib
  40. ALIGN=
  41. # for i386:
  42. #ALIGN=-malign-loops=2 -malign-functions=2
  43. WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
  44. -Wmissing-declarations -Wtraditional -Wcast-align \
  45. -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
  46. # for pgcc version 2.95.1, -O3 is buggy; don't use it.
  47. CFLAGS=-W -Wall -D_REENTRANT -O2 \
  48. $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
  49. LDFLAGS=-L. -lpng15
  50. LDFLAGS_A=libpng.a -lz -lm
  51. LIBADDFLAGS=-lz -lm
  52. INCPATH=$(prefix)/include
  53. LIBPATH=$(exec_prefix)/lib
  54. MANPATH=$(prefix)/man
  55. BINPATH=$(exec_prefix)/bin
  56. # override DESTDIR= on the make install command line to easily support
  57. # installing into a temporary location. Example:
  58. #
  59. # make install DESTDIR=/tmp/build/libpng
  60. #
  61. # If you're going to install into a temporary location
  62. # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
  63. # you execute make install.
  64. DESTDIR=
  65. DB=$(DESTDIR)$(BINPATH)
  66. DI=$(DESTDIR)$(INCPATH)
  67. DL=$(DESTDIR)$(LIBPATH)
  68. DM=$(DESTDIR)$(MANPATH)
  69. OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
  70. pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
  71. pngwtran.o pngmem.o pngerror.o pngpread.o
  72. OBJSDLL = $(OBJS:.o=.pic.o)
  73. .SUFFIXES: .c .o .pic.o
  74. .c.pic.o:
  75. $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
  76. all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
  77. # see scripts/pnglibconf.mak for more options
  78. pnglibconf.h: scripts/pnglibconf.h.prebuilt
  79. cp scripts/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!-lpng15!-lpng15\ -lz\ -lm! > libpng.pc
  89. libpng.syms: png.h pngconf.h pnglibconf.h
  90. $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
  91. awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG15_%s {global:\n",PNGMAJ)}\
  92. { for (i=1;i+2<=NF;++i)\
  93. if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
  94. print $$(i+1) ";";\
  95. for (i=1;i+1<=NF;++i)\
  96. if ($$(i)=="PNG_DATA_EXPORT")\
  97. print $$(i+1) ";";}\
  98. END{print "local: *; };"}' >$@.new
  99. $(RM_F) $@
  100. mv $@.new $@
  101. libpng-config:
  102. ( cat scripts/libpng-config-head.in; \
  103. echo prefix=\"$(prefix)\"; \
  104. echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
  105. echo L_opts=\"\"; \
  106. echo R_opts=\"\"; \
  107. echo libs=\"-lpng15\"; \
  108. echo all_libs=\"-lpng15 $(LIBADDFLAGS)\"; \
  109. cat scripts/libpng-config-body.in ) > libpng-config
  110. chmod +x libpng-config
  111. $(LIBSO): $(LIBSOMAJ)
  112. $(LN_SF) $(LIBSOMAJ) $(LIBSO)
  113. $(LIBSOMAJ): $(OBJSDLL) libpng.syms
  114. $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
  115. -Wl,-version-script,libpng.syms \
  116. -o $(LIBSOMAJ) \
  117. $(OBJSDLL)
  118. pngtest: pngtest.o $(LIBSO)
  119. $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
  120. pngtest-static: pngtest.o libpng.a
  121. $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
  122. test: pngtest pngtest-static
  123. @echo ""
  124. @echo " Running pngtest dynamically linked with $(LIBSO):"
  125. @echo ""
  126. LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest
  127. @echo ""
  128. @echo " Running pngtest statically linked with libpng.a:"
  129. @echo ""
  130. ./pngtest-static
  131. install-headers: png.h pngconf.h pnglibconf.h
  132. -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
  133. -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
  134. cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
  135. chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
  136. -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
  137. -@$(RM_F) $(DI)/libpng
  138. (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
  139. install-static: install-headers libpng.a
  140. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  141. cp libpng.a $(DL)/$(LIBNAME).a
  142. chmod 644 $(DL)/$(LIBNAME).a
  143. -@$(RM_F) $(DL)/libpng.a
  144. (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
  145. install-shared: install-headers $(LIBSOMAJ) libpng.pc
  146. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  147. -@$(RM_F) $(DL)/$(LIBSO)
  148. -@$(RM_F) $(DL)/$(LIBSOREL)
  149. -@$(RM_F) $(DL)/$(OLDSO)
  150. cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
  151. chmod 755 $(DL)/$(LIBSOREL)
  152. (cd $(DL); \
  153. $(LN_SF) $(LIBSOREL) $(LIBSO); \
  154. $(LN_SF) $(LIBSO) $(OLDSO))
  155. -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
  156. -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
  157. -@$(RM_F) $(DL)/pkgconfig/libpng.pc
  158. cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
  159. chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
  160. (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
  161. install-man: libpng.3 libpngpf.3 png.5
  162. -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
  163. -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
  164. -@$(RM_F) $(DM)/man3/libpng.3
  165. -@$(RM_F) $(DM)/man3/libpngpf.3
  166. cp libpng.3 $(DM)/man3
  167. cp libpngpf.3 $(DM)/man3
  168. -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
  169. -@$(RM_F) $(DM)/man5/png.5
  170. cp png.5 $(DM)/man5
  171. install-config: libpng-config
  172. -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
  173. -@$(RM_F) $(DB)/libpng-config
  174. -@$(RM_F) $(DB)/$(LIBNAME)-config
  175. cp libpng-config $(DB)/$(LIBNAME)-config
  176. chmod 755 $(DB)/$(LIBNAME)-config
  177. (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
  178. install: install-static install-shared install-man install-config
  179. # If you installed in $(DESTDIR), test-installed won't work until you
  180. # move the library to its final location. Use test-dd to test it
  181. # before then.
  182. test-dd:
  183. echo
  184. echo Testing installed dynamic shared library in $(DL).
  185. $(CC) -I$(DI) -I$(ZLIBINC) \
  186. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  187. -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
  188. -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
  189. ./pngtestd pngtest.png
  190. test-installed:
  191. $(CC) -I$(ZLIBINC) \
  192. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  193. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
  194. -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
  195. ./pngtesti pngtest.png
  196. clean:
  197. $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
  198. $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
  199. libpng.pc pnglibconf.h
  200. DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
  201. writelock:
  202. chmod a-w *.[ch35] $(DOCS) scripts/*
  203. # DO NOT DELETE THIS LINE -- make depend depends on it.
  204. png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  205. pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  206. pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  207. pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  208. pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  209. pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  210. pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  211. pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  212. pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  213. pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  214. pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  215. pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  216. pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  217. pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  218. pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  219. pngtest.o: png.h pngconf.h pnglibconf.h