Makefile.ds
author Andreas Schiffler <aschiffler@ferzkopp.net>
Wed, 28 Nov 2012 19:19:57 -0800
changeset 6713 fa17a97389ed
parent 6285 f12649068adb
permissions -rw-r--r--
Add crc32 and md5 to test lib
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@5515
    20
SOURCES		:=	src
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@6251
    29
		 -DVERSION=\"2.0\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1  
slouken@5423
    30
slouken@6285
    31
CFLAGS	:=	-g -Wall -Os\
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@6285
    42
# Set to 0 to use a framer buffer, or 1 to use the GL like 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@5515
    56
LIBDIRS	:=	$(LIBNDS) $(PORTLIBS)
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_error.c \
slouken@5423
    76
			SDL_fatal.c \
slouken@5423
    77
			SDL_hints.c \
slouken@5423
    78
			SDL_log.c \
slouken@5423
    79
			atomic/SDL_atomic.c \
slouken@5423
    80
			atomic/SDL_spinlock.arm.c \
slouken@5423
    81
			audio/SDL_audio.c \
slouken@5423
    82
			audio/SDL_audiocvt.c \
slouken@5423
    83
			audio/SDL_audiodev.c \
slouken@5423
    84
			audio/SDL_audiotypecvt.c \
slouken@5423
    85
			audio/SDL_mixer.c \
slouken@5423
    86
			audio/SDL_wave.c \
slouken@5423
    87
			audio/nds/SDL_ndsaudio.c \
slouken@5423
    88
			cpuinfo/SDL_cpuinfo.c \
slouken@5423
    89
			events/SDL_events.c \
slouken@5423
    90
			events/SDL_keyboard.c \
slouken@5423
    91
			events/SDL_mouse.c \
slouken@5423
    92
			events/SDL_quit.c \
slouken@5423
    93
			events/SDL_touch.c \
slouken@5423
    94
			events/SDL_windowevents.c \
slouken@5423
    95
			events/nds/SDL_ndsgesture.c \
slouken@5423
    96
			file/SDL_rwops.c \
slouken@5423
    97
			haptic/SDL_haptic.c \
slouken@5423
    98
			haptic/nds/SDL_syshaptic.c \
slouken@5423
    99
			joystick/SDL_joystick.c \
slouken@5423
   100
			joystick/nds/SDL_sysjoystick.c \
slouken@5423
   101
			power/SDL_power.c \
slouken@5423
   102
			power/nds/SDL_syspower.c \
slouken@5423
   103
			render/SDL_render.c \
slouken@5423
   104
			render/SDL_yuv_sw.c \
slouken@5428
   105
			render/nds/SDL_ndsrender.c \
slouken@6285
   106
			render/nds/SDL_libgl2D.c \
slouken@5423
   107
			render/software/SDL_blendfillrect.c \
slouken@5423
   108
			render/software/SDL_blendline.c \
slouken@5423
   109
			render/software/SDL_blendpoint.c \
slouken@5423
   110
			render/software/SDL_drawline.c \
slouken@5423
   111
			render/software/SDL_drawpoint.c \
slouken@5423
   112
			render/software/SDL_render_sw.c \
slouken@5423
   113
			stdlib/SDL_getenv.c \
slouken@5423
   114
			stdlib/SDL_iconv.c \
slouken@5423
   115
			stdlib/SDL_malloc.c \
slouken@5423
   116
			stdlib/SDL_qsort.c \
slouken@5423
   117
			stdlib/SDL_stdlib.c \
slouken@5423
   118
			stdlib/SDL_string.c \
slouken@5423
   119
			thread/SDL_thread.c \
slouken@5423
   120
			thread/nds/SDL_syscond.c \
slouken@5423
   121
			thread/nds/SDL_sysmutex.c \
slouken@5423
   122
			thread/nds/SDL_syssem.c \
slouken@5423
   123
			thread/nds/SDL_systhread.c \
slouken@5423
   124
			timer/SDL_timer.c \
slouken@5423
   125
			timer/nds/SDL_systimer.c \
slouken@5423
   126
			video/SDL_RLEaccel.c \
slouken@5423
   127
			video/SDL_blit.c \
slouken@5423
   128
			video/SDL_blit_0.c \
slouken@5423
   129
			video/SDL_blit_1.c \
slouken@5423
   130
			video/SDL_blit_A.c \
slouken@5423
   131
			video/SDL_blit_N.c \
slouken@5423
   132
			video/SDL_blit_auto.c \
slouken@5423
   133
			video/SDL_blit_copy.c \
slouken@5423
   134
			video/SDL_blit_slow.c \
slouken@5423
   135
			video/SDL_bmp.c \
slouken@5423
   136
			video/SDL_clipboard.c \
slouken@5423
   137
			video/SDL_fillrect.c \
slouken@5423
   138
			video/SDL_pixels.c \
slouken@5423
   139
			video/SDL_rect.c \
slouken@5423
   140
			video/SDL_stretch.c \
slouken@5423
   141
			video/SDL_surface.c \
