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