Advertisement
flyingfisch

[PRIZM] Makefile

Feb 16th, 2012
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.15 KB | None | 0 0
  1. #---------------------------------------------------------------------------------
  2. # Clear the implicit built in rules
  3. #---------------------------------------------------------------------------------
  4. .SUFFIXES:
  5. #---------------------------------------------------------------------------------
  6. # Set toolchain location in an environment var for future use, this will change
  7. # to use a system environment var in the future.
  8. #---------------------------------------------------------------------------------
  9. ifeq ($(strip $(FXCGSDK)),)
  10. export FXCGSDK := $(abspath ../../)
  11. endif
  12.  
  13. include $(FXCGSDK)/common/prizm_rules
  14.  
  15.  
  16. #---------------------------------------------------------------------------------
  17. # TARGET is the name of the output
  18. # BUILD is the directory where object files & intermediate files will be placed
  19. # SOURCES is a list of directories containing source code
  20. # INCLUDES is a list of directories containing extra header files
  21. #---------------------------------------------------------------------------------
  22. TARGET      :=  $(notdir $(CURDIR))
  23. BUILD       :=  build
  24. SOURCES     :=  src
  25. DATA        :=  data  
  26. INCLUDES    :=
  27.  
  28. #---------------------------------------------------------------------------------
  29. # options for code and add-in generation
  30. #---------------------------------------------------------------------------------
  31.  
  32. MKG3AFLAGS := -n basic:example -i uns:../unselected.bmp -i sel:../selected.bmp
  33.  
  34. CFLAGS  = -Os -Wall $(MACHDEP) $(INCLUDE)
  35. CXXFLAGS    =   $(CFLAGS)
  36.  
  37. LDFLAGS = $(MACHDEP) -T$(FXCGSDK)/common/prizm.ld -Wl,-static -Wl,-gc-sections
  38.  
  39. #---------------------------------------------------------------------------------
  40. # any extra libraries we wish to link with the project
  41. #---------------------------------------------------------------------------------
  42. LIBS    :=  -lfxcg -lgcc
  43.  
  44. #---------------------------------------------------------------------------------
  45. # list of directories containing libraries, this must be the top level containing
  46. # include and lib
  47. #---------------------------------------------------------------------------------
  48. LIBDIRS :=
  49.  
  50. #---------------------------------------------------------------------------------
  51. # no real need to edit anything past this point unless you need to add additional
  52. # rules for different file extensions
  53. #---------------------------------------------------------------------------------
  54. ifneq ($(BUILD),$(notdir $(CURDIR)))
  55. #---------------------------------------------------------------------------------
  56.  
  57. export OUTPUT   :=  $(CURDIR)/$(TARGET)
  58.  
  59. export VPATH    :=  $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  60.                     $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  61.  
  62. export DEPSDIR  :=  $(CURDIR)/$(BUILD)
  63.  
  64. #---------------------------------------------------------------------------------
  65. # automatically build a list of object files for our project
  66. #---------------------------------------------------------------------------------
  67. CFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  68. CPPFILES    :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  69. sFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  70. SFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
  71. BINFILES    :=  $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  72.  
  73. #---------------------------------------------------------------------------------
  74. # use CXX for linking C++ projects, CC for standard C
  75. #---------------------------------------------------------------------------------
  76. ifeq ($(strip $(CPPFILES)),)
  77.     export LD   :=  $(CC)
  78. else
  79.     export LD   :=  $(CXX)
  80. endif
  81.  
  82. export OFILES   :=  $(addsuffix .o,$(BINFILES)) \
  83.                     $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
  84.                     $(sFILES:.s=.o) $(SFILES:.S=.o)
  85.  
  86. #---------------------------------------------------------------------------------
  87. # build a list of include paths
  88. #---------------------------------------------------------------------------------
  89. export INCLUDE  :=  $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
  90.                     $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  91.                     -I$(CURDIR)/$(BUILD) -I$(LIBFXCG_INC)
  92.  
  93. #---------------------------------------------------------------------------------
  94. # build a list of library paths
  95. #---------------------------------------------------------------------------------
  96. export LIBPATHS :=  $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
  97.                     -L$(LIBFXCG_LIB)
  98.  
  99. export OUTPUT   :=  $(CURDIR)/$(TARGET)
  100. .PHONY: $(BUILD) clean
  101.  
  102. #---------------------------------------------------------------------------------
  103. $(BUILD):
  104.     @[ -d $@ ] || mkdir $@
  105.     @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  106.  
  107. #---------------------------------------------------------------------------------
  108. export CYGWIN := nodosfilewarning
  109. clean:
  110.     $(RM) -fr $(BUILD) $(OUTPUT).bin $(OUTPUT).g3a
  111.  
  112. #---------------------------------------------------------------------------------
  113. else
  114.  
  115. DEPENDS :=  $(OFILES:.o=.d)
  116.  
  117. #---------------------------------------------------------------------------------
  118. # main targets
  119. #---------------------------------------------------------------------------------
  120. $(OUTPUT).g3a: $(OUTPUT).bin
  121. $(OUTPUT).bin: $(OFILES)
  122.  
  123.  
  124. -include $(DEPENDS)
  125.  
  126. #---------------------------------------------------------------------------------
  127. endif
  128. #---------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement