Skip to content

Commit

Permalink
update makefiles for easier compiling/installing
Browse files Browse the repository at this point in the history
  • Loading branch information
dborth committed Apr 23, 2009
1 parent eb25849 commit 418eb1b
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 40 deletions.
66 changes: 26 additions & 40 deletions SDL/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif

include $(DEVKITPPC)/wii_rules

# Directories.
OBJ_DIR := obj/wii
LIB_DIR := lib
BIN_DIR := bin/wii
SDL_OBJ_DIR := $(OBJ_DIR)/sdl
SDL_SRC_DIR := src
TEST_OBJ_DIR := $(OBJ_DIR)/test
TEST_SRC_DIR := test

# Tools.
PIPE_TO_SED := 2>&1 | sed "s/:\([0-9]*\):/\(\1\) :/"
Expand Down Expand Up @@ -38,29 +47,24 @@ SDL_SRCS := \
# Library object files.
SDL_OBJS := $(subst $(SDL_SRC_DIR),$(SDL_OBJ_DIR),$(SDL_SRCS:.c=.o))

# Test source files.
# It can be useful to switch this variable around to select individual tests which are problematic.
TEST_SRCS := $(wildcard $(TEST_SRC_DIR)/*.c)
#TEST_SRCS := $(TEST_SRC_DIR)/testsprite.c

# Test object files.
TEST_OBJS := $(subst $(TEST_SRC_DIR)/,$(TEST_OBJ_DIR)/,$(TEST_SRCS:.c=.o))

# Test .DOL files.
TEST_DOLS := $(subst $(TEST_OBJ_DIR),$(BIN_DIR),$(TEST_OBJS:.o=.dol))

# What's a full build?
all: $(LIB_DIR)/libSDL.a install
all: $(LIB_DIR)/libSDL.a

# How to delete the intermediate files.
clean:
@echo Cleaning $(TEST_DOLS) $(LIB_DIR)/libSDL.a $(SDL_OBJS) $(TEST_OBJS)
@rm -f $(TEST_DOLS) $(LIB_DIR)/libSDL.a $(SDL_OBJS) $(TEST_OBJS)

# How to install to SD card ready for running.
install: $(TEST_DOLS)
@-mkdir -p dols
cp $(TEST_DOLS) dols
@echo Cleaning $(LIB_DIR) $(SDL_OBJS)
@rm -fr $(LIB_DIR) $(SDL_OBJS)

lib-install:
@mkdir -p $(DEVKITPRO)/libogc/include/SDL
@cp -frv $(LIB_DIR)/*.* $(DEVKITPRO)/libogc/lib/wii
@cp -frv include/*.* $(DEVKITPRO)/libogc/include/SDL

test-make:
$(MAKE) -f Makefile.test install

test-clean:
$(MAKE) -f Makefile.test clean

# How to build a library.
$(LIB_DIR)/libSDL.a: $(SDL_OBJS)
Expand All @@ -78,32 +82,14 @@ $(BIN_DIR)/%.dol: $(TEST_OBJ_DIR)/%.elf
@echo ----

# Compilation flags.
#COMMON_FLAGS := -g -O2 -mrvl -Wall -mcpu=750 -meabi -mhard-float $(MACHDEP)
COMMON_FLAGS := -g -O2 -mrvl -Wall -mcpu=750 -meabi -mhard-float $(MACHDEP)
INCLUDES := -Iinclude -I$(DEVKITPRO)/libogc/include
#DEFINES := -DGEKKO -DDEBUG_ERROR -DDEBUG_TIMERS -DDEBUG_THREADS -DDEBUG_BUILD -DDEBUG_CONVERT -DSDL_AUDIO_DRIVER_WII
DEFINES := -DGEKKO -DSDL_AUDIO_DRIVER_WII
CFLAGS := $(COMMON_FLAGS) $(INCLUDES) $(DEFINES)

# Test link flags.
LDFLAGS := $(COMMON_FLAGS) -L$(LIB_DIR) -L$(DEVKITPRO)/libogc/lib/wii -lSDL -lfat -lwiiuse -lbte -logc -lm
#LDFLAGS := $(COMMON_FLAGS) -L$(LIB_DIR) -L$(DEVKITPRO)/libogc/lib/wii -lSDL -lfat -lwiiuse -lbte -logc -lm
# -lsdcard

# How to link an ELF.
$(TEST_OBJ_DIR)/%.elf: $(TEST_OBJ_DIR)/%.o $(LIB_DIR)/libSDL.a
@echo Linking $@
@-mkdir -p $(dir $@)
powerpc-gekko-g++ -o $@ $< $(LDFLAGS)
#keep elf for debugging
#cp $@ /tmp/elf

# How to compile C file (Tests).
$(TEST_OBJ_DIR)/%.o: $(TEST_SRC_DIR)/%.c
@echo Compiling $<
@-mkdir -p $(dir $@)
powerpc-gekko-gcc $(CFLAGS) -c $< -o $@ $(PIPE_TO_SsED)


# How to compile C file (SDL library).
$(SDL_OBJ_DIR)/%.o: $(SDL_SRC_DIR)/%.c
@echo Compiling $<
Expand Down
64 changes: 64 additions & 0 deletions SDL/Makefile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Directories.
OBJ_DIR := obj/wii
LIB_DIR := lib
BIN_DIR := bin/wii
TEST_OBJ_DIR := $(OBJ_DIR)/test
TEST_SRC_DIR := test
TEST_DOL_DIR := test_dols

# Tools.
PIPE_TO_SED := 2>&1 | sed "s/:\([0-9]*\):/\(\1\) :/"

# Test source files.
# It can be useful to switch this variable around to select individual tests which are problematic.
TEST_SRCS := $(wildcard $(TEST_SRC_DIR)/*.c)
#TEST_SRCS := $(TEST_SRC_DIR)/testsprite.c

# Test object files.
TEST_OBJS := $(subst $(TEST_SRC_DIR)/,$(TEST_OBJ_DIR)/,$(TEST_SRCS:.c=.o))

# Test .DOL files.
TEST_DOLS := $(subst $(TEST_OBJ_DIR),$(BIN_DIR),$(TEST_OBJS:.o=.dol))

# How to build test files
install: $(TEST_DOLS)
@-mkdir -p ${TEST_DOL_DIR}
cp $(TEST_DOLS) ${TEST_DOL_DIR}

# How to delete the intermediate files
clean:
@echo Cleaning $(TEST_DOLS) $(TEST_OBJS)
@rm -fr $(TEST_DOLS) $(TEST_OBJS) ${TEST_DOL_DIR}

# How to build a DOL.
$(BIN_DIR)/%.dol: $(TEST_OBJ_DIR)/%.elf
@echo Creating DOL $@
@-mkdir -p $(dir $@)
#powerpc-gekko-objcopy -O binary $< $@
elf2dol $< $@
@echo ----

# Compilation flags.
#COMMON_FLAGS := -g -O2 -mrvl -Wall -mcpu=750 -meabi -mhard-float $(MACHDEP)
COMMON_FLAGS := -g -O2 -mrvl -Wall -mcpu=750 -meabi -mhard-float $(MACHDEP)
INCLUDES := -Iinclude -I$(DEVKITPRO)/libogc/include
#DEFINES := -DGEKKO -DDEBUG_ERROR -DDEBUG_TIMERS -DDEBUG_THREADS -DDEBUG_BUILD -DDEBUG_CONVERT -DSDL_AUDIO_DRIVER_WII
DEFINES := -DGEKKO -DSDL_AUDIO_DRIVER_WII
CFLAGS := $(COMMON_FLAGS) $(INCLUDES) $(DEFINES)

# Test link flags.
LDFLAGS := $(COMMON_FLAGS) -L$(LIB_DIR) -L$(DEVKITPRO)/libogc/lib/wii -lSDL -lfat -lwiiuse -lbte -logc -lm

# How to link an ELF.
$(TEST_OBJ_DIR)/%.elf: $(TEST_OBJ_DIR)/%.o $(LIB_DIR)/libSDL.a
@echo Linking $@
@-mkdir -p $(dir $@)
powerpc-gekko-g++ -o $@ $< $(LDFLAGS)
#keep elf for debugging
#cp $@ /tmp/elf

# How to compile C file (Tests).
$(TEST_OBJ_DIR)/%.o: $(TEST_SRC_DIR)/%.c
@echo Compiling $<
@-mkdir -p $(dir $@)
powerpc-gekko-gcc $(CFLAGS) -c $< -o $@ $(PIPE_TO_SsED)
5 changes: 5 additions & 0 deletions SDL_gfx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ $(LIB_DIR)/libSDL_gfx.a: $(OBJS)
@-mkdir -p $(dir $@)
@powerpc-gekko-ar crs $@ $(OBJS)
@echo ----

lib-install:
@mkdir -p $(DEVKITPRO)/libogc/include/SDL
@cp -frv $(LIB_DIR)/*.* $(DEVKITPRO)/libogc/lib/wii
@cp -frv include/*.* $(DEVKITPRO)/libogc/include/SDL

# How to copy the header file
headers:
Expand Down
5 changes: 5 additions & 0 deletions SDL_image/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ all: $(LIB_DIR)/libSDL_image.a $(INCLUDE_DIR)/SDL_image.h install
clean:
@echo Cleaning $(LIB_DIR)/libSDL_image.a $(OBJ_DIR)
@rm -f $(LIB_DIR)/libSDL_image.a $(OBJS) $(TEST_OBJS)

lib-install:
@mkdir -p $(DEVKITPRO)/libogc/include/SDL
@cp -frv $(LIB_DIR)/*.* $(DEVKITPRO)/libogc/lib/wii
@cp -frv include/*.* $(DEVKITPRO)/libogc/include/SDL

# How to install to SD card ready for running.
install: $(TEST_DOLS)
Expand Down
5 changes: 5 additions & 0 deletions SDL_mixer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ install: $(TEST_DOLS)
clean:
@echo Cleaning $(LIB_DIR)/libSDL_mixer.a $(OBJ_DIR)
@rm -f $(LIB_DIR)/libSDL_mixer.a $(OBJS) $(TEST_OBJS)

lib-install:
@mkdir -p $(DEVKITPRO)/libogc/include/SDL
@cp -frv $(LIB_DIR)/*.* $(DEVKITPRO)/libogc/lib/wii
@cp -frv include/*.* $(DEVKITPRO)/libogc/include/SDL

# How to build a library.
$(LIB_DIR)/libSDL_mixer.a: $(OBJS)
Expand Down
5 changes: 5 additions & 0 deletions SDL_ttf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ clean:
install: $(TEST_DOLS)
@-mkdir -p dols
cp $(TEST_DOLS) dols

lib-install:
@mkdir -p $(DEVKITPRO)/libogc/include/SDL
@cp -frv $(LIB_DIR)/*.* $(DEVKITPRO)/libogc/lib/wii
@cp -frv include/*.* $(DEVKITPRO)/libogc/include/SDL

# How to build a library.
$(LIB_DIR)/libSDL_ttf.a: $(OBJS)
Expand Down

0 comments on commit 418eb1b

Please sign in to comment.