From 7efe349072d603b9639913a9720197aa6eab0e33 Mon Sep 17 00:00:00 2001 From: novenary Date: Wed, 29 Nov 2023 18:46:32 +0200 Subject: [PATCH] Fix out-of-tree builds --- .../continuous-integration-workflow.yml | 4 +- .gitignore | 1 + Doxyfile | 4 +- Makefile | 59 +++++++++++-------- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 8f8e9b04..2e247aed 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -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 diff --git a/.gitignore b/.gitignore index d1a46b25..19afba3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build cube deps include diff --git a/Doxyfile b/Doxyfile index 92e028c1..aa538403 100644 --- a/Doxyfile +++ b/Doxyfile @@ -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 @@ -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 diff --git a/Makefile b/Makefile index 56ade00f..13ed84c0 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif +CURFILE := $(abspath $(lastword $(MAKEFILE_LIST))) + export PATH := $(DEVKITPPC)/bin:$(PATH) export LIBOGC_MAJOR := 2 @@ -26,7 +28,8 @@ 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 @@ -39,10 +42,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 @@ -74,10 +77,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 @@ -189,7 +194,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 @@ -198,12 +203,13 @@ 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 >> $@ @@ -265,7 +271,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 @@ -276,16 +282,17 @@ 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 + @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: wii cube install-headers @@ -293,8 +300,8 @@ 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 -frv $(BASEDIR)/libogc_license.txt $(DESTDIR)$(DEVKITPRO)/libogc2 + @cp -frv $(BASEDIR)/{gamecube_rules,wii_rules} $(DESTDIR)$(DEVKITPRO)/libogc2 #--------------------------------------------------------------------------------- uninstall: @@ -304,9 +311,10 @@ uninstall: #--------------------------------------------------------------------------------- dist: wii cube 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 -C $(BASEDIR) --exclude-vcs --exclude-vcs-ignores --exclude .github \ + -cvjf $(BUILDDIR)/libogc2-src-$(VERSTRING).tar.bz2 . + + @cp $(BASEDIR)/{libogc_license.txt,gamecube_rules,wii_rules} . @tar -cvjf libogc2-$(VERSTRING).tar.bz2 include lib libogc_license.txt gamecube_rules wii_rules @@ -327,6 +335,7 @@ libs: $(LIBRARIES) clean: #--------------------------------------------------------------------------------- rm -fr wii cube + rm -fr gc/ogc/libversion.h rm -fr $(DEPS) rm -fr $(LIBS) rm -fr $(INCDIR) @@ -335,6 +344,6 @@ clean: #--------------------------------------------------------------------------------- docs: install-headers #--------------------------------------------------------------------------------- - doxygen Doxyfile + @cd $(BASEDIR); doxygen Doxyfile -include $(DEPSDIR)/*.d