分类:
2012-11-01 18:31:46
原文地址:SDL在ARM LINUX上的移植笔记 作者:piaoyizu
SDL(Simple DirectMedia Layer),是免费的跨平台多媒体应用编程接口,可用于游戏、游戏开发工具、模拟器、样本演示、多媒体应用等.
基于SDL库目前已提供丰富的函数库,非常方便开发者使用。常用的如下:
1、SDL_Image:提供显示多种格式的图像显示接口,它支持bmp,png,jpeg,gif,tiff等.
2、SDL_Draw:提供画点线圆等几何图形的接口.
3、SDL_ttf:提供显示TTF文字的接口.
4、SDL_mixer:提供播放各种声音文件的接口.
需要更详细的了解SDL,可以浏览其官方网站:
本次移植的环境如下:
硬件平台:S3C2440开发板
交叉编译器:arm-linux-gcc 3.4.1
######################################################
#
# Generic makefile
#
# Copyright (c)
# All rights reserved.
#
#
######################################################
# 注意事项
#
# 1、pkg-config 工具版本 > 0.15.0
# 2、交叉编译器选用 arm-linux-gcc 3.4.1
#
#
# variable define (同时也需要在环境变量中定义以下变量)
#
PREFIX = /home/arm/cross-compile
LDFLAGS = -L$(PREFIX)/usr/lib
CFLAGS = -I$(PREFIX)/usr/include
PKG_CONFIG_PATH = $(PREFIX)/usr/lib/pkgconfig
CROSS = arm-linux-
ARCH = arm
HOST = arm-linux
BUILD = i386-linux
#
# check directories
#
check_dirs :
if [ ! -e "$(PREFIX)/usr/bin" ]; then mkdir -p $(PREFIX)/usr/bin; fi;
if [ ! -e "$(PREFIX)/usr/sbin" ]; then mkdir -p $(PREFIX)/usr/sbin; fi;
if [ ! -e "$(PREFIX)/usr/share" ]; then mkdir -p $(PREFIX)/usr/share; fi;
if [ ! -e "$(PREFIX)/usr/etc" ]; then mkdir -p $(PREFIX)/usr/etc; fi;
if [ ! -e "$(PREFIX)/usr/com" ]; then mkdir -p $(PREFIX)/usr/com; fi;
if [ ! -e "$(PREFIX)/usr/var" ]; then mkdir -p $(PREFIX)/usr/var; fi;
if [ ! -e "$(PREFIX)/usr/lib" ]; then mkdir -p $(PREFIX)/usr/lib; fi;
if [ ! -e "$(PREFIX)/usr/include" ]; then mkdir -p $(PREFIX)/usr/include; fi;
if [ ! -e "$(PREFIX)/usr/man/man1" ]; then mkdir -p $(PREFIX)/usr/man/man1; fi;
if [ ! -e "$(PREFIX)/usr/info" ]; then mkdir -p $(PREFIX)/usr/info; fi;
if [ ! -e "$(PREFIX)/etc" ]; then mkdir -p $(PREFIX)/etc; fi;
#
# Zlib compile(注意:一定要指定CC、NM、AR等MAKEFILE变量,否则使用GCC编译)
#
ZLIB_DIR="zlib-1.2.3"
.PHONY : zlib_config zlib_build zlib_clean
zlib_config :
@cd $(ZLIB_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --shared --prefix=$(PREFIX)/usr && \
echo "config done"
zlib_build :
@cd $(ZLIB_DIR) && \
make && make install && \
echo "build done"
zlib_clean :
@cd $(ZLIB_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# Freetype compile
#
FREETYPE_DIR="freetype-2.1.9"
.PHONY : freetype_config freetype_build freetype_clean
freetype_config :
@cd $(FREETYPE_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr && \
echo "config done"
freetype_build :
@cd $(FREETYPE_DIR) && \
make && make install && \
echo "build done"
freetype_clean :
@cd $(FREETYPE_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# libpng compile
#
LIBPNG_DIR="libpng-1.2.16"
.PHONY : libpng_config libpng_build libpng_clean
libpng_config :
@cd $(LIBPNG_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr && \
echo "config done"
libpng_build :
@cd $(LIBPNG_DIR) && \
make && make install && \
echo "build done"
libpng_clean :
@cd $(LIBPNG_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# libjpeg compile
# 注意:先生成在本机上能运行的脚本文件libtool(带--enable-static --enable-shared),保存起来,
# 然后在交叉编译时修改脚本configure不要生成脚本文件libtool,
# 最后用本机上能运行的脚本文件libtool作为交叉编译时所用的libtool脚本文件。
#
LIBJPEG_DIR="jpeg-6b"
.PHONY : libjpeg_config libjpeg_build libjpeg_clean
libjpeg_config :
@cd $(LIBJPEG_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr --enable-static --enable-shared && \
echo "config done"
libjpeg_build :
@cd $(LIBJPEG_DIR) && \
make && make install && \
echo "build done"
libjpeg_clean :
@cd $(LIBJPEG_DIR) && \
if [ -e Makefile ]; then make clean; fi && \
echo "clean done"
#
# libtiff compile
#
TIFF_DIR="tiff-3.8.2"
.PHONY : tiff_config tiff_build tiff_clean
tiff_config :
@cd $(TIFF_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr --without-x \
--enable-zlib --with-zlib-include-dir=$(PREFIX)/usr/include \
--with-zlib-lib-dir=$(PREFIX)/usr/lib --with-jpeg-include-dir=$(PREFIX)/usr/include \
--with-jpeg-lib-dir=$(PREFIX)/usr/lib && \
echo "config done"
tiff_build :
@cd $(TIFF_DIR) && \
make && make install && \
echo "build done"
tiff_clean :
@cd $(TIFF_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# tslib compile
#
TSLIB_DIR="tslib-07072006"
.PHONY : tslib_config tslib_build tslib_clean
tslib_config :
@cd $(TSLIB_DIR) && \
echo ac_cv_func_malloc_0_nonnull=yes>$(ARCH)-linux.cache && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr --cache-file=$(ARCH)-linux.cache \
--sysconfdir=${PREFIX}/etc --enable-static && \
echo "config done"
tslib_build :
@cd $(TSLIB_DIR) && \
make && make install && \
echo "build done"
tslib_clean :
@cd $(TSLIB_DIR) && \
if [ -e Makefile ]; then make clean; fi && \
echo "clean done"
#
# libmad compile
#
LIBMAD_DIR="libmad-0.15.1b"
.PHONY : libmad_config libmad_build libmad_clean
libmad_config :
@cd $(LIBMAD_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr && \
echo "config done"
libmad_build :
@cd $(LIBMAD_DIR) && \
make && make install && \
echo "build done"
libmad_clean :
@cd $(LIBMAD_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# libid3tag compile
#
LIBID3TAG_DIR="libid3tag-0.15.1b"
.PHONY : libid3tag_config libid3tag_build libid3tag_clean
libid3tag_config :
@cd $(LIBID3TAG_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS=-I$(PREFIX)/usr/include \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr && \
echo "config done"
libid3tag_build :
@cd $(LIBID3TAG_DIR) && \
make && make install && \
echo "build done"
libid3tag_clean :
@cd $(LIBID3TAG_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# madplay compile
#
MADPLAY_DIR="madplay-0.15.2b"
.PHONY : madplay_config madplay_build madplay_clean
madplay_config :
@cd $(MADPLAY_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS=-I$(PREFIX)/usr/include \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr && \
echo "config done"
madplay_build :
@cd $(MADPLAY_DIR) && \
make && make install && \
echo "build done"
madplay_clean :
@cd $(MADPLAY_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# ALSA lib compile
#
ALSA_DIR="alsa-lib-1.0.13"
.PHONY : libalsa_config libalsa_build libalsa_clean
libalsa_config :
@cd $(ALSA_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--disable-esd --disable-video-directfb && \
echo "config done"
libalsa_build :
@cd $(ALSA_DIR) && \
make && make install && \
echo "build done"
libalsa_clean :
@cd $(ALSA_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# audiofile compile
#
AUDIOFILE_DIR="audiofile-0.2.6"
.PHONY : audiofile_config audiofile_build audiofile_clean
audiofile_config :
@cd $(AUDIOFILE_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--disable-esd --disable-video-directfb && \
echo "config done"
audiofile_build :
@cd $(AUDIOFILE_DIR) && \
make && make install && \
echo "build done"
audiofile_clean :
@cd $(AUDIOFILE_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# esound compile
#
ESOUND_DIR="esound-0.2.38"
.PHONY : esound_config esound_build esound_clean
esound_config :
@cd $(ESOUND_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--disable-esd --disable-video-directfb && \
echo "config done"
esound_build :
@cd $(ESOUND_DIR) && \
make && make install && \
echo "build done"
esound_clean :
@cd $(ESOUND_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# sdl compile
#
SDL_DIR="SDL-1.2.11"
.PHONY : sdl_config sdl_build sdl_clean
sdl_config :
@cd $(SDL_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--with-esd-exec-prefix=$(PREFIX)/usr --disable-video-directfb && \
echo "config done"
sdl_build :
@cd $(SDL_DIR) && \
make && make install && \
echo "build done"
sdl_clean :
@cd $(SDL_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# sdl_image compile
#
SDL_IMAGE_DIR="SDL_image-1.2.5"
.PHONY : sdl_image_config sdl_image_build sdl_image_clean
sdl_image_config :
@cd $(SDL_IMAGE_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--with-sdl-exec-prefix=$(PREFIX)/usr --enable-sdltest && \
echo "config done"
sdl_image_build :
@cd $(SDL_IMAGE_DIR) && \
make && make install && \
echo "build done"
sdl_image_clean :
@cd $(SDL_IMAGE_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# sdl_tff compile
#
SDL_TTF_DIR="SDL_ttf-2.0.8"
.PHONY : sdl_ttf_config sdl_ttf_build sdl_ttf_clean
sdl_ttf_config :
@cd $(SDL_TTF_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--with-freetype-exec-prefix=$(PREFIX)/usr && \
echo "config done"
sdl_ttf_build :
@cd $(SDL_TTF_DIR) && \
make && make install && \
echo "build done"
sdl_ttf_clean :
@cd $(SDL_TTF_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# sdl_draw compile
#
SDL_DRAW_DIR="SDL_draw-1.2.11"
.PHONY : sdl_draw_config sdl_draw_build sdl_draw_clean
sdl_draw_config :
@cd $(SDL_DRAW_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--with-sdl-exec-prefix=$(PREFIX)/usr && \
echo "config done"
sdl_draw_build :
@cd $(SDL_DRAW_DIR) && \
make && make install && \
echo "build done"
sdl_draw_clean :
@cd $(SDL_DRAW_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# sdl_mixer compile
#
SDL_MIXER_DIR="SDL_mixer-1.2.7"
.PHONY : sdl_mixer_config sdl_mixer_build sdl_mixer_clean
sdl_mixer_config :
@cd $(SDL_MIXER_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--with-sdl-exec-prefix=$(PREFIX)/usr && \
echo "config done"
sdl_mixer_build :
@cd $(SDL_MIXER_DIR) && \
make && make install && \
echo "build done"
sdl_mixer_clean :
@cd $(SDL_MIXER_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"
#
# SDL mad compile
#
SDL_MAD_DIR="sdl_mad-0.1"
.PHONY : sdl_mad_config sdl_mad_build sdl_mad_clean
sdl_mad_config :
@cd $(SDL_MAD_DIR) && \
CC=$(CROSS)gcc NM=$(CROSS)nm AR=$(CROSS)ar \
LDFLAGS=-L$(PREFIX)/usr/lib CFLAGS="-I$(PREFIX)/usr/include" \
./configure --host=$(HOST) --build=$(BUILD) --prefix=$(PREFIX)/usr \
--with-sdl-exec-prefix=$(PREFIX)/usr && \
echo "config done"
sdl_mad_build :
@cd $(SDL_MAD_DIR) && \
make && make install && \
echo "build done"
sdl_mad_clean :
@cd $(SDL_MAD_DIR) && \
if [ -e Makefile ]; then make distclean; fi && \
echo "clean done"