slouken@5423
   142
			video/SDL_video.c \
slouken@5423
   143
			video/nds/SDL_ndsevents.c \
slouken@5428
   144
			video/nds/SDL_ndsvideo.c \
slouken@5428
   145
			video/nds/SDL_ndswindow.c
slouken@5423
   146
slouken@5423
   147
slouken@5423
   148
#CPPFILES	:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
slouken@5423
   149
#SFILES		:=	$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
slouken@5423
   150
#BINFILES	:=	$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
slouken@2735
   151
slouken@5423
   152
#---------------------------------------------------------------------------------
slouken@5423
   153
# use CXX for linking C++ projects, CC for standard C
slouken@5423
   154
#---------------------------------------------------------------------------------
slouken@5423
   155
ifeq ($(strip $(CPPFILES)),)
slouken@5423
   156
#---------------------------------------------------------------------------------
slouken@5423
   157
	export LD	:=	$(CC)
slouken@5423
   158
#---------------------------------------------------------------------------------
slouken@5423
   159
else
slouken@5423
   160
#---------------------------------------------------------------------------------
slouken@5423
   161
	export LD	:=	$(CXX)
slouken@5423
   162
#---------------------------------------------------------------------------------
slouken@5423
   163
endif
slouken@5423
   164
#---------------------------------------------------------------------------------
slouken@2735
   165
slouken@5423
   166
export OFILES	:=	$(addsuffix .o,$(BINFILES)) \
slouken@5423
   167
			$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
slouken@2735
   168
slouken@5423
   169
export INCLUDE	:=	$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
slouken@5423
   170
			$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
slouken@5515
   171
			-I$(CURDIR)/$(BUILD) \
slouken@5515
   172
			-I$(PORTLIBS)/include/SDL
slouken@2735
   173
slouken@5423
   174
.PHONY: $(BUILD) clean all
slouken@2735
   175
slouken@5423
   176
#---------------------------------------------------------------------------------
slouken@5423
   177
all: arm_only $(BUILD) install nds_test
slouken@2735
   178
slouken@5423
   179
lib:
slouken@5423
   180
	@[ -d $@ ] || mkdir -p $@
slouken@2735
   181
slouken@5423
   182
$(BUILD): lib
slouken@5423
   183
	@[ -d $@ ] || mkdir -p $@
slouken@5423
   184
	@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.ds -s
slouken@2735
   185
slouken@5423
   186
install: $(BUILD)
slouken@5515
   187
	@mkdir -p $(PORTLIBS)/include/SDL/
slouken@5515
   188
	@rsync -a $(OUTPUT) $(PORTLIBS)/lib/
slouken@5515
   189
	@rsync -a include/*.h $(PORTLIBS)/include/SDL/
slouken@2735
   190
slouken@2735
   191
nds_test:
slouken@5515
   192
	$(MAKE) -C test/nds-test-progs -s
slouken@2735
   193
slouken@5423
   194
tags:
slouken@5515
   195
	cd $(SOURCES); etags $(CFILES)
slouken@5423
   196
slouken@5423
   197
# This file must be compiled with the ARM instruction set, not
slouken@5423
   198
# thumb. Use devkitpro way of doing things.
slouken@5423
   199
arm_only: src/atomic/SDL_spinlock.arm.c
slouken@5423
   200
src/atomic/SDL_spinlock.arm.c: src/atomic/SDL_spinlock.c
slouken@5423
   201
	@cp $< $@
slouken@5423
   202
slouken@5423
   203
#---------------------------------------------------------------------------------
slouken@2735
   204
clean:
slouken@5423
   205
	@echo clean ...
slouken@5423
   206
	@cd src; rm -fr $(OFILES) $(OFILES:.o=.d) lib
slouken@5515
   207
	@rm -f $(OUTPUT)
slouken@5515
   208
	@make -C test/nds-test-progs -s clean
slouken@5423
   209
slouken@5423
   210
#---------------------------------------------------------------------------------
slouken@5423
   211
else
slouken@5423
   212
slouken@5423
   213
DEPENDS	:=	$(OFILES:.o=.d)
slouken@5423
   214
slouken@5423
   215
#---------------------------------------------------------------------------------
slouken@5423
   216
# main targets
slouken@5423
   217
#---------------------------------------------------------------------------------
slouken@5423
   218
$(OUTPUT)	:	$(OFILES)
slouken@5423
   219
slouken@5423
   220
#---------------------------------------------------------------------------------
slouken@5423
   221
%.bin.o	:	%.bin
slouken@5423
   222
#---------------------------------------------------------------------------------
slouken@5423
   223
	@echo $(notdir $<)
slouken@5423
   224
	@$(bin2o)
slouken@5423
   225
slouken@5423
   226
slouken@5423
   227
-include $(DEPENDS)
slouken@5423
   228
slouken@5423
   229
#---------------------------------------------------------------------------------------
slouken@5423
   230
endif
slouken@5423
   231
#---------------------------------------------------------------------------------------