Guest User

Untitled

a guest
Jun 6th, 2011
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #---------------------------------------------------------------------------------
  2. .SUFFIXES:
  3. #---------------------------------------------------------------------------------
  4.  
  5. ifeq ($(strip $(DEVKITARM)),)
  6. $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
  7. endif
  8.  
  9. include $(DEVKITARM)/ds_rules
  10.  
  11. #---------------------------------------------------------------------------------
  12. # TARGET is the name of the output
  13. # BUILD is the directory where object files & intermediate files will be placed
  14. # SOURCES is a list of directories containing source code
  15. # INCLUDES is a list of directories containing extra header files
  16. # DATA is a list of directories containing binary files embedded using bin2o
  17. # GRAPHICS is a list of directories containing image files to be converted with grit
  18. # MODELS is a directory containing models
  19. #---------------------------------------------------------------------------------
  20. TARGET := $(shell basename $(CURDIR))
  21. BUILD := build
  22. SOURCES := source
  23. INCLUDES := include
  24. DATA := data
  25. GRAPHICS := gfx
  26. MODELS := models
  27.  
  28. #---------------------------------------------------------------------------------
  29. # options for code generation
  30. #---------------------------------------------------------------------------------
  31. ARCH := -mthumb -mthumb-interwork -march=armv5te -mtune=arm946e-s
  32.  
  33. CFLAGS := -g -Wall -O2\
  34. -fomit-frame-pointer\
  35. -ffast-math \
  36. $(ARCH)
  37.  
  38. CFLAGS += $(INCLUDE) -DARM9
  39. CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
  40.  
  41. ASFLAGS := -g $(ARCH)
  42. LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
  43.  
  44. #---------------------------------------------------------------------------------
  45. # any extra libraries we wish to link with the project (order is important)
  46. #---------------------------------------------------------------------------------
  47. LIBS := -lnds9
  48.  
  49. #---------------------------------------------------------------------------------
  50. # list of directories containing libraries, this must be the top level containing
  51. # include and lib
  52. #---------------------------------------------------------------------------------
  53. LIBDIRS := $(LIBNDS)
  54.  
  55. #---------------------------------------------------------------------------------
  56. # no real need to edit anything past this point unless you need to add additional
  57. # rules for different file extensions
  58. #---------------------------------------------------------------------------------
  59. ifneq ($(BUILD),$(notdir $(CURDIR)))
  60. #---------------------------------------------------------------------------------
  61.  
  62. export OUTPUT := $(CURDIR)/$(TARGET)
  63.  
  64. export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  65. $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
  66. $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
  67. $(foreach dir,$(MODELS),$(CURDIR)/$(dir))
  68.  
  69. export DEPSDIR := $(CURDIR)/$(BUILD)
  70.  
  71. CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  72. CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  73. SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  74. PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
  75. BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  76. MODELFILES := $(foreach dir,$(MODELS),$(notdir $(wildcard $(dir)/*.md2)))
  77.  
  78. #---------------------------------------------------------------------------------
  79. # use CXX for linking C++ projects, CC for standard C
  80. #---------------------------------------------------------------------------------
  81. ifeq ($(strip $(CPPFILES)),)
  82. #---------------------------------------------------------------------------------
  83. export LD := $(CC)
  84. #---------------------------------------------------------------------------------
  85. else
  86. #---------------------------------------------------------------------------------
  87. export LD := $(CXX)
  88. #---------------------------------------------------------------------------------
  89. endif
  90. #---------------------------------------------------------------------------------
  91.  
  92. export OMODELS := $(foreach file,$(addsuffix .o,$(MODELFILES)),$(file))
  93.  
  94. export OFILES := $(addsuffix .o,$(BINFILES)) \
  95. $(PNGFILES:.png=.o) \
  96. $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
  97.  
  98. export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
  99. $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  100. -I$(CURDIR)/$(BUILD)
  101.  
  102. export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
  103.  
  104. icons := $(wildcard *.bmp)
  105.  
  106. ifneq (,$(findstring $(TARGET).bmp,$(icons)))
  107. export GAME_ICON := $(CURDIR)/$(TARGET).bmp
  108. else
  109. ifneq (,$(findstring icon.bmp,$(icons)))
  110. export GAME_ICON := $(CURDIR)/icon.bmp
  111. endif
  112. endif
  113.  
  114. .PHONY: $(BUILD) clean
  115.  
  116. #---------------------------------------------------------------------------------
  117. $(BUILD):
  118. @[ -d $@ ] || mkdir -p $@
  119. @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  120.  
  121. #---------------------------------------------------------------------------------
  122. clean:
  123. @echo clean ...
  124. @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds
  125.  
  126. #---------------------------------------------------------------------------------
  127. else
  128.  
  129. #---------------------------------------------------------------------------------
  130. # main targets
  131. #---------------------------------------------------------------------------------
  132. $(OUTPUT).nds : $(OUTPUT).elf
  133. $(OUTPUT).elf : $(OMODELS) $(OFILES)
  134.  
  135. #---------------------------------------------------------------------------------
  136. # dsmfConverter
  137. #---------------------------------------------------------------------------------
  138. %.md2.bin : %.md2
  139. @dsmfConverter -l -c -t $< -o$@
  140. %.md2.o : %.md2.bin
  141. $(bin2o)
  142.  
  143. #---------------------------------------------------------------------------------
  144. %.bin.o : %.bin
  145. #---------------------------------------------------------------------------------
  146. @echo $(notdir $<)
  147. $(bin2o)
  148.  
  149. #---------------------------------------------------------------------------------
  150. # This rule creates assembly source files using grit
  151. # grit takes an image file and a .grit describing how the file is to be processed
  152. # add additional rules like this for each image extension
  153. # you use in the graphics folders
  154. #---------------------------------------------------------------------------------
  155. %.s %.h : %.png %.grit
  156. #---------------------------------------------------------------------------------
  157. grit $< -fts -o$*
  158.  
  159. -include $(DEPSDIR)/*.d
  160.  
  161. #---------------------------------------------------------------------------------------
  162. endif
  163. #---------------------------------------------------------------------------------------
RAW Paste Data