Makefile.ds
author Sam Lantinga <slouken@libsdl.org>
Sun, 06 Mar 2011 21:12:19 -0800
changeset 5423 b69fa50e80d7
parent 5310 a9945ce48999
child 5428 cff5d3cd5777
permissions -rw-r--r--
a Nintendo ds update

Frank Zago to SDL

For those interested, here's a snapshot of the current port. I did away with
most of the previous attempt which was based of the sprite engine, because the
support is limited to 128 64x64 sprites. Instead I'm using the gl engine.
The drawback is that either the frame buffer or the gl engine can be used
because there's not that much video memory on a DS.

With minimal changes to their code, it can now run the following tests: ,
testspriteminimal, testscale and testsprite2. The last 2 only run under the
emulator for some reason. The tests are not included in this patch for size
reason.

In 16 bits mode, the 16th bit indicated transparency/opacity. If 0, the color
is not displayed. So I had to patch a few core file to set that bit to 1. See
patch for src/video/SDL_RLEaccel.c and src/video/SDL_blit.h. Is that ok, or is
there a better way ?

The nds also doesn't support windowed mode, so I force the fullscreen in
src/video/SDL_video.c. Is that ok, or is there a better way ?

To get a smaller library, I also tried to not compile the software renderer
when the hardware renderer is compiled in, and define SDL_NO_COMPAT; however
the compilation eventually fails in SDL_surface.c because SDL_SRCCOLORKEY is
defined in SDL_compat.h. Is SDL_NO_COMPAT only for application and not SDL
itself ?
slouken@5423
     1
#---------------------------------------------------------------------------------
slouken@5423
     2
.SUFFIXES:
slouken@5423
     3
#---------------------------------------------------------------------------------
slouken@2735
     4
slouken@5423
     5
ifeq ($(strip $(DEVKITARM)),)
slouken@5423
     6
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
slouken@5423
     7
endif
slouken@5289
     8
slouken@5423
     9
include $(DEVKITARM)/ds_rules
slouken@5423
    10
slouken@5423
    11
#---------------------------------------------------------------------------------
slouken@5423
    12
# TARGET is the name of the output
slouken@5423
    13
# BUILD is the directory where object files & intermediate files will be placed
slouken@5423
    14
# SOURCES is a list of directories containing source code
slouken@5423
    15
# DATA is a list of directories containing data files
slouken@5423
    16
# INCLUDES is a list of directories containing header files
slouken@5423
    17
#---------------------------------------------------------------------------------
slouken@5423
    18
TARGET		:=	$(shell basename $(CURDIR))
slouken@5423
    19
BUILD		:=	src
slouken@5423
    20
SOURCES		:=	source
slouken@5423
    21
DATA		:=	data
slouken@5423
    22
INCLUDES	:=	include
slouken@5423
    23
slouken@5423
    24
#---------------------------------------------------------------------------------
slouken@5423
    25
# options for code generation
slouken@5423
    26
#---------------------------------------------------------------------------------
slouken@5423
    27
ARCH	:=	-mthumb -mthumb-interwork \
slouken@5423
    28
		-D__NDS__ -DENABLE_NDS -DNO_SIGNAL_H -DDISABLE_THREADS -DPACKAGE=\"SDL\" \
slouken@5423
    29
		 -DVERSION=\"1.3\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1  
slouken@5423
    30
slouken@5423
    31
CFLAGS	:=	-g -Wall -O2\
slouken@5423
    32
		-march=armv5te -mtune=arm946e-s \
slouken@5423
    33
		-fomit-frame-pointer -ffast-math \
slouken@5423
    34
		$(ARCH)
slouken@5423
    35
slouken@5423
    36
CFLAGS	+=	$(INCLUDE) -DARM9
slouken@5423
    37
CXXFLAGS	:= $(CFLAGS) -fno-rtti -fno-exceptions
slouken@5423
    38
slouken@5423
    39
ASFLAGS	:=	-g $(ARCH) -march=armv5te -mtune=arm946e-s
slouken@5423
    40
LDFLAGS	=	-specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
slouken@5423
    41
slouken@5423
    42
# Set to 0 to use a framer buffer, or 1 to use the hardware
slouken@5423
    43
# renderer. Alas, both cannot be used at the same time for lack of
slouken@5423
    44
# display/texture memory.
slouken@5423
    45
USE_HW_RENDERER := 1
slouken@5423
    46
slouken@5423
    47
ifeq ($(USE_HW_RENDERER),1)
slouken@5423
    48
CFLAGS += -DUSE_HW_RENDERER
slouken@5423
    49
else
slouken@5289
    50
endif
slouken@5423
    51
slouken@5423
    52
#---------------------------------------------------------------------------------
slouken@5423
    53
# list of directories containing libraries, this must be the top level containing
slouken@5423
    54
# include and lib
slouken@5423
    55
#---------------------------------------------------------------------------------
slouken@5423
    56
LIBDIRS	:=	$(LIBNDS)
slouken@5423
    57
slouken@5423
    58
#---------------------------------------------------------------------------------
slouken@5423
    59
# no real need to edit anything past this point unless you need to add additional
slouken@5423
    60
