1 | #--------------------------------------------------------------------------------- |
---|
2 | .SUFFIXES: |
---|
3 | #--------------------------------------------------------------------------------- |
---|
4 | ifeq ($(strip $(DEVKITARM)),) |
---|
5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM) |
---|
6 | endif |
---|
7 | |
---|
8 | include $(DEVKITARM)/ds_rules |
---|
9 | |
---|
10 | TOPDIR ?= $(CURDIR)/.. |
---|
11 | |
---|
12 | #--------------------------------------------------------------------------------- |
---|
13 | # BUILD is the directory where object files & intermediate files will be placed |
---|
14 | # SOURCES is a list of directories containing source code |
---|
15 | # INCLUDES is a list of directories containing extra header files |
---|
16 | # DATA is a list of directories containing binary files |
---|
17 | # all directories are relative to this makefile |
---|
18 | #--------------------------------------------------------------------------------- |
---|
19 | BUILD ?= release |
---|
20 | SOURCES := source ../common/source |
---|
21 | INCLUDES := include build ../common/source ../include |
---|
22 | DATA := |
---|
23 | |
---|
24 | #--------------------------------------------------------------------------------- |
---|
25 | # options for code generation |
---|
26 | #--------------------------------------------------------------------------------- |
---|
27 | ARCH := -mthumb-interwork |
---|
28 | |
---|
29 | CFLAGS := -g -Wall -O2\ |
---|
30 | -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ |
---|
31 | -ffast-math \ |
---|
32 | $(ARCH) |
---|
33 | |
---|
34 | CFLAGS += $(INCLUDE) -DARM7 |
---|
35 | CXXFLAGS := $(CFLAGS) |
---|
36 | |
---|
37 | |
---|
38 | ASFLAGS := -g $(ARCH) |
---|
39 | LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*).map |
---|
40 | |
---|
41 | |
---|
42 | ifneq ($(BUILD),debug) |
---|
43 | export ARM7BIN := $(TOPDIR)/lib/libdswifi7.a |
---|
44 | else |
---|
45 | export ARM7BIN := $(TOPDIR)/lib/libdswifi7d.a |
---|
46 | CFLAGS += -DSGIP_DEBUG |
---|
47 | endif |
---|
48 | |
---|
49 | |
---|
50 | LIBS := |
---|
51 | #-lnds7 |
---|
52 | |
---|
53 | #--------------------------------------------------------------------------------- |
---|
54 | # list of directories containing libraries, this must be the top level containing |
---|
55 | # include and lib |
---|
56 | #--------------------------------------------------------------------------------- |
---|
57 | LIBDIRS := $(LIBNDS) |
---|
58 | |
---|
59 | |
---|
60 | #--------------------------------------------------------------------------------- |
---|
61 | # no real need to edit anything past this point unless you need to add additional |
---|
62 | # rules for different file extensions |
---|
63 | #--------------------------------------------------------------------------------- |
---|
64 | ifneq ($(BUILD),$(notdir $(CURDIR))) |
---|
65 | #--------------------------------------------------------------------------------- |
---|
66 | |
---|
67 | export DEPSDIR := $(CURDIR)/$(BUILD) |
---|
68 | |
---|
69 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) |
---|
70 | |
---|
71 | export CC := $(PREFIX)gcc |
---|
72 | export CXX := $(PREFIX)g++ |
---|
73 | export AR := $(PREFIX)ar |
---|
74 | export OBJCOPY := $(PREFIX)objcopy |
---|
75 | |
---|
76 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) |
---|
77 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) |
---|
78 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) |
---|
79 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) |
---|
80 | |
---|
81 | export OFILES := $(addsuffix .o,$(BINFILES)) \ |
---|
82 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) |
---|
83 | |
---|
84 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ |
---|
85 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ |
---|
86 | -I$(CURDIR)/$(BUILD) |
---|
87 | |
---|
88 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) |
---|
89 | |
---|
90 | #--------------------------------------------------------------------------------- |
---|
91 | # use CXX for linking C++ projects, CC for standard C |
---|
92 | #--------------------------------------------------------------------------------- |
---|
93 | ifeq ($(strip $(CPPFILES)),) |
---|
94 | #--------------------------------------------------------------------------------- |
---|
95 | export LD := $(CC) |
---|
96 | #--------------------------------------------------------------------------------- |
---|
97 | else |
---|
98 | #--------------------------------------------------------------------------------- |
---|
99 | export LD := $(CXX) |
---|
100 | #--------------------------------------------------------------------------------- |
---|
101 | endif |
---|
102 | #--------------------------------------------------------------------------------- |
---|
103 | |
---|
104 | .PHONY: $(BUILD) clean |
---|
105 | |
---|
106 | #--------------------------------------------------------------------------------- |
---|
107 | $(BUILD): |
---|
108 | @[ -d $@ ] || mkdir -p $@ |
---|
109 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/makefile |
---|
110 | |
---|
111 | #--------------------------------------------------------------------------------- |
---|
112 | clean: |
---|
113 | @echo clean ... |
---|
114 | @rm -fr debug release |
---|
115 | @rm -f $(TOPDIR)/lib/libdswifi7* |
---|
116 | |
---|
117 | all: $(ARM7BIN) |
---|
118 | |
---|
119 | #--------------------------------------------------------------------------------- |
---|
120 | else |
---|
121 | |
---|
122 | DEPENDS := $(OFILES:.o=.d) |
---|
123 | |
---|
124 | #--------------------------------------------------------------------------------- |
---|
125 | # main targets |
---|
126 | #--------------------------------------------------------------------------------- |
---|
127 | $(ARM7BIN) : $(OFILES) |
---|
128 | @rm -f "$(ARM7BIN)" |
---|
129 | @$(AR) rcs "$(ARM7BIN)" $(OFILES) |
---|
130 | @echo built ... $(notdir $@) |
---|
131 | |
---|
132 | |
---|
133 | #--------------------------------------------------------------------------------- |
---|
134 | # you need a rule like this for each extension you use as binary data |
---|
135 | #--------------------------------------------------------------------------------- |
---|
136 | %.bin.o : %.bin |
---|
137 | #--------------------------------------------------------------------------------- |
---|
138 | @echo $(notdir $<) |
---|
139 | @$(bin2o) |
---|
140 | |
---|
141 | -include $(DEPENDS) |
---|
142 | |
---|
143 | #--------------------------------------------------------------------------------------- |
---|
144 | endif |
---|
145 | #--------------------------------------------------------------------------------------- |
---|