diff --git a/.gitignore b/.gitignore index 34861a2..0955c90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ /*.a /build +*.bz2 +release/ +lib/ diff --git a/.travis.yml b/.travis.yml index 62ef7f7..ff1f980 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ env: global: - DEVKITPRO=/opt/devkitpro - DEVKITPPC=/opt/devkitpro/devkitPPC - - PORTLIBREPOS=$HOME/portlibrepos cache: directories: diff --git a/Makefile b/Makefile index 75360c0..5b17ecf 100644 --- a/Makefile +++ b/Makefile @@ -1,58 +1,59 @@ -#--------------------------------------------------------------------------------- -# Clear the implicit built in rules -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- .SUFFIXES: -#--------------------------------------------------------------------------------- -ifeq ($(strip $(DEVKITPPC)),) -$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +#------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") endif -export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) -export PORTLIBS := $(DEVKITPRO)/portlibs/ppc +TOPDIR ?= $(CURDIR) -PREFIX := powerpc-eabi- +include $(DEVKITPRO)/wut/share/wut_rules -export AS := $(PREFIX)as -export CC := $(PREFIX)gcc -export CXX := $(PREFIX)g++ -export AR := $(PREFIX)ar -export OBJCOPY := $(PREFIX)objcopy +export VER_MAJOR := 1 +export VER_MINOR := 0 +export VER_PATCH := 0 -include $(DEVKITPPC)/base_rules +VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) -#--------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +# TARGET is the name of the output # BUILD is the directory where object files & intermediate files will be placed # SOURCES is a list of directories containing source code -# INCLUDES is a list of directories containing extra header files -#--------------------------------------------------------------------------------- +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#------------------------------------------------------------------------------- +TARGET := $(notdir $(CURDIR)) BUILD := build SOURCES := source -INCLUDES := iosuhax.h iosuhax_devoptab.h iosuhax_disc_interface.h -LIBTARGET := libiosuhax.a - -#--------------------------------------------------------------------------------- -# installation parameters -#--------------------------------------------------------------------------------- -LIBINSTALL := $(PORTLIBS)/lib -HDRINSTALL := $(PORTLIBS)/include +DATA := data +INCLUDES := source \ + include \ #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -O2 $(DEF_FLAGS) -Wall -Wno-unused $(MACHDEP) $(INCLUDE) -CXXFLAGS = $(CFLAGS) -ASFLAGS := -g +CFLAGS := -Wall -Werror -save-temps \ + -ffunction-sections -fdata-sections \ + $(MACHDEP) \ + $(BUILD_CFLAGS) -#--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project -#--------------------------------------------------------------------------------- -LIBS := +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ + +CXXFLAGS := $(CFLAGS) -std=gnu++17 + +ASFLAGS := $(MACHDEP) + +LDFLAGS = $(ARCH) -Wl,--gc-sections + + +LIBS := #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- -LIBDIRS := +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -61,49 +62,74 @@ LIBDIRS := ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- -export DEPSDIR := $(CURDIR)/$(BUILD) +export TOPDIR := $(CURDIR) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) - - -export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) -I$(LIBOGC_INC) \ - -I$(PORTLIBS)/include - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ - -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib - -.PHONY: $(BUILD) clean +DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- -$(BUILD): +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I. + +.PHONY: all dist-bin dist-src dist install clean + +#--------------------------------------------------------------------------------- +all: lib/libiosuhax.a + +dist-bin: all + @tar --exclude=*~ -cjf libiosuhax-$(VERSION).tar.bz2 include lib + +dist-src: + @tar --exclude=*~ -cjf libiosuhax-src-$(VERSION).tar.bz2 include source Makefile + +dist: dist-src dist-bin + +install: dist-bin + mkdir -p $(DESTDIR)$(DEVKITPRO)/wut + bzip2 -cd libiosuhax-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wut + +lib: @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +release: + @[ -d $@ ] || mkdir -p $@ + +lib/libiosuhax.a :$(SOURCES) $(INCLUDES) | lib release + @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DNDEBUG=1 -O2 -s" \ + DEPSDIR=$(CURDIR)/release \ + --no-print-directory -C release \ + -f $(CURDIR)/Makefile #--------------------------------------------------------------------------------- -all: $(LIBTARGET) - clean: @echo clean ... - @rm -fr $(BUILD) $(LIBTARGET) - -install: $(LIBTARGET) - @[ -d $(LIBINSTALL) ] || mkdir -p $(LIBINSTALL) - @[ -d $(HDRINSTALL) ] || mkdir -p $(HDRINSTALL) - cp $(foreach incl,$(INCLUDES),$(SOURCES)/$(incl)) $(HDRINSTALL) - cp $(LIBTARGET) $(LIBINSTALL) - -wut: - @[ -d $(BUILD) ] || mkdir -p $(BUILD) - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile DEF_FLAGS=-D__WUT__ + @rm -rf release lib #--------------------------------------------------------------------------------- else @@ -113,13 +139,16 @@ DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- -$(LIBTARGET): $(OFILES) - @rm -f "../$(LIBTARGET)" - @$(AR) rcs "../$(LIBTARGET)" $(OFILES) - @echo built $(notdir $@) +$(OUTPUT) : $(OFILES) + +$(OFILES_SRC) : $(HFILES) + +#--------------------------------------------------------------------------------- +%_bin.h %.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) -$(LIBDIR)/$(PLATFORM): - mkdir -p ../$(LIBDIR)/$(PLATFORM) -include $(DEPENDS) diff --git a/README.md b/README.md index d107037..1fc1235 100644 --- a/README.md +++ b/README.md @@ -1 +1,10 @@ -[![Build Status](https://travis-ci.org/dimok789/libiosuhax.svg)](https://travis-ci.org/dimok789/libiosuhax) \ No newline at end of file +[![Build Status](https://travis-ci.org/dimok789/libiosuhax.svg)](https://travis-ci.org/dimok789/libiosuhax) +# libiosuhax +A PPC library to access IOSUHAX from PPC and a devoptab for any device or path. +It's only compatible to RPX-Files. + +## Building +Make you to have [wut](https://github.com/devkitPro/wut/) installed and use the following command for build: +``` +make install +``` diff --git a/source/iosuhax.h b/include/iosuhax.h similarity index 100% rename from source/iosuhax.h rename to include/iosuhax.h diff --git a/source/iosuhax_devoptab.h b/include/iosuhax_devoptab.h similarity index 100% rename from source/iosuhax_devoptab.h rename to include/iosuhax_devoptab.h diff --git a/source/iosuhax_disc_interface.h b/include/iosuhax_disc_interface.h similarity index 100% rename from source/iosuhax_disc_interface.h rename to include/iosuhax_disc_interface.h diff --git a/source/os_functions.h b/source/os_functions.h index 9d34744..a9d9d00 100644 --- a/source/os_functions.h +++ b/source/os_functions.h @@ -7,21 +7,6 @@ extern "C" { #define OS_MUTEX_SIZE 44 -#ifndef __WUT__ -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Mutex functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (* OSInitMutex)(void* mutex); -extern void (* OSLockMutex)(void* mutex); -extern void (* OSUnlockMutex)(void* mutex); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! IOS function -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern int (*IOS_Ioctl)(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); -extern int (*IOS_Open)(char *path, unsigned int mode); -extern int (*IOS_Close)(int fd); -#else //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! Mutex functions //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -35,7 +20,6 @@ extern void OSUnlockMutex(void* mutex); extern int IOS_Ioctl(int fd, unsigned int request, void *input_buffer,unsigned int input_buffer_len, void *output_buffer, unsigned int output_buffer_len); extern int IOS_Open(char *path, unsigned int mode); extern int IOS_Close(int fd); -#endif // __WUT__ #ifdef __cplusplus }