Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #----------------------------------------------------------------
  2. # make manual: http://www.gnu.org/software/make/manual/make.html
  3. #----------------------------------------------------------------
  4. #-------------------------------------------------------------------------------
  5. # global settings
  6. SHELL = /bin/bash
  7. PRE ?=
  8. CC = $(PRE)gcc
  9. CPP = $(PRE)g++
  10. STRIP = $(PRE)strip
  11. #-------------------------------------------------------------------------------
  12. # files
  13. RM_FILES = *.{o,d,tmp,bak,exe}
  14. #-------------------------------------------------------------------------------
  15. # tools
  16. TOOLS := test-libwbfs
  17. RM_FILES += $(TOOLS)
  18. #-------------------------------------------------------------------------------
  19. # object files
  20. # objects of tools
  21. TOOLS_O := $(patsubst %,%.o,$(TOOLS))
  22. # other objects
  23. LIBWBFS_O := file-formats.o libwbfs.o wiidisc.o rijndael.o
  24. # object groups
  25. C_OBJECTS := $(sort $(TOOLS_O) $(LIBWBFS_O))
  26. # all objects + sources
  27. ALL_OBJECTS := $(sort $(LIBWBFS_O))
  28. ALL_SOURCES := $(patsubst %.o,%.c,$(ALL_OBJECTS))
  29. #-------------------------------------------------------------------------------
  30. VPATH += ../src/libwbfs
  31. DEFINES = -DLARGE_FILES -D_FILE_OFFSET_BITS=64 $(XDEF)
  32. DEFINES := $(strip $(DEFINES))
  33. CFLAGS = -fomit-frame-pointer -fno-strict-aliasing
  34. CFLAGS += -Wall -Wno-parentheses -Wno-unused-function
  35. CFLAGS += -O3 -I../src/libwbfs -I.
  36. CFLAGS += $(XFLAGS)
  37. CFLAGS := $(strip $(CFLAGS))
  38. DEPFLAGS += -MMD
  39. LDFLAGS += -static-libgcc
  40. #LDFLAGS += -static
  41. LDFLAGS := $(strip $(LDFLAGS))
  42. LIBS += $(XLIBS)
  43. #
  44. ###############################################################################
  45. # default rule
  46. default_rule: all
  47. # @echo "HINT: try 'make help'"
  48. # include this behind the default rule
  49. -include $(ALL_SOURCES:.c=.d)
  50. #
  51. ###############################################################################
  52. # general rules
  53. $(TOOLS): %: %.o $(ALL_OBJECTS) Makefile
  54. @echo "*** tool $@ $(MODE)"
  55. @$(CC) $(CFLAGS) $(DEFINES) $(LDFLAGS) $@.o $(ALL_OBJECTS) $(LIBS) -o $@
  56. @if test -f $@.exe; then $(STRIP) $@.exe; else $(STRIP) $@; fi
  57. #--------------------------
  58. $(C_OBJECTS): %.o: %.c Makefile
  59. @echo "*** object $@ $(MODE)"
  60. @$(CC) $(CFLAGS) $(DEPFLAGS) $(DEFINES) -c $< -o $@
  61. #--------------------------
  62. $(ASM_OBJECTS): %.o: %.S Makefile
  63. @echo "*** asm $@ $(MODE)"
  64. @$(CC) $(CFLAGS) $(DEPFLAGS) $(DEFINES) -c $< -o $@
  65. #
  66. ###############################################################################
  67. # specific rules in alphabetic order
  68. .PHONY : all
  69. all: $(TOOLS)
  70. .PHONY : all+
  71. all+: clean all
  72. #
  73. #--------------------------
  74. .PHONY : clean
  75. clean:
  76. @echo "*** rm output files"
  77. @rm -f $(RM_FILES)
  78. #
  79. #--------------------------
  80. .PHONY : flags
  81. flags:
  82. @echo ""
  83. @echo "DEFINES: $(DEFINES)"
  84. @echo ""
  85. @echo "CFLAGS: $(CFLAGS)"
  86. @echo ""
  87. @echo "LDFLAGS: $(LDFLAGS)"
  88. @echo ""
  89. @echo "LIBS: $(LIBS)"
  90. @echo ""
  91. #
  92. #--------------------------
  93. .PHONY : tools
  94. tools: $(ALL_TOOLS)