mirror of
https://github.com/devkitPro/buildscripts.git
synced 2026-04-30 18:17:35 -05:00
130 lines
4.8 KiB
Makefile
130 lines
4.8 KiB
Makefile
#---------------------------------------------------------------------------------
|
|
.SUFFIXES:
|
|
#---------------------------------------------------------------------------------
|
|
-include $(DEVKITARM)/ds_rules
|
|
#---------------------------------------------------------------------------------
|
|
# 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
|
|
#---------------------------------------------------------------------------------
|
|
BUILD := build
|
|
SOURCES := source
|
|
INCLUDES := include build
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# options for code generation
|
|
#---------------------------------------------------------------------------------
|
|
ARCH := -mthumb -mthumb-interwork
|
|
|
|
CFLAGS := -g -Wall -O2\
|
|
-mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\
|
|
-ffast-math \
|
|
$(ARCH)
|
|
|
|
CFLAGS += $(INCLUDE) -DARM7
|
|
|
|
ASFLAGS := -g $(ARCH)
|
|
LDFLAGS = -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# path to tools - this can be deleted if you set the path in windows
|
|
#---------------------------------------------------------------------------------
|
|
export PATH := $(DEVKITARM)/bin:$(PATH)
|
|
|
|
LIBS := -lnds7
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# list of directories containing libraries, this must be the top level containing
|
|
# include and lib
|
|
#---------------------------------------------------------------------------------
|
|
LIBDIRS := $(LIBNDS)
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# 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 DEPSDIR := $(CURDIR)/$(BUILD)
|
|
|
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
|
|
|
|
export CC := $(PREFIX)gcc
|
|
export CXX := $(PREFIX)g++
|
|
export AR := $(PREFIX)ar
|
|
export OBJCOPY := $(PREFIX)objcopy
|
|
|
|
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,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
-I$(CURDIR)/$(BUILD)
|
|
|
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# use CXX for linking C++ projects, CC for standard C
|
|
#---------------------------------------------------------------------------------
|
|
ifeq ($(strip $(CPPFILES)),)
|
|
#---------------------------------------------------------------------------------
|
|
export LD := $(CC)
|
|
#---------------------------------------------------------------------------------
|
|
else
|
|
#---------------------------------------------------------------------------------
|
|
export LD := $(CXX)
|
|
#---------------------------------------------------------------------------------
|
|
endif
|
|
#---------------------------------------------------------------------------------
|
|
|
|
.PHONY: $(BUILD) clean
|
|
|
|
#---------------------------------------------------------------------------------
|
|
$(BUILD):
|
|
@[ -d $@ ] || mkdir -p $@
|
|
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
|
|
#---------------------------------------------------------------------------------
|
|
clean:
|
|
@echo clean ...
|
|
@rm -fr $(BUILD) *.elf
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
else
|
|
|
|
DEPENDS := $(OFILES:.o=.d)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# main targets
|
|
#---------------------------------------------------------------------------------
|
|
|
|
$(OUTPUT).arm7 : $(OUTPUT).elf
|
|
|
|
$(OUTPUT).elf : $(OFILES)
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.arm7: %.elf
|
|
@echo built ... $(notdir $@)
|
|
@$(OBJCOPY) -O binary $< $@
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%.elf:
|
|
@echo linking binary
|
|
@$(LD) $(LDFLAGS) -specs=ds_arm7.specs $(OFILES) $(LIBPATHS) $(LIBS) -o $@
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
endif
|
|
#---------------------------------------------------------------------------------------
|