diff --git a/.gitignore b/.gitignore index 19afba3d..68c70412 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ include lib wii gc/ogc/libversion.h +*_rules *.bz2 docs warn.log diff --git a/Makefile b/Makefile index 99c436cb..ee01ef39 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,16 @@ .SUFFIXES: #--------------------------------------------------------------------------------- +ifeq ($(strip $(INSTALL_PREFIX)),) ifeq ($(strip $(DEVKITPRO)),) $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=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=devkitPPC") @@ -226,6 +233,16 @@ gc/ogc/libversion.h : $(CURFILE) @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 #--------------------------------------------------------------------------------- @@ -297,27 +314,31 @@ install-headers: gc/ogc/libversion.h @cp $(BASEDIR)/gc/wiikeyboard/*.h $(INCDIR)/wiikeyboard #--------------------------------------------------------------------------------- -install: $(PLATFORMS) install-headers +install: $(PLATFORMS) $(RULES) install-headers #--------------------------------------------------------------------------------- - @mkdir -p $(DESTDIR)$(DEVKITPRO)/libogc2 - @cp -frv include $(DESTDIR)$(DEVKITPRO)/libogc2 - @cp -frv lib $(DESTDIR)$(DEVKITPRO)/libogc2 - @cp -frv $(BASEDIR)/libogc_license.txt $(DESTDIR)$(DEVKITPRO)/libogc2 - @cp -frv $(BASEDIR)/gamecube_rules $(BASEDIR)/wii_rules $(DESTDIR)$(DEVKITPRO)/libogc2 + @$(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: $(PLATFORMS) install-headers +dist: $(PLATFORMS) $(RULES) install-headers #--------------------------------------------------------------------------------- @tar -C $(BASEDIR) --exclude-vcs --exclude-vcs-ignores --exclude .github \ -cvjf $(BUILDDIR)/libogc2-src-$(VERSTRING).tar.bz2 . - @cp $(BASEDIR)/libogc_license.txt $(BASEDIR)/gamecube_rules $(BASEDIR)/wii_rules . - @tar -cvjf libogc2-$(VERSTRING).tar.bz2 include lib libogc_license.txt gamecube_rules wii_rules + @cp $(BASEDIR)/libogc_license.txt . + @tar -cvjf libogc2-$(VERSTRING).tar.bz2 include lib libogc_license.txt $(RULES) ifeq ($(strip $(LIBRARIES)),) @@ -340,6 +361,7 @@ clean: #--------------------------------------------------------------------------------- rm -fr wii cube rm -fr gc/ogc/libversion.h + rm -fr $(RULES) rm -fr $(DEPS) rm -fr $(LIBS) rm -fr $(INCDIR) diff --git a/gamecube_rules b/gamecube_rules.in similarity index 89% rename from gamecube_rules rename to gamecube_rules.in index de42216b..0cc754b6 100644 --- a/gamecube_rules +++ b/gamecube_rules.in @@ -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 diff --git a/wii_rules b/wii_rules.in similarity index 89% rename from wii_rules rename to wii_rules.in index 4c979ed9..8a8b3f5f 100644 --- a/wii_rules +++ b/wii_rules.in @@ -8,8 +8,8 @@ PORTLIBS := $(PORTLIBS_PATH)/wii $(PORTLIBS_PATH)/ppc export PATH := $(PORTLIBS_PATH)/wii/bin:$(PORTLIBS_PATH)/ppc/bin:$(PATH) -export LIBOGC_INC := $(DEVKITPRO)/libogc2/include -export LIBOGC_LIB := $(DEVKITPRO)/libogc2/lib/wii +export LIBOGC_INC := @PREFIX@/@INCDIR@ +export LIBOGC_LIB := @PREFIX@/@LIBDIR@/wii MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float