Makefile.ds
author Sam Lantinga <slouken@libsdl.org>
Sun, 12 Feb 2012 21:04:01 -0500
changeset 6285 f12649068adb
parent 6251 3e8c673cad58
permissions -rw-r--r--
Updated Nintendo DS support

Frank Zago

This patch updates the DS port:
- do not use the now removed compat layer.
- integrate parts of libgl2D since I got permission from the author, and thus
removed an external dependancy,
- a few bugs fixes.

Now, the textures should be completely supported, except reading from them
which doesn't makes sense to have on the DS. Sound is still not supported.

If someone else wants to work on the missing pieces, feel free.
     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		:=	src
    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=\"2.0\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1  
    30 
    31 CFLAGS	:=	-g -Wall -Os\
    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 GL like 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) $(PORTLIBS)
    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_error.c \
    76 			SDL_fatal.c \
    77 			SDL_hints.c \
    78 			SDL_log.c \
    79 			atomic/SDL_atomic.c \
    80 			atomic/SDL_spinlock.arm.c \
    81 			audio/SDL_audio.c \
    82 			audio/SDL_audiocvt.c \
    83 			audio/SDL_audiodev.c \
    84 			audio/SDL_audiotypecvt.c \
    85 			audio/SDL_mixer.c \
    86 			audio/SDL_wave.c \
    87 			audio/nds/SDL_ndsaudio.c \
    88 			cpuinfo/SDL_cpuinfo.c \
    89 			events/SDL_events.c \
    90 			events/SDL_keyboard.c \
    91 			events/SDL_mouse.c \
    92 			events/SDL_quit.c \
    93 			events/SDL_touch.c \
    94 			events/SDL_windowevents.c \
    95 			events/nds/SDL_ndsgesture.c \
    96 			file/SDL_rwops.c \
    97 			haptic/SDL_haptic.c \
    98 			haptic/nds/SDL_syshaptic.c \
    99 			joystick/SDL_joystick.c \
   100 			joystick/nds/SDL_sysjoystick.c \
   101 			power/SDL_power.c \
   102 			power/nds/SDL_syspower.c \
   103 			render/SDL_render.c \
   104 			render/SDL_yuv_sw.c \
   105 			render/nds/SDL_ndsrender.c \
   106 			render/nds/SDL_libgl2D.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 \
   114 			stdlib/SDL_iconv.c \
   115 			stdlib/SDL_malloc.c \
   116 			stdlib/SDL_qsort.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 \
   124 			timer/SDL_timer.c \
   125 			timer/nds/SDL_systimer.c \
   126 			video/SDL_RLEaccel.c \
   127 			video/SDL_blit.c \
   128 			video/SDL_blit_0.c \
   129 			video/SDL_blit_1.c \
   130 			video/SDL_blit_A.c \
   131 			video/SDL_blit_N.c \
   132 			video/SDL_blit_auto.c \
   133 			video/SDL_blit_copy.c \
   134 			video/SDL_blit_slow.c \
   135 			video/SDL_bmp.c \
   136 			video/SDL_clipboard.c \
   137 			video/SDL_fillrect.c \
   138 			video/SDL_pixels.c \
   139 			video/SDL_rect.c \
   140 			video/SDL_stretch.c \
   141 			video/SDL_surface.c \
   142 			video/SDL_video.c \
   143 			video/nds/SDL_ndsevents.c \
   144 			video/nds/SDL_ndsvideo.c \
   145 			video/nds/SDL_ndswindow.c
   146 
   147 
   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)/*.*)))
   151 
   152 #---------------------------------------------------------------------------------
   153 # use CXX for linking C++ projects, CC for standard C
   154 #---------------------------------------------------------------------------------
   155 ifeq ($(strip $(CPPFILES)),)
   156 #---------------------------------------------------------------------------------
   157 	export LD	:=	$(CC)
   158 #---------------------------------------------------------------------------------
   159 else
   160 #---------------------------------------------------------------------------------
   161 	export LD	:=	$(CXX)
   162 #---------------------------------------------------------------------------------
   163 endif
   164 #---------------------------------------------------------------------------------
   165 
   166 export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
   167 			$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
   168 
   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
   173 
   174 .PHONY: $(BUILD) clean all
   175 
   176 #---------------------------------------------------------------------------------
   177 all: arm_only $(BUILD) install nds_test
   178 
   179 lib:
   180 	@[ -d $@ ] || mkdir -p $@
   181 
   182 $(BUILD): lib
   183 	@[ -d $@ ] || mkdir -p $@
   184 	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.ds -s
   185 
   186 install: $(BUILD)
   187 	@mkdir -p $(PORTLIBS)/include/SDL/
   188 	@rsync -a $(OUTPUT) $(PORTLIBS)/lib/
   189 	@rsync -a include/*.h $(PORTLIBS)/include/SDL/
   190 
   191 nds_test:
   192 	$(MAKE) -C test/nds-test-progs -s
   193 
   194 tags:
   195 	cd $(SOURCES); etags $(CFILES)
   196 
   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
   201 	@cp $< $@
   202 
   203 #---------------------------------------------------------------------------------
   204 clean:
   205 	@echo clean ...
   206 	@cd src; rm -fr $(OFILES) $(OFILES:.o=.d) lib
   207 	@rm -f $(OUTPUT)
   208 	@make -C test/nds-test-progs -s clean
   209 
   210 #---------------------------------------------------------------------------------
   211 else
   212 
   213 DEPENDS	:=	$(OFILES:.o=.d)
   214 
   215 #---------------------------------------------------------------------------------
   216 # main targets
   217 #---------------------------------------------------------------------------------
   218 $(OUTPUT)	:	$(OFILES)
   219 
   220 #---------------------------------------------------------------------------------
   221 %.bin.o	:	%.bin
   222 #---------------------------------------------------------------------------------
   223 	@echo $(notdir $<)
   224 	@$(bin2o)
   225 
   226 
   227 -include $(DEPENDS)
   228 
   229 #---------------------------------------------------------------------------------------
   230 endif
   231 #---------------------------------------------------------------------------------------