Skip to content

Commit

Permalink
Support custom prefix, incdir and libdir
Browse files Browse the repository at this point in the history
  • Loading branch information
9ary committed Nov 29, 2023
1 parent 7e57e51 commit dc27c7f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include
lib
wii
gc/ogc/libversion.h
*_rules
*.bz2
docs
warn.log
42 changes: 32 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
.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")
Expand Down Expand Up @@ -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
#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -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)),)
Expand All @@ -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)
Expand Down
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
4 changes: 2 additions & 2 deletions wii_rules → wii_rules.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dc27c7f

Please sign in to comment.