libfat/nds/Makefile

132 lines
4.4 KiB
Makefile
Raw 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/disc_io
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
CFLAGS := -g -Wall -O2\
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)
all: $(ARM9BIN)
dist-bin:
@tar --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(DATESTRING)/libfat-nds-$(DATESTRING).tar.bz2 include lib
2006-07-14 05:00:30 +02:00
install:
cp lib/libfat.a $(DEVKITPRO)/libnds/lib
cp include/fat.h $(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
#---------------------------------------------------------------------------------------