|
|
|
task :default => 'build:linux'
|
|
|
|
|
|
|
|
require 'rake/clean'
|
|
|
|
require "./functions.rb"
|
|
|
|
verbose(false)
|
|
|
|
|
|
|
|
VERSION = "1.0"
|
|
|
|
|
|
|
|
$cc = "cc"
|
|
|
|
$ar = "ar rc"
|
|
|
|
$ranlib = "ranlib"
|
|
|
|
$prefix = "/usr"
|
|
|
|
|
|
|
|
$cflags = Array.new
|
|
|
|
$libs = Array.new
|
|
|
|
|
|
|
|
$has_iconv = 1
|
|
|
|
|
|
|
|
CLEAN.include('src/steed/*.o', 'src/zlib/*.o', 'src/zlib/libz.a', 'desktop/*.desktop')
|
|
|
|
namespace :build do
|
|
|
|
desc "Build from sources for Linux (generic) (default)"
|
|
|
|
task :linux do
|
|
|
|
puts "Building Steed for Linux."
|
|
|
|
configure()
|
|
|
|
$cflags.unshift(" -D_LOCAL_APPDATA") #i swear i would get rid of this s**t
|
|
|
|
$cflags.unshift("-g -Wall")
|
|
|
|
$cflags.unshift("-Dunix")
|
|
|
|
$cflags.push(%Q!-DLANG_PATH='"./lang"' -DSTEAD_PATH='"./stead"' -DGAMES_PATH='"./games"' -DTHEMES_PATH='"./themes"' -DVERSION='"#{VERSION}"' -DICON_PATH='"./icon"'!)
|
|
|
|
|
|
|
|
print "Building Steed.."
|
|
|
|
Dir.chdir("src/steed") do
|
|
|
|
sources = FileList["graphics.c","input.c","game.c","main.c","instead.c","sound.c","SDL_*.c","config.c","themes.c","menu.c","util.c","cache.c","unzip.c","ioapi.c","unpack.c","lfs.c","idf.c"]
|
|
|
|
sources.push ("unix.c")
|
|
|
|
print "."
|
|
|
|
sources.each do|src|
|
|
|
|
sh %Q(#{$cc} -c #{src} #{$cflags.join(" ")})
|
|
|
|
end
|
|
|
|
sh "#{$cc} #{$cflags.join(" ")} #{sources.ext("o").join(" ")} #{$libs.join(" ")} -o steed"
|
|
|
|
end
|
|
|
|
sh "ln -fs src/steed/steed ./steed"
|
|
|
|
end
|
|
|
|
|
|
|
|
task :zlib do
|
|
|
|
if File.exist? 'src/zlib/libz.a' then next end
|
|
|
|
Dir.chdir("src/zlib") do
|
|
|
|
sources = FileList["*.c"]
|
|
|
|
sources.each do|src|
|
|
|
|
sh %Q(#{$cc} -g -Wall -c #{src} -o #{src.ext("o")})
|
|
|
|
end
|
|
|
|
sh "#{$ar} libz.a #{sources.ext("o").join(" ")}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Install Steed"
|
|
|
|
task :install do
|
|
|
|
$cflags.unshift("-g -Wall")
|
|
|
|
print "Enter prefix path [/usr]:"
|
|
|
|
$prefix = STDIN.gets.chomp
|
|
|
|
if ($prefix.empty?) then $prefix = "/usr" end
|
|
|
|
$cflags.unshift("-Dunix")
|
|
|
|
$cflags.push(%Q!-DLANG_PATH='"#{$prefix}/share/steed/lang"' -DSTEAD_PATH='"#{$prefix}/share/steed/stead"' -DGAMES_PATH='"#{$prefix}/share/steed/games"' -DTHEMES_PATH='"#{$prefix}/share/steed/themes"' -DVERSION='"#{VERSION}"' -DICON_PATH='"#{$prefix}/share/pixmaps"'!)
|
|
|
|
configure()
|
|
|
|
Dir.chdir("src/steed") do
|
|
|
|
sources = FileList["graphics.c","input.c","game.c","main.c","instead.c","sound.c","SDL_*.c","config.c","themes.c","menu.c","util.c","cache.c","unzip.c","ioapi.c","unpack.c","lfs.c","idf.c"]
|
|
|
|
sources.push ("unix.c")
|
|
|
|
sources.each do|src|
|
|
|
|
sh %Q(#{$cc} -c #{src} #{$cflags.join(" ")})
|
|
|
|
end
|
|
|
|
sh "#{$cc} #{$cflags.join(" ")} #{sources.ext("o").join(" ")} #{$libs.join(" ")} -o steed"
|
|
|
|
end
|
|
|
|
mkdir_p "#{$prefix}/share/steed/lang"
|
|
|
|
mkdir_p "#{$prefix}/share/steed/stead"
|
|
|
|
mkdir_p "#{$prefix}/share/doc/steed/modules"
|
|
|
|
FileList["lang/*.ini"].each do |file|
|
|
|
|
cp file,"#{$prefix}/share/steed/lang"
|
|
|
|
end
|
|
|
|
FileList["stead/*.lua"].each do |file|
|
|
|
|
cp file,"#{$prefix}/share/steed/stead"
|
|
|
|
end
|
|
|
|
FileList["doc/modules/*.txt"].each do |file|
|
|
|
|
cp file, "#{$prefix}/share/doc/steed/modules"
|
|
|
|
end
|
|
|
|
FileList["doc/*.txt","doc/*.html","doc/*.pdf"].each do |file|
|
|
|
|
cp file, "#{$prefix}/share/doc/steed"
|
|
|
|
end
|
|
|
|
Dir.glob("games/*/*.{ini,lua,s3m,xm,it,jpg,png,ogg,wav,bin,ttf}").each do |file|
|
|
|
|
mkdir_p $prefix + "/share/steed/games/" + file.split("/").at(-2)
|
|
|
|
cp file, $prefix + "/share/steed/games/" + file.split("/").at(-2)
|
|
|
|
end
|
|
|
|
Dir.glob("games/*/*/*.{ini,lua,s3m,xm,it,jpg,png,ogg,wav,bin,ttf}").each do |file|
|
|
|
|
mkdir_p $prefix + "/share/steed/games/" + file.split("/").at(-3) + file.split("/").at(-2)
|
|
|
|
cp file, $prefix + "/share/steed/games/" + file.split("/").at(-3) + file.split("/").at(-2)
|
|
|
|
end
|
|
|
|
Dir.glob("themes/*/*.{ini,jpg,png,ogg,wav,ttf}").each do |file|
|
|
|
|
mkdir_p $prefix + "/share/steed/themes/" + file.split("/").at(-2)
|
|
|
|
cp file, $prefix + "/share/steed/themes/" + file.split("/").at(-2)
|
|
|
|
end
|
|
|
|
#todo: icon -> pixmaps
|
|
|
|
cp "README", "#{$prefix}/share/doc/steed"
|
|
|
|
cp "src/steed/steed", "#{$prefix}/bin"
|
|
|
|
puts "Installation complete."
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :test do
|
|
|
|
desc "Test SDL"
|
|
|
|
task :sdl do
|
|
|
|
sh "#{$cc} ./tests/sdl.c `sdl-config --cflags` `sdl-config --libs` -lSDL_ttf -lSDL_mixer -lSDL_image -o /tmp/sdl-test"
|
|
|
|
unless File.exist? '/tmp/sdl-test' then
|
|
|
|
puts "Testing SDL... fail"
|
|
|
|
puts "Please install sources for sdl, sdl_ttf, sdl_mixer and sdl_image C libraries."
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
puts "Testing SDL... success"
|
|
|
|
rm("/tmp/sdl-test")
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Test Iconv for encoding conversions"
|
|
|
|
task :iconv do
|
|
|
|
print "Testing iconv.. "
|
|
|
|
sh "#{$cc} ./tests/iconv.c -o /tmp/iconv-test" do |ok, res|
|
|
|
|
if !ok then
|
|
|
|
puts "fail"
|
|
|
|
$has_iconv = 0
|
|
|
|
else
|
|
|
|
$has_iconv = 1
|
|
|
|
sh "rm -f /tmp/iconv-test"
|
|
|
|
puts "success"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if ($has_iconv == 1) then next end
|
|
|
|
sh "$cc ./tests/iconv.c -liconv -o /tmp/iconv-test2" do |ok, res|
|
|
|
|
if !ok then
|
|
|
|
puts "fail"
|
|
|
|
$has_iconv = 0
|
|
|
|
else
|
|
|
|
$has_iconv = 2
|
|
|
|
sh "rm -f /tmp/iconv-test2"
|
|
|
|
puts "success"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :packaging do
|
|
|
|
desc "Packaging for Android (debug)"
|
|
|
|
task :androiddbg do
|
|
|
|
puts "Not implemented yet."
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Packaging for Windows (mingw)"
|
|
|
|
task :windows do
|
|
|
|
Rake::Task["rake:clean"].invoke
|
|
|
|
#print "Enter version [#{VERSION}]"
|
|
|
|
#version = STDIN.gets.chomp
|
|
|
|
version = VERSION
|
|
|
|
#if version.empty? then version = VERSION end
|
|
|
|
compiler = detect_mingw()
|
|
|
|
$cc = compiler + "-gcc"
|
|
|
|
$ar = compiler + "-ar"
|
|
|
|
$ranlib = compiler + "-ranlib"
|
|
|
|
$cflags.push("-I/usr/#{compiler}/include -I/usr/#{compiler}/include/SDL -Dwindows -D_SDL_MOD_BUG")
|
|
|
|
$prefix = "./package/windows"
|
|
|
|
$cflags.push(%Q!-DLANG_PATH='"./lang"' -DSTEAD_PATH='"./stead"' -DGAMES_PATH='"./games"' -DTHEMES_PATH='"./themes"' -DVERSION='"#{version}"' -DICON_PATH='"./icon"'!)
|
|
|
|
|
|
|
|
sh "pkg-config --version >/dev/null" do |ok, res|
|
|
|
|
if !ok then
|
|
|
|
puts "Error: there is no pkg-config in $PATH."
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
sh "pkg-config --cflags libsoup-2.4 >/dev/null" do |ok,res|
|
|
|
|
if (ok) then
|
|
|
|
$cflags.push "-D_USE_HTTP"
|
|
|
|
$cflags.push(`pkg-config --cflags libsoup-2.4`.chomp())
|
|
|
|
$libs.push(`pkg-config --libs libsoup-2.4`.chomp())
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
sh "pkg-config --cflags lua >/dev/null" do |ok,res|
|
|
|
|
if (ok) then
|
|
|
|
$cflags.push(`pkg-config --cflags lua`.chomp())
|
|
|
|
$libs.push(`pkg-config --libs lua`.chomp())
|
|
|
|
else
|
|
|
|
sh "pkg-config --cflags lua5.1 >/dev/null" do |ok,res|
|
|
|
|
if (ok) then
|
|
|
|
$cflags.push(`pkg-config --cflags lua5.1`.chomp())
|
|
|
|
$libs.push(`pkg-config --libs lua5.1`.chomp())
|
|
|
|
else
|
|
|
|
puts "Error: lua not found. Please install lua 5.1."
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir("src/zlib") do
|
|
|
|
sources = FileList["*.c"]
|
|
|
|
sources.each do|src|
|
|
|
|
sh %Q(#{$cc} -g -Wall -c #{src} -o #{src.ext("o")})
|
|
|
|
end
|
|
|
|
sh "#{$ar} -q libz.a #{sources.ext("o").join(" ")}"
|
|
|
|
sh "#{$ranlib} libz.a"
|
|
|
|
end
|
|
|
|
|
|
|
|
print "Enter your mingw prefix (used when compiling iconv and SDL):"
|
|
|
|
mingw_prefix = STDIN.gets.chomp
|
|
|
|
|
|
|
|
unless File.exist?("#{mingw_prefix}/include/iconv.h")
|
|
|
|
$cflags.push("-D_HAVE_ICONV")
|
|
|
|
$libs.push("-liconv")
|
|
|
|
end
|
|
|
|
|
|
|
|
unless File.exist?("#{mingw_prefix}/include/SDL/SDL.h")
|
|
|
|
puts ("SDL not found. You should download and compile SDL for mingw.")
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
|
|
|
$cflags.push(`#{mingw_prefix}/bin/sdl-config --cflags`)
|
|
|
|
$libs.push(`#{mingw_prefix}/bin/sdl-config --libs`)
|
|
|
|
$libs.push("-lSDL_ttf -lSDL_mixer -lSDL_image")
|
|
|
|
|
|
|
|
sh "#{$cc} ./tests/sdl.c #{$cflags.join(" ")} #{$libs.join(" ")} -mwindows -o /tmp/sdl-test.exe"
|
|
|
|
unless File.exist? '/tmp/sdl-test.exe' then
|
|
|
|
puts "Please install sources for sdl, sdl_ttf, sdl_mixer and sdl_image C libraries."
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
rm("/tmp/sdl-test.exe")
|
|
|
|
|
|
|
|
Dir.chdir("src/steed") do
|
|
|
|
sources = FileList["graphics.c","input.c","game.c","main.c","instead.c","sound.c","SDL_*.c","config.c","themes.c","menu.c","util.c","cache.c","unzip.c","ioapi.c","unpack.c","lfs.c","idf.c"]
|
|
|
|
sources.push ("windows.c")
|
|
|
|
sources.push ("iowin32.c")
|
|
|
|
sources.each do|src|
|
|
|
|
sh %Q(#{$cc} -c #{src} #{$cflags.join(" ")})
|
|
|
|
end
|
|
|
|
sh "#{$cc} #{$cflags.join(" ")} #{sources.ext("o").join(" ")} #{$libs.join(" ")} -o #{prefix}/steed.exe"
|
|
|
|
end
|
|
|
|
#copy_files_local()
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Packaging for Linux (generic)"
|
|
|
|
task :linux do
|
|
|
|
print "Enter version [#{VERSION}]"
|
|
|
|
version = STDIN.gets.chomp
|
|
|
|
if version.empty? then version = VERSION end
|
|
|
|
$prefix = "./package/unix"
|
|
|
|
Rake::Task["rake:clean"].invoke
|
|
|
|
copy_files_local()
|
|
|
|
sh "7za a #{$prefix}.7z #{$prefix}"
|
|
|
|
puts "Packaging complete."
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Packaging for Debian and Ubuntu"
|
|
|
|
task :debian do
|
|
|
|
puts "Not implemented yet."
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Packaging for Arch Linux"
|
|
|
|
task :arch do
|
|
|
|
$prefix = "./package/arch/files"
|
|
|
|
Rake::Task["rake:clean"].invoke
|
|
|
|
copy_files_local()
|
|
|
|
sh "tar -cz -f package/arch/steed_#{VERSION}.tar.gz package/arch/files/*"
|
|
|
|
|
|
|
|
require 'digest/md5'
|
|
|
|
md5 = Digest::MD5.hexdigest(File.read("package/arch/steed_#{VERSION}.tar.gz"))
|
|
|
|
|
|
|
|
File.open('package/arch/PKGBUILD', 'w') do |f| #until steed has no site the path is relative
|
|
|
|
f.puts <<"EOF"
|
|
|
|
# Contributor: Oreolek <keloero@oreolek.ru>
|
|
|
|
pkgname=steed
|
|
|
|
pkgver=#{VERSION}
|
|
|
|
pkgrel=1
|
|
|
|
pkgdesc="adventure interpreter"
|
|
|
|
arch=('i686' 'x86_64')
|
|
|
|
license=('GPL')
|
|
|
|
|
|
|
|
depends=('sdl' 'sdl_image' 'sdl_mixer' 'sdl_ttf' 'lua' 'libsoup-2.4')
|
|
|
|
makedepends=( 'pkgconfig' 'ruby')
|
|
|
|
|
|
|
|
source=(./steed_#{VERSION}.tar.gz)
|
|
|
|
md5sums=#{md5}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
cd $startdir/src/steed-$pkgver
|
|
|
|
echo '/usr' | rake install
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|