# rules for different file extensions
slouken@5423
    61
#---------------------------------------------------------------------------------
slouken@5423
    62
ifneq ($(BUILD),$(notdir $(CURDIR)))
slouken@5423
    63
#---------------------------------------------------------------------------------
slouken@5423
    64
slouken@5423
    65
export OUTPUT	:=	$(CURDIR)/lib/lib$(TARGET).a
slouken@5423
    66
slouken@5423
    67
export VPATH	:=	$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
slouken@5423
    68
			$(foreach dir,$(DATA),$(CURDIR)/$(dir))
slouken@5423
    69
slouken@5423
    70
export DEPSDIR	:=	$(CURDIR)/$(BUILD)
slouken@5423
    71
slouken@5423
    72
CFILES		:=	\
slouken@5423
    73
			SDL.c \
slouken@5423
    74
			SDL_assert.c \
slouken@5423
    75
			SDL_compat.c \
slouken@5423
    76
			SDL_error.c \
slouken@5423
    77
			SDL_fatal.c \
slouken@5423
    78
			SDL_hints.c \
slouken@5423
    79
			SDL_log.c \
slouken@5423
    80
			atomic/SDL_atomic.c \
slouken@5423
    81
			atomic/SDL_spinlock.arm.c \
slouken@5423
    82
			audio/SDL_audio.c \
slouken@5423
    83
			audio/SDL_audiocvt.c \
slouken@5423
    84
			audio/SDL_audiodev.c \
slouken@5423
    85
			audio/SDL_audiotypecvt.c \
slouken@5423
    86
			audio/SDL_mixer.c \
slouken@5423
    87
			audio/SDL_mixer_MMX.c \
slouken@5423
    88
			audio/SDL_mixer_MMX_VC.c \
slouken@5423
    89
			audio/SDL_mixer_m68k.c \
slouken@5423
    90
			audio/SDL_wave.c \
slouken@5423
    91
			audio/nds/SDL_ndsaudio.c \
slouken@5423
    92
			cpuinfo/SDL_cpuinfo.c \
slouken@5423
    93
			events/SDL_events.c \
slouken@5423
    94
			events/SDL_keyboard.c \
slouken@5423
    95
			events/SDL_mouse.c \
slouken@5423
    96
			events/SDL_quit.c \
slouken@5423
    97
			events/SDL_touch.c \
slouken@5423
    98
			events/SDL_windowevents.c \
slouken@5423
    99
			events/nds/SDL_ndsgesture.c \
slouken@5423
   100
			file/SDL_rwops.c \
slouken@5423
   101
			haptic/SDL_haptic.c \
slouken@5423
   102
			haptic/nds/SDL_syshaptic.c \
slouken@5423
   103
			joystick/SDL_joystick.c \
slouken@5423
   104
			joystick/nds/SDL_sysjoystick.c \
slouken@5423
   105
			power/SDL_power.c \
slouken@5423
   106
			power/nds/SDL_syspower.c \
slouken@5423
   107
			render/SDL_render.c \
slouken@5423
   108
			render/SDL_yuv_sw.c \
slouken@5423
   109
			render/software/SDL_blendfillrect.c \
slouken@5423
   110
			render/software/SDL_blendline.c \
slouken@5423
   111
			render/software/SDL_blendpoint.c \
slouken@5423
   112
			render/software/SDL_drawline.c \
slouken@5423
   113
			render/software/SDL_drawpoint.c \
slouken@5423
   114
			render/software/SDL_render_sw.c \
slouken@5423
   115
			stdlib/SDL_getenv.c \
slouken@5423
   116
			stdlib/SDL_iconv.c \
slouken@5423
   117
			stdlib/SDL_malloc.c \
slouken@5423
   118
			stdlib/SDL_qsort.c \
slouken@5423
   119
			stdlib/SDL_stdlib.c \
slouken@5423
   120
			stdlib/SDL_string.c \
slouken@5423
   121
			thread/SDL_thread.c \
slouken@5423
   122
			thread/nds/SDL_syscond.c \
slouken@5423
   123
			thread/nds/SDL_sysmutex.c \
slouken@5423
   124
			thread/nds/SDL_syssem.c \
slouken@5423
   125
			thread/nds/SDL_systhread.c \
slouken@5423
   126
			timer/SDL_timer.c \
slouken@5423
   127
			timer/nds/SDL_systimer.c \
slouken@5423
   128
			video/SDL_RLEaccel.c \
slouken@5423
   129
			video/SDL_blit.c \
slouken@5423
   130
			video/SDL_blit_0.c \
slouken@5423
   131
			video/SDL_blit_1.c \
slouken@5423
   132
			video/SDL_blit_A.c \
slouken@5423
   133
			video/SDL_blit_N.c \
slouken@5423
   134
			video/SDL_blit_auto.c \
slouken@5423
   135
			video/SDL_blit_copy.c \
slouken@5423
   136
			video/SDL_blit_slow.c \
slouken@5423
   137
			video/SDL_bmp.c \
slouken@5423
   138
			video/SDL_clipboard.c \
slouken@5423
   139
			video/SDL_fillrect.c \
