Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix multiple definition error, update makefile #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 122 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,127 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITXENON)),)
$(error "Please set DEVKITXENON in your environment. export DEVKITXENON=<path to>devkitPPC")
endif

default: xenon
include $(DEVKITXENON)/rules

all: release
#---------------------------------------------------------------------------------
# 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
#---------------------------------------------------------------------------------
TARGET := libext2fs
BUILD := build
SOURCES := source
DATA := data
INCLUDES :=

xenon:
$(MAKE) -C source PLATFORM=xenon BUILD=xenon_debug
clean:
$(MAKE) -C source clean
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

install: xenon
$(MAKE) -C source install
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -DXENON -DWORDS_BIGENDIAN -U__linux__ -DNO_INLINE_FUNCS
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,--gc-sections -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS :=

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT := $(CURDIR)/$(TARGET)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR := $(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif

export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBXENON_INC)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBXENON_LIB)

export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean


#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).elf32

install: $(OUTPUT).a
mkdir -p $(DEVKITXENON)/usr/include/libext2
cp include/ext2.h $(DEVKITXENON)/usr/include/libext2
cp libext2fs.a $(DEVKITXENON)/usr/lib/libext2fs.a

#---------------------------------------------------------------------------------
else

DEPENDS := $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).a: $(OFILES)


-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
110 changes: 0 additions & 110 deletions source/Makefile

This file was deleted.

28 changes: 5 additions & 23 deletions source/mem_allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,10 @@

#include <malloc.h>

extern __inline__ void* mem_alloc (size_t size) {
return malloc(size);
}

extern __inline__ void* mem_calloc (size_t count, size_t size) {
return calloc(count, size);
}

extern __inline__ void* mem_realloc (void *p, size_t size) {
return realloc(p, size);
}

extern __inline__ void* mem_align (size_t a, size_t size) {
#ifdef __wii__
return memalign(a, size);
#else
return malloc(size);
#endif
}

extern __inline__ void mem_free (void* mem) {
free(mem);
}
#define mem_alloc(size) malloc(size)
#define mem_calloc(count, size) calloc(count, size)
#define mem_realloc(p, size) realloc(p, size)
#define mem_align(a,size) memalign(a, size)
#define mem_free(mem) free(mem)

#endif /* _MEM_ALLOCATE_H */