Makefile.unx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
  2. # Greg Roelofs
  3. # Last modified: 2 June 2007
  4. #
  5. # The programs built by this makefile are described in the book,
  6. # "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
  7. # Associates, 1999). Go buy a copy, eh? Well, OK, it's not
  8. # generally for sale anymore, but it's the thought that counts,
  9. # right? (Hint: http://www.libpng.org/pub/png/book/ )
  10. #
  11. # Invoke this makefile from a shell prompt in the usual way; for example:
  12. #
  13. # make -f Makefile.unx
  14. #
  15. # This makefile assumes libpng and zlib have already been built or downloaded
  16. # and are installed in /usr/local/{include,lib} or as otherwise indicated by
  17. # the PNG* and Z* macros below. Edit as appropriate--choose only ONE each of
  18. # the PNGINC, PNGLIBd, PNGLIBs, ZINC, ZLIBd and ZLIBs lines.
  19. #
  20. # This makefile builds both dynamically and statically linked executables
  21. # (against libpng and zlib, that is), but that can be changed by modifying
  22. # the "EXES =" line. (You need only one set, but for testing it can be handy
  23. # to have both.)
  24. # macros --------------------------------------------------------------------
  25. #PNGDIR = /usr/local/lib
  26. #PNGINC = -I/usr/local/include/libpng16
  27. #PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
  28. #PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
  29. # or:
  30. PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
  31. #PNGDIR = ../libpng
  32. PNGINC = -I$(PNGDIR)
  33. PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
  34. PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
  35. ZDIR = /usr/local/lib
  36. #ZDIR = /usr/lib64
  37. ZINC = -I/usr/local/include
  38. ZLIBd = -L$(ZDIR) -lz # dynamically linked against zlib
  39. ZLIBs = $(ZDIR)/libz.a # statically linked against zlib
  40. # or:
  41. #ZDIR = ../zlib
  42. #ZINC = -I$(ZDIR)
  43. #ZLIBd = -Wl,-rpath,$(ZDIR) -L$(ZDIR) -lz # -rpath allows in-place testing
  44. #ZLIBs = $(ZDIR)/libz.a
  45. #XINC = -I/usr/include # old-style, stock X distributions
  46. #XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX)
  47. #XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
  48. #XLIB = -L/usr/openwin/lib -lX11
  49. XINC = -I/usr/X11R6/include # new X distributions (X.org, etc.)
  50. XLIB = -L/usr/X11R6/lib -lX11
  51. #XLIB = -L/usr/X11R6/lib64 -lX11 # e.g., Red Hat on AMD64
  52. INCS = $(PNGINC) $(ZINC) $(XINC)
  53. RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
  54. RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
  55. WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
  56. WLIBSs = $(PNGLIBs) $(ZLIBs) -lm
  57. CC = gcc
  58. LD = gcc
  59. RM = rm -f
  60. CPPFLAGS = $(INCS) -DFEATURE_LOOP
  61. CFLAGS = -O -Wall
  62. #CFLAGS = -O -W -Wall -Wextra -pedantic -ansi
  63. # [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
  64. # [-ansi, -pedantic, -Wextra, and -W can also be used]
  65. LDFLAGS =
  66. O = .o
  67. E =
  68. RPNG = rpng-x
  69. RPNG2 = rpng2-x
  70. WPNG = wpng
  71. RPNGs = $(RPNG)-static
  72. RPNG2s = $(RPNG2)-static
  73. WPNGs = $(WPNG)-static
  74. ROBJS = $(RPNG)$(O) readpng$(O)
  75. ROBJS2 = $(RPNG2)$(O) readpng2$(O)
  76. WOBJS = $(WPNG)$(O) writepng$(O)
  77. STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
  78. DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
  79. EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
  80. # implicit make rules -------------------------------------------------------
  81. .c$(O):
  82. $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
  83. # dependencies --------------------------------------------------------------
  84. all: $(EXES)
  85. $(RPNGs)$(E): $(ROBJS)
  86. $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSs)
  87. $(RPNG)$(E): $(ROBJS)
  88. $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSd)
  89. $(RPNG2s)$(E): $(ROBJS2)
  90. $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSs)
  91. $(RPNG2)$(E): $(ROBJS2)
  92. $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSd)
  93. $(WPNGs)$(E): $(WOBJS)
  94. $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSs)
  95. $(WPNG)$(E): $(WOBJS)
  96. $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSd)
  97. $(RPNG)$(O): $(RPNG).c readpng.h
  98. $(RPNG2)$(O): $(RPNG2).c readpng2.h
  99. $(WPNG)$(O): $(WPNG).c writepng.h
  100. readpng$(O): readpng.c readpng.h
  101. readpng2$(O): readpng2.c readpng2.h
  102. writepng$(O): writepng.c writepng.h
  103. # maintenance ---------------------------------------------------------------
  104. clean:
  105. $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)