Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for iplboot #22

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
path: libntfs

- name: Build libogc2
run: make install
run: |
mkdir -p build
make -C build -f ../Makefile install
working-directory: libogc2

- name: Build libfat
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
build
cube
deps
include
lib
wii
gc/ogc/libversion.h
*_rules
*.bz2
docs
warn.log
.meson-subproject-wrap-hash.txt
4 changes: 2 additions & 2 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NUMBER = 1.0
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.

OUTPUT_DIRECTORY = docs
OUTPUT_DIRECTORY = $(BUILDDIR)/docs

# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
Expand Down Expand Up @@ -579,7 +579,7 @@ WARN_FORMAT = "$file:$line: $text"
# and error messages should be written. If left blank the output is written
# to stderr.

WARN_LOGFILE = warn.log
WARN_LOGFILE = $(BUILDDIR)/warn.log

#---------------------------------------------------------------------------
# configuration options related to the input files
Expand Down
122 changes: 77 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(INSTALL_PREFIX)),)
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
endif
# Prevent variable expansion so it stays as-is in the installable rules
INSTALL_PREFIX := $$(DEVKITPRO)/libogc2
endif

INCDEST ?= include
LIBDEST ?= lib

ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif

CURFILE := $(abspath $(lastword $(MAKEFILE_LIST)))

export PATH := $(DEVKITPPC)/bin:$(PATH)

export LIBOGC_MAJOR := 2
export LIBOGC_MINOR := 1
export LIBOGC_PATCH := 0

include $(DEVKITPPC)/base_rules
export AR := $(AR) -D

BUILD := build

DATESTRING := $(shell date +%Y%m%d)
VERSTRING := $(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)

#---------------------------------------------------------------------------------
ifeq ($(strip $(PLATFORM)),)
#---------------------------------------------------------------------------------
export BASEDIR := $(CURDIR)
export BUILDDIR := $(CURDIR)
export BASEDIR := $(dir $(CURFILE))
export LWIPDIR := $(BASEDIR)/lwip
export OGCDIR := $(BASEDIR)/libogc
export MODDIR := $(BASEDIR)/libmodplay
Expand All @@ -39,10 +49,10 @@ export LIBASNDDIR := $(BASEDIR)/libasnd
export LIBAESNDDIR := $(BASEDIR)/libaesnd
export LIBISODIR := $(BASEDIR)/libiso9660
export LIBWIIKEYB := $(BASEDIR)/libwiikeyboard
export DEPS := $(BASEDIR)/deps
export LIBS := $(BASEDIR)/lib
export DEPS := $(BUILDDIR)/deps
export LIBS := $(BUILDDIR)/lib

export INCDIR := $(BASEDIR)/include
export INCDIR := $(BUILDDIR)/include

#---------------------------------------------------------------------------------
else
Expand Down Expand Up @@ -74,10 +84,12 @@ WIIKEYBLIB := $(LIBDIR)/libwiikeyboard
DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
-I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine \
-I$(BUILDDIR)/gc/ogc \
-I$(BASEDIR)/gc/modplay \
-I$(BASEDIR)/gc/bte \
-I$(BASEDIR)/gc/sdcard -I$(BASEDIR)/gc/wiiuse \
-I$(BASEDIR)/gc/di
-I$(BASEDIR)/gc/di \
-I$(CURDIR)

MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -ffunction-sections -fdata-sections

Expand All @@ -97,7 +109,8 @@ endif
INCLUDES += -I$(PORTLIBS_PATH)/ppc/include


CFLAGS := -DLIBOGC_INTERNAL -g -O2 -fno-strict-aliasing -Wall -Wno-address-of-packed-member $(MACHDEP) $(INCLUDES)
OPTLEVEL ?= 2
CFLAGS := -DLIBOGC_INTERNAL -g -O$(OPTLEVEL) -fno-strict-aliasing -Wall -Wno-address-of-packed-member $(MACHDEP) $(INCLUDES)
ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDES)

#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -180,7 +193,8 @@ WIIKEYBLIBOBJ := usbkeyboard.o keyboard.o ukbdmap.o wskbdutil.o



all: wii cube
PLATFORMS ?= wii cube
all: $(PLATFORMS)

