Makefile.unx 3.9 KB

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