slouken@5423
   140
			video/SDL_pixels.c \
slouken@5423
   141
			video/SDL_rect.c \
slouken@5423
   142
			video/SDL_stretch.c \
slouken@5423
   143
			video/SDL_surface.c \
slouken@5423
   144
			video/SDL_video.c \
slouken@5423
   145
			video/nds/SDL_ndsevents.c \
slouken@5423
   146
			video/nds/SDL_ndsvideo.c
slouken@5423
   147
slouken@5423
   148
slouken@5423
   149
ifeq ($(USE_HW_RENDERER),1)
slouken@5423
   150
# Ideally we should be able to not include the SW renderer at set
slouken@5423
   151
# SDL_NO_COMPAT. However that breaks the build.
slouken@5423
   152
CFILES +=	render/nds/SDL_ndsrender.c
slouken@5423
   153
else
slouken@5289
   154
endif
slouken@2735
   155
slouken@5423
   156
#CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
slouken@5423
   157
#SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
slouken@5423
   158
#BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
slouken@2735
   159
slouken@5423
   160
#---------------------------------------------------------------------------------
slouken@5423
   161
# use CXX for linking C++ projects, CC for standard C
slouken@5423
   162
#---------------------------------------------------------------------------------
slouken@5423
   163
ifeq ($(strip $(CPPFILES)),)
slouken@5423
   164
#---------------------------------------------------------------------------------
slouken@5423
   165
	export LD	:=	$(CC)
slouken@5423
   166
#---------------------------------------------------------------------------------
slouken@5423
   167
else
slouken@5423
   168
#---------------------------------------------------------------------------------
slouken@5423
   169
	export LD	:=	$(CXX)
slouken@5423
   170
#---------------------------------------------------------------------------------
slouken@5423
   171
endif
slouken@5423
   172
#---------------------------------------------------------------------------------
slouken@2735
   173
slouken@5423
   174
export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
slouken@5423
   175
			$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
slouken@2735
   176
slouken@5423
   177
export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
slouken@5423
   178
			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
slouken@5423
   179
			-I$(CURDIR)/$(BUILD)
slouken@2735
   180
slouken@5423
   181
.PHONY: $(BUILD) clean all
slouken@2735
   182
slouken@5423
   183
#---------------------------------------------------------------------------------
slouken@5423
   184
all: arm_only $(BUILD) install nds_test
slouken@2735
   185
slouken@5423
   186
lib:
slouken@5423
   187
	@[ -d $@ ] || mkdir -p $@
slouken@2735
   188
slouken@5423
   189
$(BUILD): lib
slouken@5423
   190
	@[ -d $@ ] || mkdir -p $@
slouken@5423
   191
	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.ds -s
slouken@2735
   192
slouken@5423
   193
install: $(BUILD)
slouken@5423
   194
	@cp $(OUTPUT) $(DEVKITPRO)/libnds/lib/
slouken@2735
   195
	@mkdir -p $(DEVKITPRO)/libnds/include/SDL/
slouken@2735
   196
	@cp include/*.h $(DEVKITPRO)/libnds/include/SDL/
slouken@2735
   197
slouken@2735
   198
nds_test:
slouken@5423
   199
	$(MAKE) -C test/nds-test-progs
slouken@2735
   200
slouken@5423
   201
tags:
slouken@5423
   202
	etags $(SRCS)
slouken@5423
   203
slouken@5423
   204
# This file must be compiled with the ARM instruction set, not
slouken@5423
   205
# thumb. Use devkitpro way of doing things.
slouken@5423
   206
arm_only: src/atomic/SDL_spinlock.arm.c
slouken@5423
   207
src/atomic/SDL_spinlock.arm.c: src/atomic/SDL_spinlock.c
slouken@5423
   208
	@cp $< $@
slouken@5423
   209
slouken@5423
   210
#---------------------------------------------------------------------------------
slouken@2735
   211
clean:
slouken@5423
   212
	@echo clean ...
slouken@5423
   213
	@cd src; rm -fr $(OFILES) $(OFILES:.o=.d) lib
slouken@5423
   214
slouken@5423
   215
#---------------------------------------------------------------------------------
slouken@5423
   216
else
slouken@5423
   217
slouken@5423
   218
DEPENDS	:=	$(OFILES:.o=.d)
slouken@5423
   219
slouken@5423
   220
#---------------------------------------------------------------------------------
slouken@5423
   221
# main targets
slouken@5423
   222
#---------------------------------------------------------------------------------
slouken@5423
   223
$(OUTPUT)	:	$(OFILES)
slouken@5423
   224
slouken@5423
   225
#---------------------------------------------------------------------------------
slouken@5423
   226
%.bin.o	:	%.bin
slouken@5423
   227
#---------------------------------------------------------------------------------
slouken@5423
   228
	@echo $(notdir $<)
slouken@5423
   229
	@$(bin2o)
slouken@5423
   230
slouken@5423
   231
slouken@5423
   232
-include $(DEPENDS)
slouken@5423
   233
slouken@5423
   234
#---------------------------------------------------------------------------------------
slouken@5423
   235
endif
slouken@5423
   236
#---------------------------------------------------------------------------------------