#---------------------------------------------------------------------------------
wii: gc/ogc/libversion.h
Expand All @@ -189,7 +203,7 @@ wii: gc/ogc/libversion.h
@[ -d $(LIBS)/wii ] || mkdir -p $(LIBS)/wii
@[ -d $(DEPS)/wii ] || mkdir -p $(DEPS)/wii
@[ -d wii ] || mkdir -p wii
@$(MAKE) PLATFORM=wii libs -C wii -f $(CURDIR)/Makefile
@$(MAKE) PLATFORM=wii libs -C wii -f $(CURFILE)

#---------------------------------------------------------------------------------
cube: gc/ogc/libversion.h
Expand All @@ -198,26 +212,34 @@ cube: gc/ogc/libversion.h
@[ -d $(LIBS)/cube ] || mkdir -p $(LIBS)/cube
@[ -d $(DEPS)/cube ] || mkdir -p $(DEPS)/cube
@[ -d cube ] || mkdir -p cube
@$(MAKE) PLATFORM=cube libs -C cube -f $(CURDIR)/Makefile
@$(MAKE) PLATFORM=cube libs -C cube -f $(CURFILE)


#---------------------------------------------------------------------------------
gc/ogc/libversion.h : Makefile
gc/ogc/libversion.h : $(CURFILE)
#---------------------------------------------------------------------------------
@[ -d gc/ogc ] || mkdir -p gc/ogc
@echo "#ifndef __OGC_LIBVERSION_H__" > $@
@echo "#define __OGC_LIBVERSION_H__" >> $@
@echo >> $@
@echo "#define _V_MAJOR_ $(LIBOGC_MAJOR)" >> $@
@echo "#define _V_MINOR_ $(LIBOGC_MINOR)" >> $@
@echo "#define _V_PATCH_ $(LIBOGC_PATCH)" >> $@
@echo >> $@
@echo "#define _V_DATE_ __DATE__" >> $@
@echo "#define _V_TIME_ __TIME__" >> $@
@echo >> $@
@echo '#define _V_STRING "libOGC Release '$(LIBOGC_MAJOR).$(LIBOGC_MINOR).$(LIBOGC_PATCH)'"' >> $@
@echo >> $@
@echo "#endif // __OGC_LIBVERSION_H__" >> $@

#---------------------------------------------------------------------------------
RULES := wii_rules gamecube_rules
%_rules: $(BASEDIR)/%_rules.in
#---------------------------------------------------------------------------------
@sed \
-e "s|@PREFIX@|\$(INSTALL_PREFIX)|g" \
-e "s|@INCDIR@|$(INCDEST)|g" \
-e "s|@LIBDIR@|$(LIBDEST)|g" \
$< > $@

#---------------------------------------------------------------------------------
asndlib.o: asnd_dsp_mixer.h
#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -265,7 +287,7 @@ $(WIIUSELIB).a: $(WIIUSEOBJ)
.PHONY: libs wii cube install-headers install uninstall dist docs

