From ace2824811d1566c5ddd48ec5189d545c4d5ddf9 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Tue, 2 Feb 2021 09:51:19 +0000 Subject: [PATCH 01/11] remove unnecessary env corrections and use correct include paths --- Makefile | 50 ++++++-------------------------------------------- 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index ae6e892..b664b19 100644 --- a/Makefile +++ b/Makefile @@ -14,48 +14,13 @@ C := , ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPRO") -endif -ifeq ($(OS),Windows_NT) - $(info Compiling from $(OS)) - - PORTLIBS := $(DEVKITPRO)/portlibs/ppc - PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) - ifeq ($(DEVKITPRO),$(subst :, ,$(DEVKITPRO))) - DEVKITPRO := $(patsubst /$(firstword $(subst /, ,$(DEVKITPRO)))/%,$(firstword $(subst /, ,$(DEVKITPRO))):/%,$(DEVKITPRO)) - $(info DEVKITPRO corrected to $(DEVKITPRO)) - else - $(info DEVKITPRO is $(DEVKITPRO)) - endif - PORTLIBS := $(DEVKITPRO)/portlibs/ppc - ifeq ($(DEVKITPPC),$(subst :, ,$(DEVKITPPC))) - DEVKITPPC := $(patsubst /$(firstword $(subst /, ,$(DEVKITPPC)))/%,$(firstword $(subst /, ,$(DEVKITPPC))):/%,$(DEVKITPPC)) - $(info DEVKITPPC corrected to $(DEVKITPPC)) - else - $(info DEVKITPPC is $(DEVKITPPC)) - endif -else - $(info Compiling from Unix) +include $(DEVKITPPC)/base_tools - PORTLIBS := $(DEVKITPRO)/portlibs/ppc - $(info DEVKITPRO is $(DEVKITPRO)) - $(info DEVKITPPC is $(DEVKITPPC)) -endif +PORTLIBS := $(DEVKITPRO)/portlibs/ppc -############################################################################### -# Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as -LD := $(PREFIX)g++ -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump -OBJCOPY := $(PREFIX)objcopy ELF2DOL ?= elf2dol +LD := $(CC) # -O2: optimise lots # -Wl$C--gc-sections: remove unneeded symbols @@ -124,12 +89,9 @@ SRC := # Phony targets PHONY := # Include directories -INC_DIRS := . +INC_DIRS := . $(DEVKITPRO)/libogc/include $(PORTLIBS)/include # Library directories -LIB_DIRS := $(DEVKITPPC) $(DEVKITPPC)/powerpc-eabi \ - $(DEVKITPRO)/libogc $(DEVKITPRO)/libogc/lib/wii \ - $(wildcard $(DEVKITPPC)/lib/gcc/powerpc-eabi/*) \ - $(PORTLIBS) $(PORTLIBS)/wii +LIB_DIRS := $(DEVKITPRO)/libogc/lib/wii $(PORTLIBS)/lib ############################################################################### # Rule to make everything. @@ -186,7 +148,7 @@ include src/makefile.mk LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src + -iquote src OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) From 167be8be74dd053ccfc1e8f40dfbdc4fd69d2874 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Tue, 2 Feb 2021 12:05:25 +0000 Subject: [PATCH 02/11] use devkitPro docker image for CI --- .github/workflows/main.yml | 64 +++++--------------------------------- 1 file changed, 8 insertions(+), 56 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4247b8..ad05084 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,68 +1,20 @@ -name: Build binaries +name: C/C++ CI on: [push, pull_request] jobs: build: + name: ubuntu-18.04 runs-on: ubuntu-18.04 - timeout-minutes: 20 + container: devkitpro/devkitppc:latest + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - - name: Cache - id: cache-1 - uses: actions/cache@v2 - with: - path: cache - key: ${{ runner.os }}-cache-1 - - name: Download devkitPPC r37, libogc 2.1.0, bin2s, elf2dol, ppc-mxml 2.11 and libfat-ogc 1.1.5 - if: steps.cache-1.outputs.cache-hit != 'true' - # general-tools is needed for bin2s and gamecube-tools is needed for elf2dol - run: | - mkdir cache && cd cache - wget "https://wii.leseratte10.de/devkitPro/file.php/devkitPPC-r37-4-linux.pkg.tar.xz" - wget "https://wii.leseratte10.de/devkitPro/file.php/libogc-2.1.0-1-any.pkg.tar.xz" - wget "https://wii.leseratte10.de/devkitPro/file.php/general-tools-1.2.0-1-linux.pkg.tar.xz" - wget "https://wii.leseratte10.de/devkitPro/file.php/gamecube-tools-1.0.2-1-linux.pkg.tar.xz" - wget "https://wii.leseratte10.de/devkitPro/file.php/ppc-mxml-2.11-2-any.pkg.tar.xz" - wget "https://wii.leseratte10.de/devkitPro/file.php/libfat-ogc-1.1.5-2-any.pkg.tar.xz" - cd .. + - name: Build + run: | + make - - name: Extract all the archives - run: | - tar -xf cache/devkitPPC-r37-4-linux.pkg.tar.xz opt/devkitpro/devkitPPC --strip-components=1 - tar -xf cache/libogc-2.1.0-1-any.pkg.tar.xz opt/devkitpro/libogc --strip-components=1 - tar -xf cache/libfat-ogc-1.1.5-2-any.pkg.tar.xz opt/devkitpro/libogc --strip-components=1 - tar -xf cache/general-tools-1.2.0-1-linux.pkg.tar.xz opt/devkitpro/tools/bin/bin2s --strip-components=4 - sudo cp bin2s /usr/local/bin/bin2s - tar -xf cache/gamecube-tools-1.0.2-1-linux.pkg.tar.xz opt/devkitpro/tools/bin/elf2dol --strip-components=4 - sudo cp elf2dol /usr/local/bin/elf2dol - tar -xf cache/ppc-mxml-2.11-2-any.pkg.tar.xz opt/devkitpro/portlibs --strip-components=1 - - name: Compile - run: | - PATH=$(pwd)/devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/devkitpro/devkitPPC DEVKITPRO=$(pwd)/devkitpro make install - cd modules - PATH=$(pwd)/../devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/../devkitpro/devkitPPC DEVKITPRO=$(pwd)/../devkitpro make - cd .. - PATH=$(pwd)/devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/devkitpro/devkitPPC DEVKITPRO=$(pwd)/devkitpro make - PATH=$(pwd)/devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/devkitpro/devkitPPC DEVKITPRO=$(pwd)/devkitpro make release - cp modules/*/bin/*.mod . - - - name: Upload compiled Brainslug binaries - uses: actions/upload-artifact@v2 - with: - name: brainslug - path: | - release/apps - release/bslug - release/readme.txt - - - name: Upload compiled modules - uses: actions/upload-artifact@v2 - with: - name: modules - path: | - *.mod From d65d04e363b57d7f49c850e2b479ccc0d6c57969 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Thu, 25 Mar 2021 11:44:34 +0000 Subject: [PATCH 03/11] don't install to devkitpro folder. This is reserved for devkitPro supplied tools and libraries. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b664b19..d7cdf78 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ all : $(TARGET) $(BIN)/boot.elf ############################################################################### # Install rule -BSLUGDIR := $(DEVKITPRO)/bslug +BSLUGDIR := $(CURDIR)/bslug # Rule to install bslug. PHONY += install From 26b775ea988dc483c72034585ac202086f409e6c Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Thu, 25 Mar 2021 12:55:44 +0000 Subject: [PATCH 04/11] ignore missing .d files --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d7cdf78..b0f7648 100644 --- a/Makefile +++ b/Makefile @@ -155,7 +155,7 @@ OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ifeq ($(words $(filter clean%,$(MAKECMDGOALS))),0) ifeq ($(words $(filter install%,$(MAKECMDGOALS))),0) ifeq ($(words $(filter uninstall%,$(MAKECMDGOALS))),0) - include $(patsubst %.c,$(BUILD)/%.c.d,$(filter %.c,$(SRC))) + -include $(patsubst %.c,$(BUILD)/%.c.d,$(filter %.c,$(SRC))) endif endif endif From 1cf34075af716095f4445ed81f7cfeeab43462ba Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Thu, 25 Mar 2021 13:02:21 +0000 Subject: [PATCH 05/11] allow external override of BSLUGDIR --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b0f7648..1e65e84 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif +BSLUGDIR ?= $(CURDIR)/bslug + include $(DEVKITPPC)/base_tools PORTLIBS := $(DEVKITPRO)/portlibs/ppc @@ -102,8 +104,6 @@ all : $(TARGET) $(BIN)/boot.elf ############################################################################### # Install rule -BSLUGDIR := $(CURDIR)/bslug - # Rule to install bslug. PHONY += install install : bslug_include modules symbols bslug.ld bslug_elf.ld From 4b179480b53ea1c981557a5c8d7a26f0a18fbeb2 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Thu, 25 Mar 2021 13:21:47 +0000 Subject: [PATCH 06/11] update installing/building instructions --- BUILDING | 7 +++---- INSTALLING | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/BUILDING b/BUILDING index 789b111..45c1718 100644 --- a/BUILDING +++ b/BUILDING @@ -1,7 +1,6 @@ -To build the BrainSlug channel you must first have a copy of devkitPro: - http://sourceforge.net/projects/devkitpro/ -You must also have libmxml for devkitPro, which can be found here: - http://wiibrew.org/wiki/Mini-XML +To build the BrainSlug channel you must first have a copy of devkitPPC: + https://devkitpro.org +You must also have libmxml for devkitPPC, which can be installed via pacman: You also need to have libfat installed. In the root directory of the BrainSlug repository, run the commands: diff --git a/INSTALLING b/INSTALLING index 573d70f..424edfd 100644 --- a/INSTALLING +++ b/INSTALLING @@ -1,14 +1,13 @@ To install BrainSlug for development of modules you must first have a copy of -devkitPro, specifically with devkitPPC included: - http://sourceforge.net/projects/devkitpro/ +devkitPPC installed. You can obtain this from devkitPro (https://devkitpro.org) In the root directory of the BrainSlug repository, run the following commands: make clean && make -C modules clean make install - -It may be necessary to run the last command with administrative privileges. -This installs the necessary headers into a bslug subdirectory within devkitPro. +This installs the necessary headers into a bslug subdirectory. Please do not +install this to /opt/devkitpro which is reserved for devkitPro tools and libraries. + Now BrainSlug modules can be compiled. See modules/README for more information about BrainSlug module development. From 0d30f6b0cb7955a414d7c8aa368cdcb52a473413 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Thu, 25 Mar 2021 13:24:42 +0000 Subject: [PATCH 07/11] clean up modules Makefile --- modules/console-gx/Makefile | 63 +++--- modules/console-gx/makefile.mk | 17 -- modules/console-sd/Makefile | 63 +++--- modules/console-sd/makefile.mk | 17 -- modules/gecko/Makefile | 63 +++--- modules/gecko/makefile.mk | 17 -- modules/https/Makefile | 345 ++++++++++++++++----------------- modules/https/makefile.mk | 17 -- modules/libfat-sd/Makefile | 63 +++--- modules/libfat-sd/makefile.mk | 17 -- modules/libfat/Makefile | 63 +++--- modules/libfat/makefile.mk | 17 -- modules/libsd/Makefile | 63 +++--- modules/libsd/makefile.mk | 17 -- modules/template/Makefile | 63 +++--- modules/template/makefile.mk | 17 -- 16 files changed, 389 insertions(+), 533 deletions(-) delete mode 100644 modules/console-gx/makefile.mk delete mode 100644 modules/console-sd/makefile.mk delete mode 100644 modules/gecko/makefile.mk delete mode 100644 modules/https/makefile.mk delete mode 100644 modules/libfat-sd/makefile.mk delete mode 100644 modules/libfat/makefile.mk delete mode 100644 modules/libsd/makefile.mk delete mode 100644 modules/template/makefile.mk diff --git a/modules/console-gx/Makefile b/modules/console-gx/Makefile index e8c57ec..20394d8 100644 --- a/modules/console-gx/Makefile +++ b/modules/console-gx/Makefile @@ -4,27 +4,32 @@ # # A makefile script for generation of a brainslug module ############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. ############################################################################### # devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include +include $(DEVKITPPC)/base_tools -include makefile.mk +############################################################################### +# Source files + +# The source files to compile. +SRC := main.c +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := ############################################################################### # Parameters @@ -37,22 +42,15 @@ LOG ?= @echo $@ # The intermediate directory for compiled object files. BUILD ?= build # The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) +LIST ?= $(TARGET).list # The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) +MAP ?= $(TARGET).map INC_DIRS += $(LIB_INC_DIRS) ############################################################################### # Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking @@ -65,6 +63,14 @@ LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ LD1FLAGS += --relocatable -s \ -T $(BSLUGDIR)/bslug_elf.ld + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + # -O2: optimise lots # -Wall: generate lots of warnings # -x c: compile as C code @@ -73,21 +79,19 @@ LD1FLAGS += --relocatable -s \ # -ffreestanding: we don't have libc; don't expect we do # -DGEKKO: define the symbol GEKKO (used in some libogc headers) # -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) # -mrvl: enable wii/gamecube compilation # -mcpu=750: enable processor specific compilation # -meabi: enable eabi specific compilation # -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables # -fno-common: stop common variables which the loader can't understand # -msdata-none: do not use r2 or r13 as small data areas # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ -msdata=none -memb -ffunction-sections -fdata-sections ifdef DEBUG @@ -110,11 +114,6 @@ all : $(TARGET) ############################################################################### # Derived rules -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ############################################################################### diff --git a/modules/console-gx/makefile.mk b/modules/console-gx/makefile.mk deleted file mode 100644 index 0b8bed9..0000000 --- a/modules/console-gx/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := main.c -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := diff --git a/modules/console-sd/Makefile b/modules/console-sd/Makefile index e8c57ec..20394d8 100644 --- a/modules/console-sd/Makefile +++ b/modules/console-sd/Makefile @@ -4,27 +4,32 @@ # # A makefile script for generation of a brainslug module ############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. ############################################################################### # devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include +include $(DEVKITPPC)/base_tools -include makefile.mk +############################################################################### +# Source files + +# The source files to compile. +SRC := main.c +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := ############################################################################### # Parameters @@ -37,22 +42,15 @@ LOG ?= @echo $@ # The intermediate directory for compiled object files. BUILD ?= build # The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) +LIST ?= $(TARGET).list # The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) +MAP ?= $(TARGET).map INC_DIRS += $(LIB_INC_DIRS) ############################################################################### # Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking @@ -65,6 +63,14 @@ LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ LD1FLAGS += --relocatable -s \ -T $(BSLUGDIR)/bslug_elf.ld + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + # -O2: optimise lots # -Wall: generate lots of warnings # -x c: compile as C code @@ -73,21 +79,19 @@ LD1FLAGS += --relocatable -s \ # -ffreestanding: we don't have libc; don't expect we do # -DGEKKO: define the symbol GEKKO (used in some libogc headers) # -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) # -mrvl: enable wii/gamecube compilation # -mcpu=750: enable processor specific compilation # -meabi: enable eabi specific compilation # -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables # -fno-common: stop common variables which the loader can't understand # -msdata-none: do not use r2 or r13 as small data areas # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ -msdata=none -memb -ffunction-sections -fdata-sections ifdef DEBUG @@ -110,11 +114,6 @@ all : $(TARGET) ############################################################################### # Derived rules -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ############################################################################### diff --git a/modules/console-sd/makefile.mk b/modules/console-sd/makefile.mk deleted file mode 100644 index 0b8bed9..0000000 --- a/modules/console-sd/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := main.c -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := diff --git a/modules/gecko/Makefile b/modules/gecko/Makefile index e8c57ec..55d164d 100644 --- a/modules/gecko/Makefile +++ b/modules/gecko/Makefile @@ -4,27 +4,32 @@ # # A makefile script for generation of a brainslug module ############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. ############################################################################### # devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include +include $(DEVKITPPC)/base_tools -include makefile.mk +############################################################################### +# Source files + +# The source files to compile. +SRC := gecko.c +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := ############################################################################### # Parameters @@ -37,22 +42,15 @@ LOG ?= @echo $@ # The intermediate directory for compiled object files. BUILD ?= build # The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) +LIST ?= $(TARGET).list # The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) +MAP ?= $(TARGET).map INC_DIRS += $(LIB_INC_DIRS) ############################################################################### # Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking @@ -65,6 +63,14 @@ LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ LD1FLAGS += --relocatable -s \ -T $(BSLUGDIR)/bslug_elf.ld + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + # -O2: optimise lots # -Wall: generate lots of warnings # -x c: compile as C code @@ -73,21 +79,19 @@ LD1FLAGS += --relocatable -s \ # -ffreestanding: we don't have libc; don't expect we do # -DGEKKO: define the symbol GEKKO (used in some libogc headers) # -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) # -mrvl: enable wii/gamecube compilation # -mcpu=750: enable processor specific compilation # -meabi: enable eabi specific compilation # -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables # -fno-common: stop common variables which the loader can't understand # -msdata-none: do not use r2 or r13 as small data areas # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ -msdata=none -memb -ffunction-sections -fdata-sections ifdef DEBUG @@ -110,11 +114,6 @@ all : $(TARGET) ############################################################################### # Derived rules -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ############################################################################### diff --git a/modules/gecko/makefile.mk b/modules/gecko/makefile.mk deleted file mode 100644 index f4bc93f..0000000 --- a/modules/gecko/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := gecko.c -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := diff --git a/modules/https/Makefile b/modules/https/Makefile index 5aab63b..20394d8 100644 --- a/modules/https/Makefile +++ b/modules/https/Makefile @@ -1,173 +1,172 @@ -############################################################################### -# Makefile -# by Alex Chadwick -# -# A makefile script for generation of a brainslug module -############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. - -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include - -include makefile.mk - -############################################################################### -# Parameters - -# A comma to make writing commands easier -C := , -# Used to suppress command echo. -Q ?= @ -LOG ?= @echo $@ -# The intermediate directory for compiled object files. -BUILD ?= build -# The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) -# The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) - -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as -LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG -endif - -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +############################################################################### +# Makefile +# by Alex Chadwick +# +# A makefile script for generation of a brainslug module +############################################################################### + +############################################################################### +# devkitpro settings +ifeq ($(strip $(DEVKITPPC)),) + $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif + +include $(DEVKITPPC)/base_tools + +############################################################################### +# Source files + +# The source files to compile. +SRC := main.c +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := + +############################################################################### +# Parameters + +# A comma to make writing commands easier +C := , +# Used to suppress command echo. +Q ?= @ +LOG ?= @echo $@ +# The intermediate directory for compiled object files. +BUILD ?= build +# The name of the assembler listing file to generate. +LIST ?= $(TARGET).list +# The name of the map file to generate. +MAP ?= $(TARGET).map + +INC_DIRS += $(LIB_INC_DIRS) + +############################################################################### +# Compiler settings +LD := $(PREFIX)ld + +# --relocatable: make sure ld doesn't remove relocations bslug will need +# -s: strip local symbols to speed linking +# --gc-sections: remove unneeded symbols +# -T: use the linker script specified (to force certain bslug sections together) +# -Map: generate a map file +LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ + -T $(BSLUGDIR)/bslug.ld \ + $(patsubst %,-Map %,$(strip $(MAP))) +LD1FLAGS += --relocatable -s \ + -T $(BSLUGDIR)/bslug_elf.ld + + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + +# -O2: optimise lots +# -Wall: generate lots of warnings +# -x c: compile as C code +# -std=gnu99: use the C99 standard with GNU extensions +# -nostdinc: don't include standard headers (we don't have all the symbols) +# -ffreestanding: we don't have libc; don't expect we do +# -DGEKKO: define the symbol GEKKO (used in some libogc headers) +# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) +# -mrvl: enable wii/gamecube compilation +# -mcpu=750: enable processor specific compilation +# -meabi: enable eabi specific compilation +# -mhard-float: enable hardware floating point instructions +# -fno-common: stop common variables which the loader can't understand +# -msdata-none: do not use r2 or r13 as small data areas +# -memb: enable embedded application specific compilation +# -ffunction-sections: split up functions so linker can garbage collect +# -fdata-sections: split up data so linker can garbage collect +CFLAGS += -O2 -Wall -x c -std=gnu99 \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ + -msdata=none -memb -ffunction-sections -fdata-sections + +ifdef DEBUG +else + CFLAGS += -DNDEBUG +endif + +############################################################################### +# Variable init + +# Phony targets +PHONY := + +############################################################################### +# Rule to make everything. +PHONY += all + +all : $(TARGET) + +############################################################################### +# Derived rules + +OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) + +############################################################################### +# Special build rules + +# Rule to make the module file. +$(TARGET) : $(BUILD)/output.elf | $(BIN) + $(LOG) + $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ + +# Rule to make the module file. +$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) + $(LOG) + $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ + +# Rule to make intermediate directory +$(BUILD) : + $Qmkdir $@ + +# Rule to make output directory +$(BIN) : + $Qmkdir $@ + +############################################################################### +# Standard build rules + +$(BUILD)/%.c.o: %.c | $(BUILD) + $(LOG) + -$Qmkdir -p $(dir $@) + $Q$(CC) -c $(CFLAGS) $< -o $@ + +############################################################################### +# Assembly listing rules + +# Rule to make assembly listing. +PHONY += list +list : $(LIST) + +# Rule to make the listing file. +%.list : $(TARGET) + $(LOG) + -$Qmkdir -p $(dir $@) + $Q$(OBJDUMP) -d $< > $@ + +############################################################################### +# Clean rule + +# Rule to clean files. +PHONY += clean +clean : + $Qrm -rf $(wildcard $(BUILD) $(BIN)) + +############################################################################### +# Phony targets + +.PHONY : $(PHONY) diff --git a/modules/https/makefile.mk b/modules/https/makefile.mk deleted file mode 100644 index b7fa45f..0000000 --- a/modules/https/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := main.c -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := diff --git a/modules/libfat-sd/Makefile b/modules/libfat-sd/Makefile index e8c57ec..20394d8 100644 --- a/modules/libfat-sd/Makefile +++ b/modules/libfat-sd/Makefile @@ -4,27 +4,32 @@ # # A makefile script for generation of a brainslug module ############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. ############################################################################### # devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include +include $(DEVKITPPC)/base_tools -include makefile.mk +############################################################################### +# Source files + +# The source files to compile. +SRC := main.c +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := ############################################################################### # Parameters @@ -37,22 +42,15 @@ LOG ?= @echo $@ # The intermediate directory for compiled object files. BUILD ?= build # The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) +LIST ?= $(TARGET).list # The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) +MAP ?= $(TARGET).map INC_DIRS += $(LIB_INC_DIRS) ############################################################################### # Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking @@ -65,6 +63,14 @@ LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ LD1FLAGS += --relocatable -s \ -T $(BSLUGDIR)/bslug_elf.ld + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + # -O2: optimise lots # -Wall: generate lots of warnings # -x c: compile as C code @@ -73,21 +79,19 @@ LD1FLAGS += --relocatable -s \ # -ffreestanding: we don't have libc; don't expect we do # -DGEKKO: define the symbol GEKKO (used in some libogc headers) # -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) # -mrvl: enable wii/gamecube compilation # -mcpu=750: enable processor specific compilation # -meabi: enable eabi specific compilation # -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables # -fno-common: stop common variables which the loader can't understand # -msdata-none: do not use r2 or r13 as small data areas # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ -msdata=none -memb -ffunction-sections -fdata-sections ifdef DEBUG @@ -110,11 +114,6 @@ all : $(TARGET) ############################################################################### # Derived rules -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ############################################################################### diff --git a/modules/libfat-sd/makefile.mk b/modules/libfat-sd/makefile.mk deleted file mode 100644 index 0b8bed9..0000000 --- a/modules/libfat-sd/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := main.c -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := diff --git a/modules/libfat/Makefile b/modules/libfat/Makefile index e8c57ec..972f40d 100644 --- a/modules/libfat/Makefile +++ b/modules/libfat/Makefile @@ -4,27 +4,32 @@ # # A makefile script for generation of a brainslug module ############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. ############################################################################### # devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include +include $(DEVKITPPC)/base_tools -include makefile.mk +############################################################################### +# Source files + +# The source files to compile. +SRC := $(wildcard *.c) +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := ############################################################################### # Parameters @@ -37,22 +42,15 @@ LOG ?= @echo $@ # The intermediate directory for compiled object files. BUILD ?= build # The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) +LIST ?= $(TARGET).list # The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) +MAP ?= $(TARGET).map INC_DIRS += $(LIB_INC_DIRS) ############################################################################### # Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking @@ -65,6 +63,14 @@ LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ LD1FLAGS += --relocatable -s \ -T $(BSLUGDIR)/bslug_elf.ld + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + # -O2: optimise lots # -Wall: generate lots of warnings # -x c: compile as C code @@ -73,21 +79,19 @@ LD1FLAGS += --relocatable -s \ # -ffreestanding: we don't have libc; don't expect we do # -DGEKKO: define the symbol GEKKO (used in some libogc headers) # -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) # -mrvl: enable wii/gamecube compilation # -mcpu=750: enable processor specific compilation # -meabi: enable eabi specific compilation # -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables # -fno-common: stop common variables which the loader can't understand # -msdata-none: do not use r2 or r13 as small data areas # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ -msdata=none -memb -ffunction-sections -fdata-sections ifdef DEBUG @@ -110,11 +114,6 @@ all : $(TARGET) ############################################################################### # Derived rules -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ############################################################################### diff --git a/modules/libfat/makefile.mk b/modules/libfat/makefile.mk deleted file mode 100644 index 856b827..0000000 --- a/modules/libfat/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := $(wildcard *.c) -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := diff --git a/modules/libsd/Makefile b/modules/libsd/Makefile index e8c57ec..20394d8 100644 --- a/modules/libsd/Makefile +++ b/modules/libsd/Makefile @@ -4,27 +4,32 @@ # # A makefile script for generation of a brainslug module ############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. ############################################################################### # devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include +include $(DEVKITPPC)/base_tools -include makefile.mk +############################################################################### +# Source files + +# The source files to compile. +SRC := main.c +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := ############################################################################### # Parameters @@ -37,22 +42,15 @@ LOG ?= @echo $@ # The intermediate directory for compiled object files. BUILD ?= build # The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) +LIST ?= $(TARGET).list # The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) +MAP ?= $(TARGET).map INC_DIRS += $(LIB_INC_DIRS) ############################################################################### # Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking @@ -65,6 +63,14 @@ LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ LD1FLAGS += --relocatable -s \ -T $(BSLUGDIR)/bslug_elf.ld + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + # -O2: optimise lots # -Wall: generate lots of warnings # -x c: compile as C code @@ -73,21 +79,19 @@ LD1FLAGS += --relocatable -s \ # -ffreestanding: we don't have libc; don't expect we do # -DGEKKO: define the symbol GEKKO (used in some libogc headers) # -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) # -mrvl: enable wii/gamecube compilation # -mcpu=750: enable processor specific compilation # -meabi: enable eabi specific compilation # -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables # -fno-common: stop common variables which the loader can't understand # -msdata-none: do not use r2 or r13 as small data areas # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ -msdata=none -memb -ffunction-sections -fdata-sections ifdef DEBUG @@ -110,11 +114,6 @@ all : $(TARGET) ############################################################################### # Derived rules -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ############################################################################### diff --git a/modules/libsd/makefile.mk b/modules/libsd/makefile.mk deleted file mode 100644 index ca5bed4..0000000 --- a/modules/libsd/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := main.c wiisd.c -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := diff --git a/modules/template/Makefile b/modules/template/Makefile index e8c57ec..20394d8 100644 --- a/modules/template/Makefile +++ b/modules/template/Makefile @@ -4,27 +4,32 @@ # # A makefile script for generation of a brainslug module ############################################################################### -# Hopefully you shouldn't need to change anything in this file. -# Alter makefile.mk to change common settings. ############################################################################### # devkitpro settings -ifeq ($(strip $(DEVKITPRO)),) - $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro") -endif ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif -BSLUGDIR := $(DEVKITPRO)/bslug -GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion) - -PATH := $(DEVKITPPC)/bin:$(PATH) -LIB_INC_DIRS := $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include \ - $(DEVKITPPC)/lib/gcc/powerpc-eabi/$(GCC_VER)/include-fixed \ - $(BSLUGDIR)/include +include $(DEVKITPPC)/base_tools -include makefile.mk +############################################################################### +# Source files + +# The source files to compile. +SRC := main.c +# Include directories +INC_DIRS := +# Library directories +LIB_DIRS := +# The names of libraries to use. +LIBS := +# The output directory for compiled results. +BIN := bin +# The name of the output file to generate. +TARGET := $(BIN)/$(notdir $(CURDIR)).mod +# C compiler flags +CFLAGS := ############################################################################### # Parameters @@ -37,22 +42,15 @@ LOG ?= @echo $@ # The intermediate directory for compiled object files. BUILD ?= build # The name of the assembler listing file to generate. -LIST ?= $(TARGET:.mod=.list) +LIST ?= $(TARGET).list # The name of the map file to generate. -MAP ?= $(TARGET:.mod=.map) +MAP ?= $(TARGET).map INC_DIRS += $(LIB_INC_DIRS) ############################################################################### # Compiler settings - -# The toolchain to use. -PREFIX ?= powerpc-eabi- -# Tools to use -AS := $(PREFIX)as LD := $(PREFIX)ld -CC := $(PREFIX)g++ -OBJDUMP := $(PREFIX)objdump # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking @@ -65,6 +63,14 @@ LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ LD1FLAGS += --relocatable -s \ -T $(BSLUGDIR)/bslug_elf.ld + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) \ + -I $(BSLUGDIR)/include + + # -O2: optimise lots # -Wall: generate lots of warnings # -x c: compile as C code @@ -73,21 +79,19 @@ LD1FLAGS += --relocatable -s \ # -ffreestanding: we don't have libc; don't expect we do # -DGEKKO: define the symbol GEKKO (used in some libogc headers) # -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -D__wii__: define the symbol __wii__ (used in some libogc headers) # -mrvl: enable wii/gamecube compilation # -mcpu=750: enable processor specific compilation # -meabi: enable eabi specific compilation # -mhard-float: enable hardware floating point instructions -# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables # -fno-common: stop common variables which the loader can't understand # -msdata-none: do not use r2 or r13 as small data areas # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -nostdinc -ffreestanding \ - -DGEKKO -DHW_RVL -D__wii__ \ - -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -fno-common \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ -msdata=none -memb -ffunction-sections -fdata-sections ifdef DEBUG @@ -110,11 +114,6 @@ all : $(TARGET) ############################################################################### # Derived rules -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src - OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) ############################################################################### diff --git a/modules/template/makefile.mk b/modules/template/makefile.mk deleted file mode 100644 index 0b8bed9..0000000 --- a/modules/template/makefile.mk +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################### -# Source files - -# The source files to compile. -SRC := main.c -# Include directories -INC_DIRS := -# Library directories -LIB_DIRS := -# The names of libraries to use. -LIBS := -# The output directory for compiled results. -BIN := bin -# The name of the output file to generate. -TARGET := $(BIN)/$(notdir $(CURDIR)).mod -# C compiler flags -CFLAGS := From 0b1a55c496a573fe8273cfb62659bb97caf6ac94 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Thu, 25 Mar 2021 13:30:27 +0000 Subject: [PATCH 08/11] update workflow to build modules & upload artifacts --- .github/workflows/main.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ad05084..4652116 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,24 @@ jobs: - name: Build run: | - make + export BSLUGDIR=$(pwd)blsug + make && make install + make -C modules + make release + cp modules/*/bin/*.mod . + - name: Upload compiled Brainslug binaries + uses: actions/upload-artifact@v2 + with: + name: brainslug + path: | + release/apps + release/bslug + release/readme.txt - + - name: Upload compiled modules + uses: actions/upload-artifact@v2 + with: + name: modules + path: | + *.mod From 903009b3c2b0cbdddd61a8d622bf17ddb7fbcc8c Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Fri, 26 Mar 2021 09:24:09 +0000 Subject: [PATCH 09/11] use common makefile fragment for modules --- Makefile | 3 +- bslug.mk | 130 +++++++++++++++++++++++++++++++++++ modules/console-gx/Makefile | 133 +----------------------------------- modules/console-sd/Makefile | 133 +----------------------------------- modules/gecko/Makefile | 133 +----------------------------------- modules/libfat-sd/Makefile | 133 +----------------------------------- modules/libfat/Makefile | 133 +----------------------------------- modules/libsd/Makefile | 133 +----------------------------------- modules/template/Makefile | 133 +----------------------------------- 9 files changed, 153 insertions(+), 911 deletions(-) create mode 100644 bslug.mk diff --git a/Makefile b/Makefile index 1e65e84..53f136d 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,7 @@ all : $(TARGET) $(BIN)/boot.elf # Rule to install bslug. PHONY += install -install : bslug_include modules symbols bslug.ld bslug_elf.ld +install : bslug_include modules symbols bslug.ld bslug_elf.ld bslug.mk $(LOG) $(addprefix $Qrm -rf ,$(wildcard $(BSLUGDIR))) $Qmkdir $(BSLUGDIR) @@ -115,6 +115,7 @@ install : bslug_include modules symbols bslug.ld bslug_elf.ld $Qcp -r symbols $(BSLUGDIR) $Qcp -r bslug.ld $(BSLUGDIR) $Qcp -r bslug_elf.ld $(BSLUGDIR) + $Qcp -r bslug.mk $(BSLUGDIR) # Rule to install bslug. PHONY += uninstall diff --git a/bslug.mk b/bslug.mk new file mode 100644 index 0000000..7c0a3a6 --- /dev/null +++ b/bslug.mk @@ -0,0 +1,130 @@ +############################################################################### +# Compiler settings + +############################################################################### +# devkitPPC settings +ifeq ($(strip $(DEVKITPPC)),) + $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif + +include $(DEVKITPPC)/base_tools + +LD := $(PREFIX)ld + +# --relocatable: make sure ld doesn't remove relocations bslug will need +# -s: strip local symbols to speed linking +# --gc-sections: remove unneeded symbols +# -T: use the linker script specified (to force certain bslug sections together) +# -Map: generate a map file +LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ + -T $(BSLUGDIR)/bslug.ld \ + $(patsubst %,-Map %,$(strip $(MAP))) +LD1FLAGS += --relocatable -s \ + -T $(BSLUGDIR)/bslug_elf.ld + + +LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ + $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) +CFLAGS += -I $(BSLUGDIR)/include \ + $(patsubst %,-I %,$(INC_DIRS)) \ + $(patsubst %,-I %/include,$(LIB_DIRS)) + +# -O2: optimise lots +# -Wall: generate lots of warnings +# -x c: compile as C code +# -std=gnu99: use the C99 standard with GNU extensions +# -nostdinc: don't include standard headers (we don't have all the symbols) +# -ffreestanding: we don't have libc; don't expect we do +# -DGEKKO: define the symbol GEKKO (used in some libogc headers) +# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) +# -mrvl: enable wii/gamecube compilation +# -mcpu=750: enable processor specific compilation +# -meabi: enable eabi specific compilation +# -mhard-float: enable hardware floating point instructions +# -fno-common: stop common variables which the loader can't understand +# -msdata-none: do not use r2 or r13 as small data areas +# -memb: enable embedded application specific compilation +# -ffunction-sections: split up functions so linker can garbage collect +# -fdata-sections: split up data so linker can garbage collect +CFLAGS += -O2 -Wall -x c -std=gnu99 \ + -ffreestanding \ + -DGEKKO -DHW_RVL \ + -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ + -msdata=none -memb -ffunction-sections -fdata-sections + +ifdef DEBUG +else + CFLAGS += -DNDEBUG +endif + +############################################################################### +# Variable init + +# Phony targets +PHONY := + +############################################################################### +# Rule to make everything. +PHONY += all + +all : $(TARGET) + +############################################################################### +# Derived rules + +OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) + +############################################################################### +# Special build rules + +# Rule to make the module file. +$(TARGET) : $(BUILD)/output.elf | $(BIN) + $(LOG) + $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ + +# Rule to make the module file. +$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) + $(LOG) + $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ + +# Rule to make intermediate directory +$(BUILD) : + $Qmkdir $@ + +# Rule to make output directory +$(BIN) : + $Qmkdir $@ + +############################################################################### +# Standard build rules + +$(BUILD)/%.c.o: %.c | $(BUILD) + $(LOG) + -$Qmkdir -p $(dir $@) + $Q$(CC) -c $(CFLAGS) $< -o $@ + +############################################################################### +# Assembly listing rules + +# Rule to make assembly listing. +PHONY += list +list : $(LIST) + +# Rule to make the listing file. +%.list : $(TARGET) + $(LOG) + -$Qmkdir -p $(dir $@) + $Q$(OBJDUMP) -d $< > $@ + +############################################################################### +# Clean rule + +# Rule to clean files. +PHONY += clean +clean : + $Qrm -rf $(wildcard $(BUILD) $(BIN)) + +############################################################################### +# Phony targets + +.PHONY : $(PHONY) diff --git a/modules/console-gx/Makefile b/modules/console-gx/Makefile index 20394d8..7265e24 100644 --- a/modules/console-gx/Makefile +++ b/modules/console-gx/Makefile @@ -5,14 +5,6 @@ # A makefile script for generation of a brainslug module ############################################################################### -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -include $(DEVKITPPC)/base_tools - ############################################################################### # Source files @@ -46,127 +38,8 @@ LIST ?= $(TARGET).list # The name of the map file to generate. MAP ?= $(TARGET).map -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings -LD := $(PREFIX)ld - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) \ - -I $(BSLUGDIR)/include - - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -DGEKKO -DHW_RVL \ - -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG +ifeq ($(strip $(BSLUGDIR)),) + $(error "Please set BSLUGDIR in your environment. export BSLUGDIR=bslug") endif -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +include $(BSLUGDIR)/bslug.mk \ No newline at end of file diff --git a/modules/console-sd/Makefile b/modules/console-sd/Makefile index 20394d8..7265e24 100644 --- a/modules/console-sd/Makefile +++ b/modules/console-sd/Makefile @@ -5,14 +5,6 @@ # A makefile script for generation of a brainslug module ############################################################################### -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -include $(DEVKITPPC)/base_tools - ############################################################################### # Source files @@ -46,127 +38,8 @@ LIST ?= $(TARGET).list # The name of the map file to generate. MAP ?= $(TARGET).map -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings -LD := $(PREFIX)ld - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) \ - -I $(BSLUGDIR)/include - - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -DGEKKO -DHW_RVL \ - -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG +ifeq ($(strip $(BSLUGDIR)),) + $(error "Please set BSLUGDIR in your environment. export BSLUGDIR=bslug") endif -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +include $(BSLUGDIR)/bslug.mk \ No newline at end of file diff --git a/modules/gecko/Makefile b/modules/gecko/Makefile index 55d164d..f3060f3 100644 --- a/modules/gecko/Makefile +++ b/modules/gecko/Makefile @@ -5,14 +5,6 @@ # A makefile script for generation of a brainslug module ############################################################################### -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -include $(DEVKITPPC)/base_tools - ############################################################################### # Source files @@ -46,127 +38,8 @@ LIST ?= $(TARGET).list # The name of the map file to generate. MAP ?= $(TARGET).map -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings -LD := $(PREFIX)ld - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) \ - -I $(BSLUGDIR)/include - - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -DGEKKO -DHW_RVL \ - -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG +ifeq ($(strip $(BSLUGDIR)),) + $(error "Please set BSLUGDIR in your environment. export BSLUGDIR=bslug") endif -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +include $(BSLUGDIR)/bslug.mk diff --git a/modules/libfat-sd/Makefile b/modules/libfat-sd/Makefile index 20394d8..7265e24 100644 --- a/modules/libfat-sd/Makefile +++ b/modules/libfat-sd/Makefile @@ -5,14 +5,6 @@ # A makefile script for generation of a brainslug module ############################################################################### -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -include $(DEVKITPPC)/base_tools - ############################################################################### # Source files @@ -46,127 +38,8 @@ LIST ?= $(TARGET).list # The name of the map file to generate. MAP ?= $(TARGET).map -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings -LD := $(PREFIX)ld - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) \ - -I $(BSLUGDIR)/include - - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -DGEKKO -DHW_RVL \ - -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG +ifeq ($(strip $(BSLUGDIR)),) + $(error "Please set BSLUGDIR in your environment. export BSLUGDIR=bslug") endif -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +include $(BSLUGDIR)/bslug.mk \ No newline at end of file diff --git a/modules/libfat/Makefile b/modules/libfat/Makefile index 972f40d..cf47d9c 100644 --- a/modules/libfat/Makefile +++ b/modules/libfat/Makefile @@ -5,14 +5,6 @@ # A makefile script for generation of a brainslug module ############################################################################### -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -include $(DEVKITPPC)/base_tools - ############################################################################### # Source files @@ -46,127 +38,8 @@ LIST ?= $(TARGET).list # The name of the map file to generate. MAP ?= $(TARGET).map -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings -LD := $(PREFIX)ld - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) \ - -I $(BSLUGDIR)/include - - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -DGEKKO -DHW_RVL \ - -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG +ifeq ($(strip $(BSLUGDIR)),) + $(error "Please set BSLUGDIR in your environment. export BSLUGDIR=bslug") endif -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +include $(BSLUGDIR)/bslug.mk \ No newline at end of file diff --git a/modules/libsd/Makefile b/modules/libsd/Makefile index 20394d8..7265e24 100644 --- a/modules/libsd/Makefile +++ b/modules/libsd/Makefile @@ -5,14 +5,6 @@ # A makefile script for generation of a brainslug module ############################################################################### -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -include $(DEVKITPPC)/base_tools - ############################################################################### # Source files @@ -46,127 +38,8 @@ LIST ?= $(TARGET).list # The name of the map file to generate. MAP ?= $(TARGET).map -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings -LD := $(PREFIX)ld - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) \ - -I $(BSLUGDIR)/include - - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -DGEKKO -DHW_RVL \ - -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG +ifeq ($(strip $(BSLUGDIR)),) + $(error "Please set BSLUGDIR in your environment. export BSLUGDIR=bslug") endif -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +include $(BSLUGDIR)/bslug.mk \ No newline at end of file diff --git a/modules/template/Makefile b/modules/template/Makefile index 20394d8..7265e24 100644 --- a/modules/template/Makefile +++ b/modules/template/Makefile @@ -5,14 +5,6 @@ # A makefile script for generation of a brainslug module ############################################################################### -############################################################################### -# devkitpro settings -ifeq ($(strip $(DEVKITPPC)),) - $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -include $(DEVKITPPC)/base_tools - ############################################################################### # Source files @@ -46,127 +38,8 @@ LIST ?= $(TARGET).list # The name of the map file to generate. MAP ?= $(TARGET).map -INC_DIRS += $(LIB_INC_DIRS) - -############################################################################### -# Compiler settings -LD := $(PREFIX)ld - -# --relocatable: make sure ld doesn't remove relocations bslug will need -# -s: strip local symbols to speed linking -# --gc-sections: remove unneeded symbols -# -T: use the linker script specified (to force certain bslug sections together) -# -Map: generate a map file -LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \ - -T $(BSLUGDIR)/bslug.ld \ - $(patsubst %,-Map %,$(strip $(MAP))) -LD1FLAGS += --relocatable -s \ - -T $(BSLUGDIR)/bslug_elf.ld - - -LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ - $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ - $(patsubst %,-I %/include,$(LIB_DIRS)) \ - -I $(BSLUGDIR)/include - - -# -O2: optimise lots -# -Wall: generate lots of warnings -# -x c: compile as C code -# -std=gnu99: use the C99 standard with GNU extensions -# -nostdinc: don't include standard headers (we don't have all the symbols) -# -ffreestanding: we don't have libc; don't expect we do -# -DGEKKO: define the symbol GEKKO (used in some libogc headers) -# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers) -# -mrvl: enable wii/gamecube compilation -# -mcpu=750: enable processor specific compilation -# -meabi: enable eabi specific compilation -# -mhard-float: enable hardware floating point instructions -# -fno-common: stop common variables which the loader can't understand -# -msdata-none: do not use r2 or r13 as small data areas -# -memb: enable embedded application specific compilation -# -ffunction-sections: split up functions so linker can garbage collect -# -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ - -ffreestanding \ - -DGEKKO -DHW_RVL \ - -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ - -msdata=none -memb -ffunction-sections -fdata-sections - -ifdef DEBUG -else - CFLAGS += -DNDEBUG +ifeq ($(strip $(BSLUGDIR)),) + $(error "Please set BSLUGDIR in your environment. export BSLUGDIR=bslug") endif -############################################################################### -# Variable init - -# Phony targets -PHONY := - -############################################################################### -# Rule to make everything. -PHONY += all - -all : $(TARGET) - -############################################################################### -# Derived rules - -OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC))) - -############################################################################### -# Special build rules - -# Rule to make the module file. -$(TARGET) : $(BUILD)/output.elf | $(BIN) - $(LOG) - $Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@ - -# Rule to make the module file. -$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD) - $(LOG) - $Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@ - -# Rule to make intermediate directory -$(BUILD) : - $Qmkdir $@ - -# Rule to make output directory -$(BIN) : - $Qmkdir $@ - -############################################################################### -# Standard build rules - -$(BUILD)/%.c.o: %.c | $(BUILD) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(CC) -c $(CFLAGS) $< -o $@ - -############################################################################### -# Assembly listing rules - -# Rule to make assembly listing. -PHONY += list -list : $(LIST) - -# Rule to make the listing file. -%.list : $(TARGET) - $(LOG) - -$Qmkdir -p $(dir $@) - $Q$(OBJDUMP) -d $< > $@ - -############################################################################### -# Clean rule - -# Rule to clean files. -PHONY += clean -clean : - $Qrm -rf $(wildcard $(BUILD) $(BIN)) - -############################################################################### -# Phony targets - -.PHONY : $(PHONY) +include $(BSLUGDIR)/bslug.mk \ No newline at end of file From 408b888794c28e8ac9ec182e5017d3b4b6fbfcbb Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Fri, 26 Mar 2021 10:35:31 +0000 Subject: [PATCH 10/11] use freestanding headers for modules --- bslug.mk | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bslug.mk b/bslug.mk index 7c0a3a6..d8d84d1 100644 --- a/bslug.mk +++ b/bslug.mk @@ -11,6 +11,10 @@ include $(DEVKITPPC)/base_tools LD := $(PREFIX)ld +FREESTANDING_INC := $(shell LANG=C $(CC) -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p') + +INC_DIRS += $(FREESTANDING_INC)include $(FREESTANDING_INC)include-fixed $(BSLUGDIR)/include + # --relocatable: make sure ld doesn't remove relocations bslug will need # -s: strip local symbols to speed linking # --gc-sections: remove unneeded symbols @@ -25,8 +29,8 @@ LD1FLAGS += --relocatable -s \ LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \ $(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS)) -CFLAGS += -I $(BSLUGDIR)/include \ - $(patsubst %,-I %,$(INC_DIRS)) \ + +CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \ $(patsubst %,-I %/include,$(LIB_DIRS)) # -O2: optimise lots @@ -46,7 +50,7 @@ CFLAGS += -I $(BSLUGDIR)/include \ # -memb: enable embedded application specific compilation # -ffunction-sections: split up functions so linker can garbage collect # -fdata-sections: split up data so linker can garbage collect -CFLAGS += -O2 -Wall -x c -std=gnu99 \ +CFLAGS += -O2 -Wall -x c -std=gnu99 -nostdinc \ -ffreestanding \ -DGEKKO -DHW_RVL \ -mrvl -mcpu=750 -meabi -mhard-float -fno-common \ From b67a1f599ee9074e97409066eef120415c340ed5 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Fri, 26 Mar 2021 23:35:07 +0000 Subject: [PATCH 11/11] use full compiler path for $(shell ) --- bslug.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bslug.mk b/bslug.mk index d8d84d1..5ab66c1 100644 --- a/bslug.mk +++ b/bslug.mk @@ -11,7 +11,7 @@ include $(DEVKITPPC)/base_tools LD := $(PREFIX)ld -FREESTANDING_INC := $(shell LANG=C $(CC) -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p') +FREESTANDING_INC := $(shell LANG=C $(DEVKITPPC)/bin/powerpc-eabi-gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p') INC_DIRS += $(FREESTANDING_INC)include $(FREESTANDING_INC)include-fixed $(BSLUGDIR)/include