Makefile.ds
author Sam Lantinga <slouken@libsdl.org>
Sat, 26 Mar 2011 21:27:23 -0700
changeset 5516 89ad52a52876
parent 5515 0fcf231a6e74
child 5536 05af1b9ff46d
permissions -rw-r--r--
Temporarily removing sprite and sprite2 at Frank's request
     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=\"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) $(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_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/nds/SDL_ndsrender.c \
   110 			render/software/SDL_blendfillrect.c \
   111 			render/software/SDL_blendline.c \
   112 			render/software/SDL_blendpoint.c \
   113 			render/software/SDL_drawline.c \
   114 			render/software/SDL_drawpoint.c \
   115 			render/software/SDL_render_sw.c \
   116 			stdlib/SDL_getenv.c \
   117 			stdlib/SDL_iconv.c \
   118 			stdlib/SDL_malloc.c \
   119 			stdlib/SDL_qsort.c \
   120 			stdlib/SDL_stdlib.c \
   121 			stdlib/SDL_string.c \
   122 			thread/SDL_thread.c \
   123 			thread/nds/SDL_syscond.c \
   124 			thread/nds/SDL_sysmutex.c \
   125 			thread/nds/SDL_syssem.c \
   126 			thread/nds/SDL_systhread.c \
   127 			timer/SDL_timer.c \
   128 			timer/nds/SDL_systimer.c \
   129 			video/SDL_RLEaccel.c \
   130 			video/SDL_blit.c \
   131 			video/SDL_blit_0.c \
   132 			video/SDL_blit_1.c \
   133 			video/SDL_blit_A.c \
   134 			video/SDL_blit_N.c \
   135 			video/SDL_blit_auto.c \
   136 			video/SDL_blit_copy.c \
   137 			video/SDL_blit_slow.c \
   138 			video/SDL_bmp.c \
   139 			video/SDL_clipboard.c \
   140 			video/SDL_fillrect.c \
   141 			video/SDL_pixels.c \
   142 			video/SDL_rect.c \
   143 			video/SDL_stretch.c \
   144 			video/SDL_surface.c \
   145 			video/SDL_video.c \
   146 			video/nds/SDL_ndsevents.c \
   147 			video/nds/SDL_ndsvideo.c \
   148 			video/nds/SDL_ndswindow.c
   149 
   150 
   151 #CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
   152 #SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
   153 #BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
   154 
   155 #---------------------------------------------------------------------------------
   156 # use CXX for linking C++ projects, CC for standard C
   157 #---------------------------------------------------------------------------------
   158 ifeq ($(strip $(CPPFILES)),)
   159 #---------------------------------------------------------------------------------
   160 	export LD	:=	$(CC)
   161 #---------------------------------------------------------------------------------
   162 else
   163 #---------------------------------------------------------------------------------
   164 	export LD	:=	$(CXX)
   165 #---------------------------------------------------------------------------------
   166 endif
   167 #---------------------------------------------------------------------------------
   168 
   169 export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
   170 			$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
   171 
   172 export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
   173 			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
   174 			-I$(CURDIR)/$(BUILD) \
   175 			-I$(PORTLIBS)/include/SDL
   176 
   177 .PHONY: $(BUILD) clean all
   178 
   179 #---------------------------------------------------------------------------------
   180 all: arm_only $(BUILD) install nds_test
   181 
   182 lib:
   183 	@[ -d $@ ] || mkdir -p $@
   184 
   185 $(BUILD): lib
   186 	@[ -d $@ ] || mkdir -p $@
   187 	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.ds -s
   188 
   189 install: $(BUILD)
   190 	@mkdir -p $(PORTLIBS)/include/SDL/
   191 	@rsync -a $(OUTPUT) $(PORTLIBS)/lib/
   192 	@rsync -a include/*.h $(PORTLIBS)/include/SDL/
   193 
   194 nds_test:
   195 	$(MAKE) -C test/nds-test-progs -s
   196 
   197 tags:
   198 	cd $(SOURCES); etags $(CFILES)
   199 
   200 # This file must be compiled with the ARM instruction set, not
   201 # thumb. Use devkitpro way of doing things.
   202 arm_only: src/atomic/SDL_spinlock.arm.c
   203 src/atomic/SDL_spinlock.arm.c: src/atomic/SDL_spinlock.c
   204 	@cp $< $@
   205 
   206 #---------------------------------------------------------------------------------
   207 clean:
   208 	@echo clean ...
   209 	@cd src; rm -fr $(OFILES) $(OFILES:.o=.d) lib
   210 	@rm -f $(OUTPUT)
   211 	@make -C test/nds-test-progs -s clean
   212 
   213 #---------------------------------------------------------------------------------
   214 else
   215 
   216 DEPENDS	:=	$(OFILES:.o=.d)
   217 
   218 #---------------------------------------------------------------------------------
   219 # main targets
   220 #---------------------------------------------------------------------------------
   221 $(OUTPUT)	:	$(OFILES)
   222 
   223 #---------------------------------------------------------------------------------
   224 %.bin.o	:	%.bin
   225 #---------------------------------------------------------------------------------
   226 	@echo $(notdir $<)
   227 	@$(bin2o)
   228 
   229 
   230 -include $(DEPENDS)
   231 
   232 #---------------------------------------------------------------------------------------
   233 endif
   234 #---------------------------------------------------------------------------------------