makefile.elf 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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
  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).16 is a symlink rather than a different library
  13. # * versioned symbols
  14. # Library name:
  15. LIBNAME = libpng16
  16. PNGMAJ = 16
  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.16
  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 libpng16.a, libpng16.so*,
  31. # libpng16/png.h, libpng16/pngconf.h, and libpng16/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. CPPFLAGS=-D_REENTRANT # -DPNG_DEBUG=5
  48. CFLAGS=-W -Wall -O2 $(ALIGN) # $(WARNMORE) -g
  49. LDFLAGS=-L. -lpng16
  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.o:
  75. $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
  76. .c.pic.o:
  77. $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
  78. all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
  79. # see scripts/pnglibconf.mak for more options
  80. pnglibconf.h: scripts/pnglibconf.h.prebuilt
  81. cp scripts/pnglibconf.h.prebuilt $@
  82. libpng.a: $(OBJS)
  83. $(AR_RC) $@ $(OBJS)
  84. $(RANLIB) $@
  85. libpng.pc:
  86. cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
  87. -e s!@exec_prefix@!$(exec_prefix)! \
  88. -e s!@libdir@!$(LIBPATH)! \
  89. -e s!@includedir@!$(INCPATH)! \
  90. -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
  91. libpng.syms: png.h pngconf.h pnglibconf.h
  92. $(CC) $(CPPFLAGS) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
  93. awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG16_%s {global:\n",PNGMAJ)}\
  94. { for (i=1;i+2<=NF;++i)\
  95. if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
  96. print $$(i+1) ";";\
  97. for (i=1;i+1<=NF;++i)\
  98. if ($$(i)=="PNG_DATA_EXPORT")\
  99. print $$(i+1) ";";}\
  100. END{print "local: *; };"}' >[email protected]
  101. $(RM_F) $@
  102. mv [email protected] $@
  103. libpng-config:
  104. ( cat scripts/libpng-config-head.in; \
  105. echo prefix=\"$(prefix)\"; \
  106. echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
  107. echo L_opts=\"\"; \
  108. echo R_opts=\"\"; \
  109. echo libs=\"-lpng16\"; \
  110. echo all_libs=\"-lpng16 $(LIBADDFLAGS)\"; \
  111. cat scripts/libpng-config-body.in ) > libpng-config
  112. chmod +x libpng-config
  113. $(LIBSO): $(LIBSOMAJ)
  114. $(LN_SF) $(LIBSOMAJ) $(LIBSO)
  115. $(LIBSOMAJ): $(OBJSDLL) libpng.syms
  116. $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
  117. -Wl,-version-script,libpng.syms \
  118. -o $(LIBSOMAJ) \
  119. $(OBJSDLL)
  120. pngtest: pngtest.o $(LIBSO)
  121. $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
  122. pngtest-static: pngtest.o libpng.a
  123. $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
  124. test: pngtest pngtest-static
  125. @echo ""
  126. @echo " Running pngtest dynamically linked with $(LIBSO):"
  127. @echo ""
  128. LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest
  129. @echo ""
  130. @echo " Running pngtest statically linked with libpng.a:"
  131. @echo ""
  132. ./pngtest-static
  133. install-headers: png.h pngconf.h pnglibconf.h
  134. -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
  135. -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
  136. cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
  137. chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
  138. -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
  139. -@$(RM_F) $(DI)/libpng
  140. (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
  141. install-static: install-headers libpng.a
  142. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  143. cp libpng.a $(DL)/$(LIBNAME).a
  144. chmod 644 $(DL)/$(LIBNAME).a
  145. -@$(RM_F) $(DL)/libpng.a
  146. (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
  147. install-shared: install-headers $(LIBSOMAJ) libpng.pc
  148. -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
  149. -@$(RM_F) $(DL)/$(LIBSO)
  150. -@$(RM_F) $(DL)/$(LIBSOREL)
  151. -@$(RM_F) $(DL)/$(OLDSO)
  152. cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
  153. chmod 755 $(DL)/$(LIBSOREL)
  154. (cd $(DL); \
  155. $(LN_SF) $(LIBSOREL) $(LIBSO); \
  156. $(LN_SF) $(LIBSO) $(OLDSO))
  157. -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
  158. -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
  159. -@$(RM_F) $(DL)/pkgconfig/libpng.pc
  160. cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
  161. chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
  162. (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
  163. install-man: libpng.3 libpngpf.3 png.5
  164. -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
  165. -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
  166. -@$(RM_F) $(DM)/man3/libpng.3
  167. -@$(RM_F) $(DM)/man3/libpngpf.3
  168. cp libpng.3 $(DM)/man3
  169. cp libpngpf.3 $(DM)/man3
  170. -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
  171. -@$(RM_F) $(DM)/man5/png.5
  172. cp png.5 $(DM)/man5
  173. install-config: libpng-config
  174. -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
  175. -@$(RM_F) $(DB)/libpng-config
  176. -@$(RM_F) $(DB)/$(LIBNAME)-config
  177. cp libpng-config $(DB)/$(LIBNAME)-config
  178. chmod 755 $(DB)/$(LIBNAME)-config
  179. (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
  180. install: install-static install-shared install-man install-config
  181. # If you installed in $(DESTDIR), test-installed won't work until you
  182. # move the library to its final location. Use test-dd to test it
  183. # before then.
  184. test-dd:
  185. echo
  186. echo Testing installed dynamic shared library in $(DL).
  187. $(CC) -I$(DI) $(CPPFLAGS) \
  188. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  189. -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
  190. -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
  191. ./pngtestd pngtest.png
  192. test-installed:
  193. $(CC) $(CPPFLAGS) \
  194. `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
  195. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
  196. -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
  197. ./pngtesti pngtest.png
  198. clean:
  199. $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
  200. $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
  201. libpng.pc pnglibconf.h
  202. DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
  203. writelock:
  204. chmod a-w *.[ch35] $(DOCS) scripts/*
  205. # DO NOT DELETE THIS LINE -- make depend depends on it.
  206. png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  207. pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  208. pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  209. pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  210. pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  211. pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  212. pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  213. pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  214. pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  215. pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  216. pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  217. pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  218. pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  219. pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  220. pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
  221. pngtest.o: png.h pngconf.h pnglibconf.h