Makefile.mingw32 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Sample makefile for rpng-win / rpng2-win / wpng using mingw32-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 DOS-prompt window via:
  12. #
  13. # make -f Makefile.mingw32
  14. #
  15. # This makefile assumes libpng and zlib have already been built or downloaded
  16. # and are in subdirectories at the same level as the current subdirectory
  17. # (as indicated by the PNGDIR and ZDIR macros below). It makes no assumptions
  18. # at all about the mingw32 installation tree (W32DIR). Edit as appropriate.
  19. #
  20. # Note that the names of the dynamic and static libpng and zlib libraries
  21. # used below may change in later releases of the libraries. This makefile
  22. # builds both statically and dynamically linked executables by default.
  23. # (You need only one set, but for testing it can be handy to have both.)
  24. # macros --------------------------------------------------------------------
  25. #PNGDIR = ../..# for libpng-x.y.z/contrib/gregbook builds
  26. PNGDIR = ../libpng-win32
  27. PNGINC = -I$(PNGDIR)
  28. PNGLIBd = $(PNGDIR)/libpng.dll.a # dynamically linked
  29. PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
  30. #ZDIR = ../../../zlib-win32# for libpng-x.y.z/contrib/gregbook builds
  31. ZDIR = ../zlib-win32
  32. ZINC = -I$(ZDIR)
  33. ZLIBd = $(ZDIR)/libzdll.a
  34. ZLIBs = $(ZDIR)/libz.a
  35. # change this to be the path where mingw32 installs its stuff:
  36. W32DIR =
  37. #W32DIR = /usr/local/cross-tools/i386-mingw32msvc
  38. W32INC = -I$(W32DIR)/include
  39. W32LIB = $(W32DIR)/lib/libuser32.a $(W32DIR)/lib/libgdi32.a
  40. CC = gcc
  41. #CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
  42. LD = $(CC)
  43. RM = rm -f
  44. CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS)
  45. # [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
  46. # [-ansi, -pedantic and -W can also be used]
  47. LDFLAGS = $(MINGW_LDFLAGS)
  48. O = .o
  49. E = .exe
  50. INCS = $(PNGINC) $(ZINC) $(W32INC)
  51. RLIBSd = $(PNGLIBd) $(ZLIBd) $(W32LIB) -lm
  52. RLIBSs = $(PNGLIBs) $(ZLIBs) $(W32LIB) -lm
  53. WLIBSd = $(PNGLIBd) $(ZLIBd)
  54. WLIBSs = $(PNGLIBs) $(ZLIBs)
  55. RPNG = rpng-win
  56. RPNG2 = rpng2-win
  57. WPNG = wpng
  58. ROBJSd = $(RPNG)$(O) readpng.pic$(O)
  59. ROBJS2d = $(RPNG2)$(O) readpng2.pic$(O)
  60. WOBJSd = $(WPNG)$(O) writepng.pic$(O)
  61. RPNGs = $(RPNG)-static
  62. RPNG2s = $(RPNG2)-static
  63. WPNGs = $(WPNG)-static
  64. ROBJSs = $(RPNG)$(O) readpng$(O)
  65. ROBJS2s = $(RPNG2)$(O) readpng2$(O)
  66. WOBJSs = $(WPNG)$(O) writepng$(O)
  67. STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
  68. DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
  69. EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
  70. # implicit make rules -------------------------------------------------------
  71. .c$(O):
  72. $(CC) -c $(CFLAGS) $<
  73. %.pic$(O): %.c
  74. $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
  75. # dependencies --------------------------------------------------------------
  76. all: $(EXES)
  77. $(RPNGs)$(E): $(ROBJSs)
  78. $(LD) $(LDFLAGS) -o $@ $(ROBJSs) $(RLIBSs)
  79. $(RPNG)$(E): $(ROBJSd)
  80. $(LD) $(LDFLAGS) -o $@ $(ROBJSd) $(RLIBSd)
  81. $(RPNG2s)$(E): $(ROBJS2s)
  82. $(LD) $(LDFLAGS) -o $@ $(ROBJS2s) $(RLIBSs)
  83. $(RPNG2)$(E): $(ROBJS2d)
  84. $(LD) $(LDFLAGS) -o $@ $(ROBJS2d) $(RLIBSd)
  85. $(WPNGs)$(E): $(WOBJSs)
  86. $(LD) $(LDFLAGS) -o $@ $(WOBJSs) $(WLIBSs)
  87. $(WPNG)$(E): $(WOBJSd)
  88. $(LD) $(LDFLAGS) -o $@ $(WOBJSd) $(WLIBSd)
  89. $(RPNG)$(O): $(RPNG).c readpng.h
  90. $(RPNG2)$(O): $(RPNG2).c readpng2.h
  91. $(WPNG)$(O): $(WPNG).c writepng.h
  92. readpng$(O) readpng.pic$(O): readpng.c readpng.h
  93. readpng2$(O) readpng2.pic$(O): readpng2.c readpng2.h
  94. writepng$(O) writepng.pic$(O): writepng.c writepng.h
  95. # maintenance ---------------------------------------------------------------
  96. clean:
  97. $(RM) $(EXES)
  98. $(RM) $(ROBJSs) $(ROBJS2s) $(WOBJSs)
  99. $(RM) $(ROBJSd) $(ROBJS2d) $(WOBJSd)