Makefile.unx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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)
  57. CC = gcc
  58. LD = gcc
  59. RM = rm -f
  60. CPPFLAGS = $(INCS) -DFEATURE_LOOP
  61. CFLAGS = -O -Wall
  62. # [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
  63. # [-ansi, -pedantic and -W can also be used]
  64. LDFLAGS =
  65. O = .o
  66. E =
  67. RPNG = rpng-x
  68. RPNG2 = rpng2-x
  69. WPNG = wpng
  70. RPNGs = $(RPNG)-static
  71. RPNG2s = $(RPNG2)-static
  72. WPNGs = $(WPNG)-static
  73. ROBJS = $(RPNG)$(O) readpng$(O)
  74. ROBJS2 = $(RPNG2)$(O) readpng2$(O)
  75. WOBJS = $(WPNG)$(O) writepng$(O)
  76. STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
  77. DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
  78. EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
  79. # implicit make rules -------------------------------------------------------
  80. .c$(O):
  81. $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
  82. # dependencies --------------------------------------------------------------
  83. all: $(EXES)
  84. $(RPNGs)$(E): $(ROBJS)
  85. $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSs)
  86. $(RPNG)$(E): $(ROBJS)
  87. $(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBSd)
  88. $(RPNG2s)$(E): $(ROBJS2)
  89. $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSs)
  90. $(RPNG2)$(E): $(ROBJS2)
  91. $(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBSd)
  92. $(WPNGs)$(E): $(WOBJS)
  93. $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSs)
  94. $(WPNG)$(E): $(WOBJS)
  95. $(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBSd)
  96. $(RPNG)$(O): $(RPNG).c readpng.h
  97. $(RPNG2)$(O): $(RPNG2).c readpng2.h
  98. $(WPNG)$(O): $(WPNG).c writepng.h
  99. readpng$(O): readpng.c readpng.h
  100. readpng2$(O): readpng2.c readpng2.h
  101. writepng$(O): writepng.c writepng.h
  102. # maintenance ---------------------------------------------------------------
  103. clean:
  104. $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)