1 #---------------------------------------------------------------------------------
3 #---------------------------------------------------------------------------------
5 ifeq ($(strip $(DEVKITARM)),)
6 $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
9 include $(DEVKITARM)/ds_rules
11 #---------------------------------------------------------------------------------
12 # TARGET is the name of the output
13 # BUILD is the directory where object files & intermediate files will be placed
14 # SOURCES is a list of directories containing source code
15 # DATA is a list of directories containing data files
16 # INCLUDES is a list of directories containing header files
17 #---------------------------------------------------------------------------------
18 TARGET := $(shell basename $(CURDIR))
24 #---------------------------------------------------------------------------------
25 # options for code generation
26 #---------------------------------------------------------------------------------
27 ARCH := -mthumb -mthumb-interwork \
28 -D__NDS__ -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" \
29 -DVERSION=\"1.3\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1
31 CFLAGS := -g -Wall -O2\
32 -march=armv5te -mtune=arm946e-s \
33 -fomit-frame-pointer -ffast-math \
36 CFLAGS += $(INCLUDE) -DARM9
37 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
39 ASFLAGS := -g $(ARCH) -march=armv5te -mtune=arm946e-s
40 LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
42 # Set to 0 to use a framer buffer, or 1 to use the hardware
43 # renderer. Alas, both cannot be used at the same time for lack of
44 # display/texture memory.
47 ifeq ($(USE_HW_RENDERER),1)
48 CFLAGS += -DUSE_HW_RENDERER
52 #---------------------------------------------------------------------------------
53 # list of directories containing libraries, this must be the top level containing
55 #---------------------------------------------------------------------------------
56 LIBDIRS := $(LIBNDS) $(PORTLIBS)
58 #---------------------------------------------------------------------------------
59 # no real need to edit anything past this point unless you need to add additional
60 # rules for different file extensions
61 #---------------------------------------------------------------------------------
62 ifneq ($(BUILD),$(notdir $(CURDIR)))
63 #---------------------------------------------------------------------------------
65 export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
67 export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
68 $(foreach dir,$(DATA),$(CURDIR)/$(dir))
70 export DEPSDIR := $(CURDIR)/$(BUILD)
81 atomic/SDL_spinlock.arm.c \
83 audio/SDL_audiocvt.c \
84 audio/SDL_audiodev.c \
85 audio/SDL_audiotypecvt.c \
88 audio/nds/SDL_ndsaudio.c \
89 cpuinfo/SDL_cpuinfo.c \
91 events/SDL_keyboard.c \
95 events/SDL_windowevents.c \
96 events/nds/SDL_ndsgesture.c \
99 haptic/nds/SDL_syshaptic.c \
100 joystick/SDL_joystick.c \
101 joystick/nds/SDL_sysjoystick.c \
103 power/nds/SDL_syspower.c \
104 render/SDL_render.c \
105 render/SDL_yuv_sw.c \
106 render/nds/SDL_ndsrender.c \
107 render/software/SDL_blendfillrect.c \
108 render/software/SDL_blendline.c \
109 render/software/SDL_blendpoint.c \
110 render/software/SDL_drawline.c \
111 render/software/SDL_drawpoint.c \
112 render/software/SDL_render_sw.c \
113 stdlib/SDL_getenv.c \
115 stdlib/SDL_malloc.c \
117 stdlib/SDL_stdlib.c \
118 stdlib/SDL_string.c \
119 thread/SDL_thread.c \
120 thread/nds/SDL_syscond.c \
121 thread/nds/SDL_sysmutex.c \
122 thread/nds/SDL_syssem.c \
123 thread/nds/SDL_systhread.c \
125 timer/nds/SDL_systimer.c \
126 video/SDL_RLEaccel.c \
132 video/SDL_blit_auto.c \
133 video/SDL_blit_copy.c \
134 video/SDL_blit_slow.c \
136 video/SDL_clipboard.c \
137 video/SDL_fillrect.c \
140 video/SDL_stretch.c \
141 video/SDL_surface.c \
143 video/nds/SDL_ndsevents.c \
144 video/nds/SDL_ndsvideo.c \
145 video/nds/SDL_ndswindow.c
148 #CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
149 #SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
150 #BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
152 #---------------------------------------------------------------------------------
153 # use CXX for linking C++ projects, CC for standard C
154 #---------------------------------------------------------------------------------
155 ifeq ($(strip $(CPPFILES)),)
156 #---------------------------------------------------------------------------------
158 #---------------------------------------------------------------------------------
160 #---------------------------------------------------------------------------------
162 #---------------------------------------------------------------------------------
164 #---------------------------------------------------------------------------------
166 export OFILES := $(addsuffix .o,$(BINFILES)) \
167 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
169 export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
170 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
171 -I$(CURDIR)/$(BUILD) \
172 -I$(PORTLIBS)/include/SDL
174 .PHONY: $(BUILD) clean all
176 #---------------------------------------------------------------------------------
177 all: arm_only $(BUILD) install nds_test
180 @[ -d $@ ] || mkdir -p $@
183 @[ -d $@ ] || mkdir -p $@
184 @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.ds -s
187 @mkdir -p $(PORTLIBS)/include/SDL/
188 @rsync -a $(OUTPUT) $(PORTLIBS)/lib/
189 @rsync -a include/*.h $(PORTLIBS)/include/SDL/
192 $(MAKE) -C test/nds-test-progs -s
195 cd $(SOURCES); etags $(CFILES)
197 # This file must be compiled with the ARM instruction set, not
198 # thumb. Use devkitpro way of doing things.
199 arm_only: src/atomic/SDL_spinlock.arm.c
200 src/atomic/SDL_spinlock.arm.c: src/atomic/SDL_spinlock.c
203 #---------------------------------------------------------------------------------
206 @cd src; rm -fr $(OFILES) $(OFILES:.o=.d) lib
208 @make -C test/nds-test-progs -s clean
210 #---------------------------------------------------------------------------------
213 DEPENDS := $(OFILES:.o=.d)
215 #---------------------------------------------------------------------------------
217 #---------------------------------------------------------------------------------
218 $(OUTPUT) : $(OFILES)
220 #---------------------------------------------------------------------------------
222 #---------------------------------------------------------------------------------
229 #---------------------------------------------------------------------------------------
231 #---------------------------------------------------------------------------------------