libfat/nds/Makefile

137 lines
4.7 KiB
Makefile
Raw Permalink Normal View History

2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
endif
include $(DEVKITARM)/ds_rules
#---------------------------------------------------------------------------------
# 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 binary files
# LIB is where the built library will be placed
# all directories are relative to this makefile
#---------------------------------------------------------------------------------
BUILD ?= release
SOURCES := ../source source
2006-07-14 04:42:37 +02:00
INCLUDES := ../include
DATA :=
2006-07-14 05:00:30 +02:00
LIB := $(TOPDIR)/nds/lib
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork
2017-01-10 01:06:20 +01:00
CFLAGS := -g -Wall -O2 \
-ffunction-sections -fdata-sections \
2006-07-14 05:00:30 +02:00
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
-ffast-math \
$(ARCH)
2006-07-14 04:42:37 +02:00
CFLAGS += $(INCLUDE) -DARM9 -DNDS
CXXFLAGS := $(CFLAGS)
ASFLAGS := -g $(ARCH)
ifneq ($(BUILD),debug)
export ARM9BIN := $(LIB)/libfat.a
else
export ARM9BIN := $(LIB)/libfatd.a
CFLAGS += -DFAT_DEBUG
endif
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
2006-07-14 05:00:30 +02:00
LIBS :=
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS)
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
# 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 TOPDIR ?= $(CURDIR)/..
2006-07-14 04:42:37 +02:00
export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
2006-07-14 05:00:30 +02:00
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
2006-07-14 04:42:37 +02:00
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
export OFILES := $(addsuffix .o,$(BINFILES)) \
2006-07-14 05:00:30 +02:00
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
2006-07-14 04:42:37 +02:00
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
2006-07-14 05:00:30 +02:00
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
2006-07-14 04:42:37 +02:00
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
.PHONY: $(BUILD) clean
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr debug release $(LIB) include
2006-07-14 04:42:37 +02:00
all: $(ARM9BIN)
dist-bin:
2012-05-09 17:42:33 +02:00
@mkdir -p include
@cp $(TOPDIR)/include/fat.h $(TOPDIR)/include/libfatversion.h include
2009-05-01 02:36:01 +02:00
@tar --exclude=.svn --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(VERSTRING)/libfat-nds-$(VERSTRING).tar.bz2 include lib
2006-07-14 05:00:30 +02:00
install:
2018-05-14 14:19:01 +02:00
@mkdir -p $(DESTDIR)$(DEVKITPRO)/libnds/lib
@mkdir -p $(DESTDIR)$(DEVKITPRO)/libnds/include
@cp -v lib/libfat.a $(DESTDIR)$(DEVKITPRO)/libnds/lib
@cp -v $(TOPDIR)/include/fat.h $(TOPDIR)/include/libfatversion.h $(DESTDIR)$(DEVKITPRO)/libnds/include
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
else
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
DEPENDS := $(OFILES:.o=.d)
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(ARM9BIN) : $(OFILES) $(LIB)
@rm -f "$(ARM9BIN)"
@$(AR) rcs "$(ARM9BIN)" $(OFILES)
@echo built ... $(notdir $@)
$(LIB):
mkdir $(LIB)
2006-07-14 04:42:37 +02:00
-include $(DEPENDS)
2006-07-14 05:00:30 +02:00
2006-07-14 04:42:37 +02:00
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------