#---------------------------------------------------------------------------------
install-headers:
install-headers: gc/ogc/libversion.h
#---------------------------------------------------------------------------------
@mkdir -p $(INCDIR)
@mkdir -p $(INCDIR)/ogc/machine
Expand All @@ -276,57 +298,67 @@ install-headers:
@mkdir -p $(INCDIR)/sdcard
@mkdir -p $(INCDIR)/di
@mkdir -p $(INCDIR)/wiikeyboard
@cp ./gc/*.h $(INCDIR)
@cp ./gc/ogc/*.h $(INCDIR)/ogc
@cp ./gc/ogc/machine/*.h $(INCDIR)/ogc/machine
@cp ./gc/sys/*.h $(INCDIR)/sys
@cp ./gc/bte/*.h $(INCDIR)/bte
@cp ./gc/wiiuse/*.h $(INCDIR)/wiiuse
@cp ./gc/modplay/*.h $(INCDIR)/modplay
@cp ./gc/sdcard/*.h $(INCDIR)/sdcard
@cp ./gc/di/*.h $(INCDIR)/di
@cp ./gc/wiikeyboard/*.h $(INCDIR)/wiikeyboard

#---------------------------------------------------------------------------------
install: wii cube install-headers
#---------------------------------------------------------------------------------
@mkdir -p $(DESTDIR)$(DEVKITPRO)/libogc2
@cp -frv include $(DESTDIR)$(DEVKITPRO)/libogc2
@cp -frv lib $(DESTDIR)$(DEVKITPRO)/libogc2
@cp -frv libogc_license.txt $(DESTDIR)$(DEVKITPRO)/libogc2
@cp -frv gamecube_rules wii_rules $(DESTDIR)$(DEVKITPRO)/libogc2
@cp $(BASEDIR)/gc/*.h $(INCDIR)
@cp $(BASEDIR)/gc/ogc/*.h $(INCDIR)/ogc
@cp $(BUILDDIR)/gc/ogc/*.h $(INCDIR)/ogc
@cp $(BASEDIR)/gc/ogc/machine/*.h $(INCDIR)/ogc/machine
@cp $(BASEDIR)/gc/sys/*.h $(INCDIR)/sys
@cp $(BASEDIR)/gc/bte/*.h $(INCDIR)/bte
@cp $(BASEDIR)/gc/wiiuse/*.h $(INCDIR)/wiiuse
@cp $(BASEDIR)/gc/modplay/*.h $(INCDIR)/modplay
@cp $(BASEDIR)/gc/sdcard/*.h $(INCDIR)/sdcard
@cp $(BASEDIR)/gc/di/*.h $(INCDIR)/di
@cp $(BASEDIR)/gc/wiikeyboard/*.h $(INCDIR)/wiikeyboard

#---------------------------------------------------------------------------------
install: $(PLATFORMS) $(RULES) install-headers
#---------------------------------------------------------------------------------
@$(eval INSTALL_PREFIX := $(INSTALL_PREFIX)) # Expand
@mkdir -p $(DESTDIR)$(INSTALL_PREFIX)
@mkdir -p $(DESTDIR)$(INSTALL_PREFIX)/$(INCDEST)
@cp -frv include/* -t $(DESTDIR)$(INSTALL_PREFIX)/$(INCDEST)
@mkdir -p $(DESTDIR)$(INSTALL_PREFIX)/$(LIBDEST)
@cp -frv lib/* -t $(DESTDIR)$(INSTALL_PREFIX)/$(LIBDEST)
@cp -frv $(BASEDIR)/libogc_license.txt $(DESTDIR)$(INSTALL_PREFIX)
@cp -frv $(RULES) $(DESTDIR)$(INSTALL_PREFIX)

#---------------------------------------------------------------------------------
uninstall:
#---------------------------------------------------------------------------------
@rm -frv $(DESTDIR)$(DEVKITPRO)/libogc2
@$(eval INSTALL_PREFIX := $(INSTALL_PREFIX)) # Expand
@rm -frv $(DESTDIR)$(INSTALL_PREFIX)

#---------------------------------------------------------------------------------
dist: wii cube install-headers
dist: $(PLATFORMS) $(RULES) install-headers
#---------------------------------------------------------------------------------
@tar --exclude=*CVS* --exclude=.svn --exclude=wii --exclude=cube --exclude=*deps* \
--exclude=*.bz2 --exclude=*include* --exclude=*lib/* --exclude=*docs/*\
-cvjf libogc2-src-$(VERSTRING).tar.bz2 *
@tar -cvjf libogc2-$(VERSTRING).tar.bz2 include lib libogc_license.txt gamecube_rules wii_rules
@tar -C $(BASEDIR) --exclude-vcs --exclude-vcs-ignores --exclude .github \
-cvjf $(BUILDDIR)/libogc2-src-$(VERSTRING).tar.bz2 .

@cp $(BASEDIR)/libogc_license.txt .
@tar -cvjf libogc2-$(VERSTRING).tar.bz2 include lib libogc_license.txt $(RULES)


LIBRARIES := $(OGCLIB).a $(MODLIB).a $(DBLIB).a $(TINYSMBLIB).a $(ASNDLIB).a $(AESNDLIB).a $(ISOLIB).a
ifeq ($(strip $(LIBRARIES)),)
LIBRARIES := ogc modplay db tinysmb asnd aesnd iso9660

ifeq ($(PLATFORM),cube)
LIBRARIES += $(BBALIB).a
LIBRARIES += bba
endif
ifeq ($(PLATFORM),wii)
LIBRARIES += $(BTELIB).a $(WIIUSELIB).a $(DILIB).a $(WIIKEYBLIB).a
LIBRARIES += bte wiiuse di wiikeyboard
endif
endif

#---------------------------------------------------------------------------------
libs: $(LIBRARIES)
libs: $(foreach lib,$(LIBRARIES),$(LIBDIR)/lib$(lib).a)
#---------------------------------------------------------------------------------

#---------------------------------------------------------------------------------
clean:
#---------------------------------------------------------------------------------
rm -fr wii cube
rm -fr gc/ogc/libversion.h
rm -fr $(RULES)
rm -fr $(DEPS)
rm -fr $(LIBS)
rm -fr $(INCDIR)
Expand All @@ -335,6 +367,6 @@ clean:
#---------------------------------------------------------------------------------
docs: install-headers
#---------------------------------------------------------------------------------
doxygen Doxyfile
@cd $(BASEDIR); doxygen Doxyfile

-include $(DEPSDIR)/*.d
58 changes: 58 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash

src=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")

if [[ "$(readlink -f "$PWD")" == "$src" ]]; then
printf '%s\n' 'This script must be run out of tree!'
exit 1
fi

tmp=$(mktemp -t Makefile.XXXXXXXXXX)
trap 'rm -f "$tmp"' EXIT

function write() {
printf '%s\n' "$*" >> "$tmp"
}

write '# Automatically generated file'

platforms=()
libs=()

for arg in "$@"; do
val="${arg#*=}"
case $arg in
--prefix=*)
write export INSTALL_PREFIX := "$val"
;;
--incdir=*)
write export INCDEST := "$val"
;;
--libdir=*)
write export LIBDEST := "$val"
;;
--opt-level=*)
write export OPTLEVEL := "$val"
;;
--with-platform=*)
platforms+=("$val")
;;
--with-lib=*)
libs+=("$val")
;;
*)
printf '%s\n' "$arg: Invalid argument"
exit 1
esac
done

if (( ${#platforms[@]} )); then
write export PLATFORMS := "${platforms[@]}"
fi

if (( ${#libs[@]} )); then
write export LIBRARIES := "${libs[@]}"
fi

write "include $src/Makefile"
cp "$tmp" Makefile
4 changes: 2 additions & 2 deletions gamecube_rules → gamecube_rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ PORTLIBS := $(PORTLIBS_PATH)/gamecube $(PORTLIBS_PATH)/ppc

export PATH := $(PORTLIBS_PATH)/gamecube/bin:$(PORTLIBS_PATH)/ppc/bin:$(PATH)

export LIBOGC_INC := $(DEVKITPRO)/libogc2/include
export LIBOGC_LIB := $(DEVKITPRO)/libogc2/lib/cube
export LIBOGC_INC := @PREFIX@/@INCDIR@
export LIBOGC_LIB := @PREFIX@/@LIBDIR@/cube


MACHDEP = -DGEKKO -mogc -mcpu=750 -meabi -mhard-float
Expand Down
2 changes: 1 addition & 1 deletion libogc/console_font_8x16.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unsigned char console_font_8x16[] = {
unsigned char console_font_8x16[] __attribute__((weak)) = {

/* 0 0x00 '^@' */
0x00, /* 00000000 */
Expand Down
3 changes: 1 addition & 2 deletions libogc/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ static sys_resetinfo mem_resetinfo = {
127
};

static const char *__sys_versiondate;
static const char *__sys_versionbuild;

static __inline__ alarm_st* __lwp_syswd_open(syswd_t wd)
Expand Down Expand Up @@ -1034,7 +1033,7 @@ void* __SYS_GetIPCBufferHi(void)
#endif

void _V_EXPORTNAME(void)
{ __sys_versionbuild = _V_STRING; __sys_versiondate = _V_DATE_; }
{ __sys_versionbuild = _V_STRING; }

#if defined(HW_RVL)
void __SYS_DoPowerCB(void)
Expand Down
Loading