Adopt makefile from wut libraries. Now only compatible to WUT projects.

This commit is contained in:
orboditilt 2019-08-14 22:15:37 +02:00
parent f4ee7165b2
commit cf4f2ab607
8 changed files with 112 additions and 88 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
/*.a
/build
*.bz2
release/
lib/

View File

@ -8,7 +8,6 @@ env:
global:
- DEVKITPRO=/opt/devkitpro
- DEVKITPPC=/opt/devkitpro/devkitPPC
- PORTLIBREPOS=$HOME/portlibrepos
cache:
directories:

169
Makefile
View File

@ -1,58 +1,59 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
#-------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/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)

View File

@ -1 +1,10 @@
[![Build Status](https://travis-ci.org/dimok789/libiosuhax.svg)](https://travis-ci.org/dimok789/libiosuhax)
[![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
```

View File

@ -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
}