Mattie

Untitled

Mar 21st, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 5.71 KB | None | 0 0
  1. #---------------------------------------------------------------------------------
  2. # Clear the implicit built in rules
  3. #---------------------------------------------------------------------------------
  4. .SUFFIXES:
  5. #---------------------------------------------------------------------------------
  6. ifeq ($(strip $(DEVKITPPC)),)
  7. $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
  8. endif
  9.  
  10. include $(DEVKITPPC)/wii_rules
  11.  
  12. #---------------------------------------------------------------------------------
  13. # TARGET is the name of the output
  14. # BUILD is the directory where object files & intermediate files will be placed
  15. # SOURCES is a list of directories containing source code
  16. # INCLUDES is a list of directories containing extra header files
  17. #---------------------------------------------------------------------------------
  18. TARGET      :=  $(notdir $(CURDIR))
  19. BUILD       :=  build
  20. SOURCES     :=  source
  21. DATA        :=  data  
  22. INCLUDES    :=
  23.  
  24. #---------------------------------------------------------------------------------
  25. # options for code generation
  26. #---------------------------------------------------------------------------------
  27.  
  28. CFLAGS  = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
  29. CXXFLAGS    =   $(CFLAGS)
  30.  
  31. LDFLAGS =   -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
  32.  
  33. #---------------------------------------------------------------------------------
  34. # any extra libraries we wish to link with the project
  35. #---------------------------------------------------------------------------------
  36. LIBS    :=  -lwiiuse -lbte -logc -lm
  37.  
  38. #---------------------------------------------------------------------------------
  39. # list of directories containing libraries, this must be the top level containing
  40. # include and lib
  41. #---------------------------------------------------------------------------------
  42. LIBDIRS := $(DEVKITPRO)/wiilibs
  43.  
  44.  
  45. #---------------------------------------------------------------------------------
  46. # no real need to edit anything past this point unless you need to add additional
  47. # rules for different file extensions
  48. #---------------------------------------------------------------------------------
  49. ifneq ($(BUILD),$(notdir $(CURDIR)))
  50. #---------------------------------------------------------------------------------
  51.  
  52. export OUTPUT   :=  $(CURDIR)/$(TARGET)
  53.  
  54. export VPATH    :=  $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  55.                     $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  56.  
  57. export DEPSDIR  :=  $(CURDIR)/$(BUILD)
  58.  
  59. #---------------------------------------------------------------------------------
  60. # automatically build a list of object files for our project
  61. #---------------------------------------------------------------------------------
  62. CFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  63. CPPFILES    :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  64. sFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  65. SFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
  66. BINFILES    :=  $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  67.  
  68. #---------------------------------------------------------------------------------
  69. # use CXX for linking C++ projects, CC for standard C
  70. #---------------------------------------------------------------------------------
  71. ifeq ($(strip $(CPPFILES)),)
  72.     export LD   :=  $(CC)
  73. else
  74.     export LD   :=  $(CXX)
  75. endif
  76.  
  77. export OFILES   :=  $(addsuffix .o,$(BINFILES)) \
  78.                     $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
  79.                     $(sFILES:.s=.o) $(SFILES:.S=.o)
  80.  
  81. #---------------------------------------------------------------------------------
  82. # build a list of include paths
  83. #---------------------------------------------------------------------------------
  84. export INCLUDE  :=  $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
  85.                     $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  86.                     -I$(CURDIR)/$(BUILD) \
  87.                     -I$(LIBOGC_INC)
  88.  
  89. #---------------------------------------------------------------------------------
  90. # build a list of library paths
  91. #---------------------------------------------------------------------------------
  92. export LIBPATHS :=  $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
  93.                     -L$(LIBOGC_LIB)
  94.  
  95. export OUTPUT   :=  $(CURDIR)/$(TARGET)
  96. .PHONY: $(BUILD) clean
  97.  
  98. #---------------------------------------------------------------------------------
  99. $(BUILD):
  100.     @[ -d $@ ] || mkdir -p $@
  101.     @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  102.     @cp WiiGame.elf boot.elf
  103.     @cp boot.elf $(DROPBOX)/project\ WII\ game/Matthijs_c++/boot.elf
  104.     @cp boot.elf $(DROPBOX)/project\ WII\ game/Matthijs_c++/boot_`date +%m-%d-%Y---%H\;%M\;%S`.elf
  105.     @cp boot.elf /g/apps/WIIGAMETEST
  106.  
  107. #---------------------------------------------------------------------------------
  108. clean:
  109.     @echo clean ...
  110.     @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
  111.  
  112. #---------------------------------------------------------------------------------
  113. run:
  114.     wiiload $(TARGET).dol
  115.  
  116.  
  117. #---------------------------------------------------------------------------------
  118. else
  119.  
  120. DEPENDS :=  $(OFILES:.o=.d)
  121.  
  122. #---------------------------------------------------------------------------------
  123. # main targets
  124. #---------------------------------------------------------------------------------
  125. $(OUTPUT).dol: $(OUTPUT).elf
  126. $(OUTPUT).elf: $(OFILES)
  127.  
  128. #---------------------------------------------------------------------------------
  129. # This rule links in binary data with the .jpg extension
  130. #---------------------------------------------------------------------------------
  131. %.jpg.o :   %.jpg
  132. #---------------------------------------------------------------------------------
  133.     @echo $(notdir $<)
  134.     $(bin2o)
  135.  
  136. -include $(DEPENDS)
  137.  
  138. #---------------------------------------------------------------------------------
  139. endif
  140. #---------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment