Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Jun 11th, 2010 | Syntax: None | Size: 3.78 KB | Hits: 42 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. # BC's quick'n'dirty makefile - with annotations
  2.  
  3. #-------------------------------------------------------------------------------
  4. # Check devkitpro is installed
  5. #-------------------------------------------------------------------------------
  6. ifeq ($(strip $(DEVKITPPC)),)
  7. $(error "Use export DEVKITPPC=<path to>devkitPPC and try again")
  8. endif
  9.  
  10. ifeq ($(strip $(DEVKITPRO)),)
  11. $(error "Use export DEVKITPRO=<path to>devkitPRO and try again")
  12. endif
  13.  
  14. #-------------------------------------------------------------------------------
  15. # Applicatin will be named after this directory
  16. #-------------------------------------------------------------------------------
  17. APP := $(notdir $(CURDIR))
  18. ELF := $(APP).elf
  19. DOL := $(APP).dol
  20. MAP := $(APP).map
  21.  
  22. #-------------------------------------------------------------------------------
  23. # Source code and binary resources
  24. #-------------------------------------------------------------------------------
  25. SRC := $(wildcard *.c)
  26. SRCOBJ := $(patsubst %.c,%.o,$(SRC))
  27.  
  28. RES := $(wildcard *.png)
  29. RESOBJ := $(patsubst %.png,%.o,$(RES))
  30. RESC := $(patsubst %.png,%.c,$(RES))
  31. RESH := $(patsubst %.png,%.h,$(RES))
  32.  
  33. OBJ := $(RESOBJ) $(SRCOBJ)
  34.  
  35. #-------------------------------------------------------------------------------
  36. # Include required libraries ...the order can-be/is critical!
  37. #-------------------------------------------------------------------------------
  38. LIBS := -lgrrlib -lpngu -lpng -ljpeg -lz -lfat
  39. LIBS += -lwiiuse
  40. #LIBS += -lmodplay -lasnd
  41. LIBS += -lbte -logc
  42. LIBS += -lm
  43.  
  44. #-------------------------------------------------------------------------------
  45. # Compilers & utils which we will be using
  46. #-------------------------------------------------------------------------------
  47. BINDIR := $(DEVKITPPC)/bin
  48. PREFIX := $(BINDIR)/powerpc-gekko-
  49.  
  50. CC := $(PREFIX)gcc
  51. CXX := $(PREFIX)g++
  52. AR := $(PREFIX)ar
  53. AS := $(PREFIX)as
  54. LD := $(CC)
  55. OBJCOPY := $(PREFIX)objcopy
  56.  
  57. ELF2DOL := $(BINDIR)/elf2dol
  58. UPLOAD := $(BINDIR)/wiiload
  59.  
  60. #-------------------------------------------------------------------------------
  61. # libogc - the main Wii/GC libraries
  62. #-------------------------------------------------------------------------------
  63. OGC := $(DEVKITPRO)/libogc
  64. INCD := $(OGC)/include
  65. LIBD := $(OGC)/lib/wii
  66.  
  67. #-------------------------------------------------------------------------------
  68. # Wii specific compiler flags
  69. #-------------------------------------------------------------------------------
  70. MACHDEP := -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float
  71. CFLAGS := -O2 -Wall $(MACHDEP) -I $(INCD)
  72.  
  73. #-------------------------------------------------------------------------------
  74. # Information for the linker
  75. #-------------------------------------------------------------------------------
  76. LDFLAGS = $(MACHDEP) -Wl,-Map,$(MAP)
  77. LIBPATHS := -L$(DEVKITPRO)/libogc/lib/wii
  78.  
  79. #-------------------------------------------------------------------------------
  80. # Build rules
  81. #-------------------------------------------------------------------------------
  82.  
  83. # "make all" -> Build the DOL file
  84. all : $(DOL)
  85.  
  86. # "make clean" -> Erase everything made by `make`
  87. clean :
  88.         rm -f $(OBJ) $(RESC) $(RESH) $(ELF) $(DOL) $(MAP)
  89.  
  90. # "make run" -> Send the DOL file to the Wii
  91. run : $(DOL)
  92.         $(UPLOAD) $(DOL)
  93.  
  94. # The DOL file is built from the ELF file
  95. $(DOL) : $(ELF)
  96. @echo Converting to: $@
  97.         @$(ELF2DOL) $< $@
  98.  
  99. # The ELF is built from the OBJects
  100. $(ELF) : $(OBJ)
  101. @echo Linking as: $@
  102.         @$(CC) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -o $@
  103.  
  104. # Objects (.o) are made from C files (.c)
  105. %.o : %.c
  106. @echo Compiling: $<
  107.         @$(CC) $(CFLAGS) -c $< -o $@
  108.  
  109. # C files (.c) can be made from PNG images
  110. .PRECIOUS : %.c
  111. %.c : %.png
  112. @echo Converting resource: $<
  113.         @./raw2c.exe $< 2>null