1275793eaSopenharmony_ci#---------------------------------------------------------------------------------
2275793eaSopenharmony_ci.SUFFIXES:
3275793eaSopenharmony_ci#---------------------------------------------------------------------------------
4275793eaSopenharmony_ci
5275793eaSopenharmony_ciifeq ($(strip $(DEVKITARM)),)
6275793eaSopenharmony_ci$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
7275793eaSopenharmony_ciendif
8275793eaSopenharmony_ci
9275793eaSopenharmony_ciinclude $(DEVKITARM)/ds_rules
10275793eaSopenharmony_ci
11275793eaSopenharmony_ci#---------------------------------------------------------------------------------
12275793eaSopenharmony_ci# TARGET is the name of the output
13275793eaSopenharmony_ci# BUILD is the directory where object files & intermediate files will be placed
14275793eaSopenharmony_ci# SOURCES is a list of directories containing source code
15275793eaSopenharmony_ci# DATA is a list of directories containing data files
16275793eaSopenharmony_ci# INCLUDES is a list of directories containing header files
17275793eaSopenharmony_ci#---------------------------------------------------------------------------------
18275793eaSopenharmony_ciTARGET		:=	$(shell basename $(CURDIR))
19275793eaSopenharmony_ciBUILD		:=	build
20275793eaSopenharmony_ciSOURCES		:=	../../
21275793eaSopenharmony_ciDATA		:=	data
22275793eaSopenharmony_ciINCLUDES	:=	include
23275793eaSopenharmony_ci
24275793eaSopenharmony_ci#---------------------------------------------------------------------------------
25275793eaSopenharmony_ci# options for code generation
26275793eaSopenharmony_ci#---------------------------------------------------------------------------------
27275793eaSopenharmony_ciARCH	:=	-mthumb -mthumb-interwork
28275793eaSopenharmony_ci
29275793eaSopenharmony_ciCFLAGS	:=	-Wall -O2\
30275793eaSopenharmony_ci		-march=armv5te -mtune=arm946e-s \
31275793eaSopenharmony_ci		-fomit-frame-pointer -ffast-math \
32275793eaSopenharmony_ci		$(ARCH)
33275793eaSopenharmony_ci
34275793eaSopenharmony_ciCFLAGS	+=	$(INCLUDE) -DARM9
35275793eaSopenharmony_ciCXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions
36275793eaSopenharmony_ci
37275793eaSopenharmony_ciASFLAGS	:=	$(ARCH) -march=armv5te -mtune=arm946e-s
38275793eaSopenharmony_ciLDFLAGS	=	-specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
39275793eaSopenharmony_ci
40275793eaSopenharmony_ci#---------------------------------------------------------------------------------
41275793eaSopenharmony_ci# list of directories containing libraries, this must be the top level containing
42275793eaSopenharmony_ci# include and lib
43275793eaSopenharmony_ci#---------------------------------------------------------------------------------
44275793eaSopenharmony_ciLIBDIRS	:=	$(LIBNDS)
45275793eaSopenharmony_ci
46275793eaSopenharmony_ci#---------------------------------------------------------------------------------
47275793eaSopenharmony_ci# no real need to edit anything past this point unless you need to add additional
48275793eaSopenharmony_ci# rules for different file extensions
49275793eaSopenharmony_ci#---------------------------------------------------------------------------------
50275793eaSopenharmony_ciifneq ($(BUILD),$(notdir $(CURDIR)))
51275793eaSopenharmony_ci#---------------------------------------------------------------------------------
52275793eaSopenharmony_ci
53275793eaSopenharmony_ciexport OUTPUT	:=	$(CURDIR)/lib/libz.a
54275793eaSopenharmony_ci
55275793eaSopenharmony_ciexport VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
56275793eaSopenharmony_ci			$(foreach dir,$(DATA),$(CURDIR)/$(dir))
57275793eaSopenharmony_ci
58275793eaSopenharmony_ciexport DEPSDIR	:=	$(CURDIR)/$(BUILD)
59275793eaSopenharmony_ci
60275793eaSopenharmony_ciCFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
61275793eaSopenharmony_ciCPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
62275793eaSopenharmony_ciSFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
63275793eaSopenharmony_ciBINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
64275793eaSopenharmony_ci
65275793eaSopenharmony_ci#---------------------------------------------------------------------------------
66275793eaSopenharmony_ci# use CXX for linking C++ projects, CC for standard C
67275793eaSopenharmony_ci#---------------------------------------------------------------------------------
68275793eaSopenharmony_ciifeq ($(strip $(CPPFILES)),)
69275793eaSopenharmony_ci#---------------------------------------------------------------------------------
70275793eaSopenharmony_ci	export LD	:=	$(CC)
71275793eaSopenharmony_ci#---------------------------------------------------------------------------------
72275793eaSopenharmony_cielse
73275793eaSopenharmony_ci#---------------------------------------------------------------------------------
74275793eaSopenharmony_ci	export LD	:=	$(CXX)
75275793eaSopenharmony_ci#---------------------------------------------------------------------------------
76275793eaSopenharmony_ciendif
77275793eaSopenharmony_ci#---------------------------------------------------------------------------------
78275793eaSopenharmony_ci
79275793eaSopenharmony_ciexport OFILES	:=	$(addsuffix .o,$(BINFILES)) \
80275793eaSopenharmony_ci			$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
81275793eaSopenharmony_ci
82275793eaSopenharmony_ciexport INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
83275793eaSopenharmony_ci			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
84275793eaSopenharmony_ci			-I$(CURDIR)/$(BUILD)
85275793eaSopenharmony_ci
86275793eaSopenharmony_ci.PHONY: $(BUILD) clean all
87275793eaSopenharmony_ci
88275793eaSopenharmony_ci#---------------------------------------------------------------------------------
89275793eaSopenharmony_ciall: $(BUILD)
90275793eaSopenharmony_ci	@[ -d $@ ] || mkdir -p include
91275793eaSopenharmony_ci	@cp ../../*.h include
92275793eaSopenharmony_ci
93275793eaSopenharmony_cilib:
94275793eaSopenharmony_ci	@[ -d $@ ] || mkdir -p $@
95275793eaSopenharmony_ci	
96275793eaSopenharmony_ci$(BUILD): lib
97275793eaSopenharmony_ci	@[ -d $@ ] || mkdir -p $@
98275793eaSopenharmony_ci	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
99275793eaSopenharmony_ci
100275793eaSopenharmony_ci#---------------------------------------------------------------------------------
101275793eaSopenharmony_ciclean:
102275793eaSopenharmony_ci	@echo clean ...
103275793eaSopenharmony_ci	@rm -fr $(BUILD) lib
104275793eaSopenharmony_ci
105275793eaSopenharmony_ci#---------------------------------------------------------------------------------
106275793eaSopenharmony_cielse
107275793eaSopenharmony_ci
108275793eaSopenharmony_ciDEPENDS	:=	$(OFILES:.o=.d)
109275793eaSopenharmony_ci
110275793eaSopenharmony_ci#---------------------------------------------------------------------------------
111275793eaSopenharmony_ci# main targets
112275793eaSopenharmony_ci#---------------------------------------------------------------------------------
113275793eaSopenharmony_ci$(OUTPUT)	:	$(OFILES)
114275793eaSopenharmony_ci
115275793eaSopenharmony_ci#---------------------------------------------------------------------------------
116275793eaSopenharmony_ci%.bin.o	:	%.bin
117275793eaSopenharmony_ci#---------------------------------------------------------------------------------
118275793eaSopenharmony_ci	@echo $(notdir $<)
119275793eaSopenharmony_ci	@$(bin2o)
120275793eaSopenharmony_ci
121275793eaSopenharmony_ci
122275793eaSopenharmony_ci-include $(DEPENDS)
123275793eaSopenharmony_ci
124275793eaSopenharmony_ci#---------------------------------------------------------------------------------------
125275793eaSopenharmony_ciendif
126275793eaSopenharmony_ci#---------------------------------------------------------------------------------------
127