Makefile.ds
changeset 5423 b69fa50e80d7
parent 5310 a9945ce48999
child 5428 cff5d3cd5777
     1.1 --- a/Makefile.ds	Sat Mar 05 10:03:57 2011 -0800
     1.2 +++ b/Makefile.ds	Sun Mar 06 21:12:19 2011 -0800
     1.3 @@ -1,140 +1,236 @@
     1.4 -
     1.5 -#LibSDL 1.3 porting and enhancements by Darren Alton (lifning)
     1.6 -#LibSDL 1.2.9 DS porting by Troy Davis(GPF)
     1.7 +#---------------------------------------------------------------------------------
     1.8 +.SUFFIXES:
     1.9 +#---------------------------------------------------------------------------------
    1.10  
    1.11 -ifeq ($(strip $(DEVKITPRO)),)
    1.12 -$(error "Please set DEVKITPRO in your environment (available from http://www.devkitpro.org). export DEVKITPRO=<path to>devkitPro")
    1.13 -endif
    1.14  ifeq ($(strip $(DEVKITARM)),)
    1.15 -DEVKITARM = $(DEVKITPRO)/devkitARM
    1.16 +$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
    1.17  endif
    1.18 -PATH := $(PATH):$(DEVKITARM)/bin
    1.19 +
    1.20 +include $(DEVKITARM)/ds_rules
    1.21  
    1.22 -CC = arm-eabi-gcc
    1.23 -AR = arm-eabi-ar
    1.24 -RANLIB = arm-eabi-ranlib
    1.25 +#---------------------------------------------------------------------------------
    1.26 +# TARGET is the name of the output
    1.27 +# BUILD is the directory where object files & intermediate files will be placed
    1.28 +# SOURCES is a list of directories containing source code
    1.29 +# DATA is a list of directories containing data files
    1.30 +# INCLUDES is a list of directories containing header files
    1.31 +#---------------------------------------------------------------------------------
    1.32 +TARGET		:=	$(shell basename $(CURDIR))
    1.33 +BUILD		:=	src
    1.34 +SOURCES		:=	source
    1.35 +DATA		:=	data
    1.36 +INCLUDES	:=	include
    1.37 +
    1.38 +#---------------------------------------------------------------------------------
    1.39 +# options for code generation
    1.40 +#---------------------------------------------------------------------------------
    1.41 +ARCH	:=	-mthumb -mthumb-interwork \
    1.42 +		-D__NDS__ -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" \
    1.43 +		 -DVERSION=\"1.3\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1  
    1.44 +
    1.45 +CFLAGS	:=	-g -Wall -O2\
    1.46 +		-march=armv5te -mtune=arm946e-s \
    1.47 +		-fomit-frame-pointer -ffast-math \
    1.48 +		$(ARCH)
    1.49  
    1.50 -#ifdef GL
    1.51 -#DEFS += -DSDL_VIDEO_OPENGL=1
    1.52 -#TARGET = libSDL_gl.a
    1.53 -#else
    1.54 -TARGET = libSDL.a
    1.55 -#endif
    1.56 +CFLAGS	+=	$(INCLUDE) -DARM9
    1.57 +CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions
    1.58 +
    1.59 +ASFLAGS	:=	-g $(ARCH) -march=armv5te -mtune=arm946e-s
    1.60 +LDFLAGS	=	-specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
    1.61 +
    1.62 +# Set to 0 to use a framer buffer, or 1 to use the hardware
    1.63 +# renderer. Alas, both cannot be used at the same time for lack of
    1.64 +# display/texture memory.
    1.65 +USE_HW_RENDERER := 1
    1.66 +
    1.67 +ifeq ($(USE_HW_RENDERER),1)
    1.68 +CFLAGS += -DUSE_HW_RENDERER
    1.69 +else
    1.70 +endif
    1.71  
    1.72 -#CFLAGS=$(DEFS) -Iinclude
    1.73 -CFLAGS	=	-mthumb -mthumb-interwork \
    1.74 -		-march=armv5te -mtune=arm946e-s \
    1.75 -		-O2 -Wall -Wwrite-strings -Wpointer-arith  \
    1.76 -		-DARM9 -D__NDS__ -I$(DEVKITPRO)/libnds/include -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" -DVERSION=\"1.3\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -Iinclude
    1.77 +#---------------------------------------------------------------------------------
    1.78 +# list of directories containing libraries, this must be the top level containing
    1.79 +# include and lib
    1.80 +#---------------------------------------------------------------------------------
    1.81 +LIBDIRS	:=	$(LIBNDS)
    1.82  
    1.83 -#src/audio/disk/SDL_diskaudio.c \
    1.84 -#src/audio/dummy/SDL_dummyaudio.c \
    1.85 +#---------------------------------------------------------------------------------
    1.86 +# no real need to edit anything past this point unless you need to add additional
    1.87 +# rules for different file extensions
    1.88 +#---------------------------------------------------------------------------------
    1.89 +ifneq ($(BUILD),$(notdir $(CURDIR)))
    1.90 +#---------------------------------------------------------------------------------
    1.91 +
    1.92 +export OUTPUT	:=	$(CURDIR)/lib/lib$(TARGET).a
    1.93 +
    1.94 +export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
    1.95 +			$(foreach dir,$(DATA),$(CURDIR)/$(dir))
    1.96 +
    1.97 +export DEPSDIR	:=	$(CURDIR)/$(BUILD)
    1.98  
    1.99 -SRCS = \
   1.100 -src/SDL.c \
   1.101 -src/SDL_assert.c \
   1.102 -src/SDL_compat.c \
   1.103 -src/SDL_error.c \
   1.104 -src/SDL_fatal.c \
   1.105 -src/SDL_hints.c \
   1.106 -src/SDL_log.c \
   1.107 -src/atomic/SDL_atomic.c \
   1.108 -src/atomic/SDL_spinlock.c \
   1.109 -src/audio/SDL_audio.c \
   1.110 -src/audio/SDL_audiocvt.c \
   1.111 -src/audio/SDL_audiodev.c \
   1.112 -src/audio/SDL_audiotypecvt.c \
   1.113 -src/audio/SDL_mixer.c \
   1.114 -src/audio/SDL_mixer_MMX.c \
   1.115 -src/audio/SDL_mixer_MMX_VC.c \
   1.116 -src/audio/SDL_mixer_m68k.c \
   1.117 -src/audio/SDL_wave.c \
   1.118 -src/audio/nds/SDL_ndsaudio.c \
   1.119 -src/cpuinfo/SDL_cpuinfo.c \
   1.120 -src/events/SDL_events.c \
   1.121 -src/events/SDL_keyboard.c \
   1.122 -src/events/SDL_mouse.c \
   1.123 -src/events/SDL_quit.c \
   1.124 -src/events/SDL_touch.c \
   1.125 -src/events/SDL_windowevents.c \
   1.126 -src/events/nds/SDL_ndsgesture.c \
   1.127 -src/file/SDL_rwops.c \
   1.128 -src/haptic/SDL_haptic.c \
   1.129 -src/haptic/nds/SDL_syshaptic.c \
   1.130 -src/joystick/SDL_joystick.c \
   1.131 -src/joystick/nds/SDL_sysjoystick.c \
   1.132 -src/power/SDL_power.c \
   1.133 -src/power/nds/SDL_syspower.c \
   1.134 -src/render/SDL_render.c \
   1.135 -src/render/SDL_yuv_sw.c \
   1.136 -src/render/software/SDL_render_sw.c \
   1.137 -src/render/software/SDL_blendpoint.c \
   1.138 -src/render/software/SDL_drawline.c \
   1.139 -src/render/software/SDL_blendline.c \
   1.140 -src/render/software/SDL_blendfillrect.c \
   1.141 -src/render/software/SDL_drawpoint.c \
   1.142 -src/stdlib/SDL_getenv.c \
   1.143 -src/stdlib/SDL_iconv.c \
   1.144 -src/stdlib/SDL_malloc.c \
   1.145 -src/stdlib/SDL_qsort.c \
   1.146 -src/stdlib/SDL_stdlib.c \
   1.147 -src/stdlib/SDL_string.c \
   1.148 -src/thread/SDL_thread.c \
   1.149 -src/thread/nds/SDL_syscond.c \
   1.150 -src/thread/nds/SDL_sysmutex.c \
   1.151 -src/thread/nds/SDL_syssem.c \
   1.152 -src/thread/nds/SDL_systhread.c \
   1.153 -src/timer/SDL_timer.c \
   1.154 -src/timer/nds/SDL_systimer.c \
   1.155 -src/video/SDL_RLEaccel.c \
   1.156 -src/video/SDL_blit.c \
   1.157 -src/video/SDL_blit_0.c \
   1.158 -src/video/SDL_blit_1.c \
   1.159 -src/video/SDL_blit_A.c \
   1.160 -src/video/SDL_blit_N.c \
   1.161 -src/video/SDL_blit_auto.c \
   1.162 -src/video/SDL_blit_copy.c \
   1.163 -src/video/SDL_blit_slow.c \
   1.164 -src/video/SDL_bmp.c \
   1.165 -src/video/SDL_fillrect.c \
   1.166 -src/video/SDL_pixels.c \
   1.167 -src/video/SDL_rect.c \
   1.168 -src/video/SDL_stretch.c \
   1.169 -src/video/SDL_surface.c \
   1.170 -src/video/SDL_video.c \
   1.171 -src/video/dummy/SDL_nullevents.c \
   1.172 -src/video/dummy/SDL_nullvideo.c \
   1.173 -src/video/nds/SDL_ndsevents.c \
   1.174 -src/video/nds/SDL_ndsrender.c \
   1.175 -src/video/nds/SDL_ndsvideo.c \
   1.176 -
   1.177 -OBJS = $(SRCS:.c=.o)
   1.178 -
   1.179 -TEST = \
   1.180 -test/nds-test-progs/general/general.nds \
   1.181 -test/nds-test-progs/sprite/sprite.nds \
   1.182 -test/nds-test-progs/sprite2/sprite2.nds \
   1.183 +CFILES		:=	\
   1.184 +			SDL.c \
   1.185 +			SDL_assert.c \
   1.186 +			SDL_compat.c \
   1.187 +			SDL_error.c \
   1.188 +			SDL_fatal.c \
   1.189 +			SDL_hints.c \
   1.190 +			SDL_log.c \
   1.191 +			atomic/SDL_atomic.c \
   1.192 +			atomic/SDL_spinlock.arm.c \
   1.193 +			audio/SDL_audio.c \
   1.194 +			audio/SDL_audiocvt.c \
   1.195 +			audio/SDL_audiodev.c \
   1.196 +			audio/SDL_audiotypecvt.c \
   1.197 +			audio/SDL_mixer.c \
   1.198 +			audio/SDL_mixer_MMX.c \
   1.199 +			audio/SDL_mixer_MMX_VC.c \
   1.200 +			audio/SDL_mixer_m68k.c \
   1.201 +			audio/SDL_wave.c \
   1.202 +			audio/nds/SDL_ndsaudio.c \
   1.203 +			cpuinfo/SDL_cpuinfo.c \
   1.204 +			events/SDL_events.c \
   1.205 +			events/SDL_keyboard.c \
   1.206 +			events/SDL_mouse.c \
   1.207 +			events/SDL_quit.c \
   1.208 +			events/SDL_touch.c \
   1.209 +			events/SDL_windowevents.c \
   1.210 +			events/nds/SDL_ndsgesture.c \
   1.211 +			file/SDL_rwops.c \
   1.212 +			haptic/SDL_haptic.c \
   1.213 +			haptic/nds/SDL_syshaptic.c \
   1.214 +			joystick/SDL_joystick.c \
   1.215 +			joystick/nds/SDL_sysjoystick.c \
   1.216 +			power/SDL_power.c \
   1.217 +			power/nds/SDL_syspower.c \
   1.218 +			render/SDL_render.c \
   1.219 +			render/SDL_yuv_sw.c \
   1.220 +			render/software/SDL_blendfillrect.c \
   1.221 +			render/software/SDL_blendline.c \
   1.222 +			render/software/SDL_blendpoint.c \
   1.223 +			render/software/SDL_drawline.c \
   1.224 +			render/software/SDL_drawpoint.c \
   1.225 +			render/software/SDL_render_sw.c \
   1.226 +			stdlib/SDL_getenv.c \
   1.227 +			stdlib/SDL_iconv.c \
   1.228 +			stdlib/SDL_malloc.c \
   1.229 +			stdlib/SDL_qsort.c \
   1.230 +			stdlib/SDL_stdlib.c \
   1.231 +			stdlib/SDL_string.c \
   1.232 +			thread/SDL_thread.c \
   1.233 +			thread/nds/SDL_syscond.c \
   1.234 +			thread/nds/SDL_sysmutex.c \
   1.235 +			thread/nds/SDL_syssem.c \
   1.236 +			thread/nds/SDL_systhread.c \
   1.237 +			timer/SDL_timer.c \
   1.238 +			timer/nds/SDL_systimer.c \
   1.239 +			video/SDL_RLEaccel.c \
   1.240 +			video/SDL_blit.c \
   1.241 +			video/SDL_blit_0.c \
   1.242 +			video/SDL_blit_1.c \
   1.243 +			video/SDL_blit_A.c \
   1.244 +			video/SDL_blit_N.c \
   1.245 +			video/SDL_blit_auto.c \
   1.246 +			video/SDL_blit_copy.c \
   1.247 +			video/SDL_blit_slow.c \
   1.248 +			video/SDL_bmp.c \
   1.249 +			video/SDL_clipboard.c \
   1.250 +			video/SDL_fillrect.c \
   1.251 +			video/SDL_pixels.c \
   1.252 +			video/SDL_rect.c \
   1.253 +			video/SDL_stretch.c \
   1.254 +			video/SDL_surface.c \
   1.255 +			video/SDL_video.c \
   1.256 +			video/nds/SDL_ndsevents.c \
   1.257 +			video/nds/SDL_ndsvideo.c
   1.258  
   1.259  
   1.260 -all: $(TARGET) install nds_test
   1.261 +ifeq ($(USE_HW_RENDERER),1)
   1.262 +# Ideally we should be able to not include the SW renderer at set
   1.263 +# SDL_NO_COMPAT. However that breaks the build.
   1.264 +CFILES +=	render/nds/SDL_ndsrender.c
   1.265 +else
   1.266 +endif
   1.267  
   1.268 -# That file must be compiled in arm mode, not thumb mode.
   1.269 -src/atomic/SDL_spinlock.o: src/atomic/SDL_spinlock.c
   1.270 -	$(CC) $(CFLAGS) -mno-thumb -o $@ -c $^
   1.271 +#CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
   1.272 +#SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
   1.273 +#BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
   1.274  
   1.275 -$(TARGET): $(OBJS)
   1.276 -	$(AR) rc $(TARGET) $(OBJS)
   1.277 -	-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
   1.278 +#---------------------------------------------------------------------------------
   1.279 +# use CXX for linking C++ projects, CC for standard C
   1.280 +#---------------------------------------------------------------------------------
   1.281 +ifeq ($(strip $(CPPFILES)),)
   1.282 +#---------------------------------------------------------------------------------
   1.283 +	export LD	:=	$(CC)
   1.284 +#---------------------------------------------------------------------------------
   1.285 +else
   1.286 +#---------------------------------------------------------------------------------
   1.287 +	export LD	:=	$(CXX)
   1.288 +#---------------------------------------------------------------------------------
   1.289 +endif
   1.290 +#---------------------------------------------------------------------------------
   1.291 +
   1.292 +export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
   1.293 +			$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
   1.294  
   1.295 -install: $(TARGET)
   1.296 -	@cp libSDL.a $(DEVKITPRO)/libnds/lib/
   1.297 +export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
   1.298 +			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
   1.299 +			-I$(CURDIR)/$(BUILD)
   1.300 +
   1.301 +.PHONY: $(BUILD) clean all
   1.302 +
   1.303 +#---------------------------------------------------------------------------------
   1.304 +all: arm_only $(BUILD) install nds_test
   1.305 +
   1.306 +lib:
   1.307 +	@[ -d $@ ] || mkdir -p $@
   1.308 +
   1.309 +$(BUILD): lib
   1.310 +	@[ -d $@ ] || mkdir -p $@
   1.311 +	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.ds -s
   1.312 +
   1.313 +install: $(BUILD)
   1.314 +	@cp $(OUTPUT) $(DEVKITPRO)/libnds/lib/
   1.315  	@mkdir -p $(DEVKITPRO)/libnds/include/SDL/
   1.316  	@cp include/*.h $(DEVKITPRO)/libnds/include/SDL/
   1.317  
   1.318  nds_test:
   1.319 -	$(MAKE) -C test/nds-test-progs/general
   1.320 -#	$(MAKE) -C test/nds-test-progs/sprite
   1.321 -#	$(MAKE) -C test/nds-test-progs/sprite2
   1.322 +	$(MAKE) -C test/nds-test-progs
   1.323 +
   1.324 +tags:
   1.325 +	etags $(SRCS)
   1.326 +
   1.327 +# This file must be compiled with the ARM instruction set, not
   1.328 +# thumb. Use devkitpro way of doing things.
   1.329 +arm_only: src/atomic/SDL_spinlock.arm.c
   1.330 +src/atomic/SDL_spinlock.arm.c: src/atomic/SDL_spinlock.c
   1.331 +	@cp $< $@
   1.332 +
   1.333 +#---------------------------------------------------------------------------------
   1.334 +clean:
   1.335 +	@echo clean ...
   1.336 +	@cd src; rm -fr $(OFILES) $(OFILES:.o=.d) lib
   1.337 +
   1.338 +#---------------------------------------------------------------------------------
   1.339 +else
   1.340  
   1.341 -clean:
   1.342 -	rm -f $(OBJS)
   1.343 +DEPENDS	:=	$(OFILES:.o=.d)
   1.344 +
   1.345 +#---------------------------------------------------------------------------------
   1.346 +# main targets
   1.347 +#---------------------------------------------------------------------------------
   1.348 +$(OUTPUT)	:	$(OFILES)
   1.349 +
   1.350 +#---------------------------------------------------------------------------------
   1.351 +%.bin.o	:	%.bin
   1.352 +#---------------------------------------------------------------------------------
   1.353 +	@echo $(notdir $<)
   1.354 +	@$(bin2o)
   1.355 +
   1.356 +
   1.357 +-include $(DEPENDS)
   1.358 +
   1.359 +#---------------------------------------------------------------------------------------
   1.360 +endif
   1.361 +#---------------------------------------------------------------------------------------