2011-09-04 15:56:22 +03:00
|
|
|
task :default => 'build:linux'
|
|
|
|
|
|
|
|
require 'rake/clean'
|
2011-09-06 10:04:27 +03:00
|
|
|
verbose(false)
|
2011-09-04 15:56:22 +03:00
|
|
|
|
2011-09-05 13:12:44 +03:00
|
|
|
VERSION = "1.0"
|
2011-09-04 15:56:22 +03:00
|
|
|
|
|
|
|
$cc = "cc"
|
|
|
|
$ar = "ar rc"
|
|
|
|
$ranlib = "ranlib"
|
2011-09-05 14:34:33 +03:00
|
|
|
$prefix = "/usr"
|
2011-09-04 15:56:22 +03:00
|
|
|
|
|
|
|
$cflags = Array.new
|
|
|
|
$libs = Array.new
|
|
|
|
|
|
|
|
$has_iconv = 1
|
|
|
|
|
2011-09-05 13:12:44 +03:00
|
|
|
CLEAN.include('src/steed/*.o', 'src/zlib/*.o', 'src/zlib/libz.a', 'desktop/*.desktop')
|
2011-09-04 15:56:22 +03:00
|
|
|
namespace :build do
|
|
|
|
desc "Build from sources for Linux (generic) (default)"
|
|
|
|
task :linux do
|
|
|
|
puts "Building Steed for Linux."
|
2011-09-06 10:04:27 +03:00
|
|
|
configure()
|
2011-09-04 15:56:22 +03:00
|
|
|
$cflags.unshift(" -D_LOCAL_APPDATA") #i swear i would get rid of this s**t
|
|
|
|
$cflags.unshift("-g -Wall")
|
|
|
|
$cflags.unshift("-Dunix")
|
2011-09-05 13:12:44 +03:00
|
|
|
$cflags.push(%Q!-DLANG_PATH='"./lang"' -DSTEAD_PATH='"./stead"' -DGAMES_PATH='"./games"' -DTHEMES_PATH='"./themes"' -DVERSION='"#{VERSION}"' -DICON_PATH='"./icon"'!)
|
2011-09-04 15:56:22 +03:00
|
|
|
|
|
|
|
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"]
|
2011-09-05 13:12:44 +03:00
|
|
|
sources.push ("unix.c")
|
2011-09-04 15:56:22 +03:00
|
|
|
print "."
|
|
|
|
sources.each do|src|
|
2011-09-05 13:12:44 +03:00
|
|
|
sh %Q(#{$cc} -c #{src} #{$cflags.join(" ")})
|
2011-09-04 15:56:22 +03:00
|
|
|
end
|
2011-09-05 13:12:44 +03:00
|
|
|
sh "#{$cc} #{$cflags.join(" ")} #{sources.ext("o").join(" ")} #{$libs.join(" ")} -o steed"
|
2011-09-05 14:34:33 +03:00
|
|
|
sh "ln -fs src/steed/steed ./steed"
|
2011-09-05 13:12:44 +03:00
|
|
|
end
|
|
|
|
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(" ")}"
|
2011-09-04 15:56:22 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
def configure #detects $cflags and $libs for every build
|
|
|
|
print "C compiler.."
|
|
|
|
sh "#{$cc} --version >/dev/null" do |ok,res|
|
|
|
|
if !ok then
|
|
|
|
sh "cc --version >/dev/null" do |ok, res|
|
|
|
|
if !ok then
|
|
|
|
sh "gcc --version >/dev/null" do |ok, res|
|
|
|
|
if !ok then
|
|
|
|
puts "Error: can't find C compiler. Please export CC variable for a valid one."
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
$cc = "gcc"
|
|
|
|
print "gcc"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
$cc = "cc"
|
|
|
|
print "cc"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else puts "cc"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
sh "pkg-config --version >/dev/null" do |ok, res|
|
|
|
|
if !ok then
|
|
|
|
puts "Error: there is no pkg-config in $PATH."
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
print "zlib.. "
|
|
|
|
sh "pkg-config --cflags zlib >/dev/null" do |ok,res|
|
|
|
|
if (ok) then
|
|
|
|
puts "system"
|
|
|
|
$cflags.push(`pkg-config --cflags zlib`.chomp())
|
|
|
|
$cflags.push("-D USE_UNPACK")
|
|
|
|
$libs.push(`pkg-config --libs zlib`.chomp())
|
|
|
|
else
|
|
|
|
if File.exist? '/usr/include/zlib.h' then
|
|
|
|
puts "own"
|
2011-09-05 13:12:44 +03:00
|
|
|
Rake::Task["rake:build:zlib"].invoke
|
2011-09-04 15:56:22 +03:00
|
|
|
$cflags.push("-D USE_UNPACK")
|
2011-09-05 13:12:44 +03:00
|
|
|
$cflags.push("-I../zlib")
|
|
|
|
$libs.push("-lz ../zlib/libz.a")
|
2011-09-04 15:56:22 +03:00
|
|
|
else
|
|
|
|
puts "not found"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
print "gtk+-2.0.. "
|
|
|
|
sh "pkg-config --cflags gtk+-2.0 >/dev/null" do |ok,res|
|
|
|
|
if (ok) then
|
|
|
|
puts "found"
|
|
|
|
$cflags.push(`pkg-config --cflags gtk+-2.0`.chomp())
|
|
|
|
$cflags.push "-D_USE_GTK -D_USE_BROWSE"
|
|
|
|
$libs.push(`pkg-config --libs gtk+-2.0`.chomp())
|
2011-09-05 14:34:33 +03:00
|
|
|
$libs.push("-lSDL_mixer -lSDL_image -lSDL_ttf")
|
2011-09-04 15:56:22 +03:00
|
|
|
else
|
|
|
|
puts "not found"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
print "libsoup-2.4.. "
|
|
|
|
sh "pkg-config --cflags libsoup-2.4 >/dev/null" do |ok,res|
|
|
|
|
if (ok) then
|
|
|
|
puts "found"
|
|
|
|
$cflags.push "-D_USE_HTTP"
|
|
|
|
$cflags.push(`pkg-config --cflags libsoup-2.4`.chomp())
|
|
|
|
$libs.push(`pkg-config --libs libsoup-2.4`.chomp())
|
|
|
|
else
|
|
|
|
puts "not found"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
print "lua.. "
|
|
|
|
sh "pkg-config --cflags lua >/dev/null" do |ok,res|
|
|
|
|
if (ok) then
|
|
|
|
puts "found"
|
|
|
|
$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
|
|
|
|
puts "found"
|
|
|
|
$cflags.push(`pkg-config --cflags lua5.1`.chomp())
|
|
|
|
$libs.push(`pkg-config --libs lua5.1`.chomp())
|
2011-09-05 13:12:44 +03:00
|
|
|
$libs.push("-lSDL_ttf -lSDL_mixer -lSDL_image")
|
2011-09-04 15:56:22 +03:00
|
|
|
else
|
|
|
|
puts "not found"
|
|
|
|
puts "Error: lua not found. Please install lua 5.1."
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::Task["rake:test:sdl"].invoke #if we are still alive everything is perfect
|
|
|
|
$cflags.unshift(`sdl-config --cflags`.chomp())
|
|
|
|
$libs.unshift(`sdl-config --libs`.chomp())
|
|
|
|
Rake::Task["rake:test:iconv"].invoke
|
|
|
|
if $has_iconv>0 then
|
|
|
|
$cflags.push("-D_HAVE_ICONV")
|
|
|
|
if $has_iconv == 2 then $libs.push("-liconv") end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-09-06 09:39:10 +03:00
|
|
|
directory "#{$prefix}/share/doc/steed/"
|
|
|
|
directory "#{$prefix}/bin"
|
2011-09-06 10:04:27 +03:00
|
|
|
directory "#{$prefix}"
|
2011-09-06 09:39:10 +03:00
|
|
|
directory "#{$prefix}/share/steed"
|
|
|
|
directory "#{$prefix}/share/man/man6"
|
|
|
|
|
|
|
|
task :man => "#{$prefix}/share/man/man6" do
|
|
|
|
Dir.chdir("doc") do
|
|
|
|
FileList["*.6"].each do |file|
|
|
|
|
cp file, "#{$prefix}/share/man/man6"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
task :data => "#{$prefix}/share/steed" do
|
|
|
|
FileList["lang/*.ini", "stead/*.lua", "themes/*/*.(ini|jpg|png|ogg|wav|ttf)"].each do |file|
|
|
|
|
cp file,"#{$prefix}/share/steed"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
task :steed => "#{$prefix}/bin" do #if I do that as file task it thinks it's already done
|
|
|
|
cp "src/steed/steed", "#{$prefix}/bin"
|
|
|
|
File.chmod(0755, "#{$prefix}/bin/steed")
|
|
|
|
end
|
|
|
|
task :doc => "#{$prefix}/share/doc/steed/" do
|
|
|
|
Dir.chdir("doc") do
|
|
|
|
FileList["modules/*.txt","*.html", "*.txt", "*.pdf"].each do |file|
|
|
|
|
cp file, "#{$prefix}/share/doc/steed/"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Install Steed"
|
|
|
|
task :install do
|
|
|
|
$cflags.unshift("-g -Wall")
|
|
|
|
if (RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i) then
|
2011-09-05 14:34:33 +03:00
|
|
|
print "Enter prefix path [/usr]:"
|
|
|
|
$prefix = STDIN.gets.chomp
|
2011-09-06 09:39:10 +03:00
|
|
|
if ($prefix.empty?) then $prefix = "/usr" end
|
2011-09-05 14:34:33 +03:00
|
|
|
$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"'!)
|
2011-09-06 10:04:27 +03:00
|
|
|
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"
|
|
|
|
sh "ln -fs src/steed/steed ./steed"
|
|
|
|
end
|
2011-09-05 14:34:33 +03:00
|
|
|
#next are parallel
|
2011-09-06 09:39:10 +03:00
|
|
|
Rake::Task["doc"].invoke
|
|
|
|
Rake::Task["data"].invoke
|
|
|
|
Rake::Task["steed"].invoke
|
|
|
|
Rake::Task["man"].invoke
|
2011-09-05 14:34:33 +03:00
|
|
|
puts "Installation complete."
|
|
|
|
end
|
2011-09-06 10:04:27 +03:00
|
|
|
if (Win32.windows?) then
|
|
|
|
$cflags.unshift("-Dwindows -mwindows -D_SDL_MOD_BUG")
|
|
|
|
$prefix = "."
|
|
|
|
$cflags.push(%Q!-DLANG_PATH='"./lang"' -DSTEAD_PATH='"#{$prefix}/stead"' -DGAMES_PATH='"#{$prefix}/games"' -DTHEMES_PATH='"#{$prefix}/themes"' -DVERSION='"#{VERSION}"' -DICON_PATH='"#{$prefix}/icon"'!)
|
|
|
|
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 ("windows.c 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 steed"
|
|
|
|
end
|
|
|
|
Rake::Task["steed"].invoke
|
|
|
|
$prefix = "./bin"
|
|
|
|
FileList["lang/*.ini", "stead/*.lua", "themes/*/*.(ini|jpg|png|ogg|wav|ttf)"].each do |file|
|
|
|
|
cp file,"#{$prefix}"
|
|
|
|
end
|
|
|
|
FileList["modules/*.txt","*.html", "*.txt", "*.pdf"].each do |file|
|
|
|
|
cp file, "#{$prefix}/doc"
|
|
|
|
end
|
|
|
|
puts "Installation complete."
|
|
|
|
end
|
2011-09-04 15:56:22 +03:00
|
|
|
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
|
|
|
|
else
|
|
|
|
puts "Testing SDL... success"
|
|
|
|
sh "rm -f /tmp/sdl-test"
|
|
|
|
end
|
|
|
|
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"
|
|
|
|
task :android, [:version] do |t, args|
|
|
|
|
args.with_defaults(:version => VERSION)
|
|
|
|
end
|
|
|
|
desc "Packaging for Windows (mingw)"
|
|
|
|
task :windows, [:version] do |t, args|
|
|
|
|
args.with_defaults(:version => VERSION)
|
|
|
|
$cc = "i486-mingw32-gcc"
|
|
|
|
$ar = "i486-mingw32-ar rc"
|
|
|
|
$ranlib = "i486-mingw32-ranlib"
|
2011-09-06 10:04:27 +03:00
|
|
|
$cflags.push("-Dwindows -mwindows -D_SDL_MOD_BUG")
|
|
|
|
$prefix = "./package/windows"
|
|
|
|
$cflags.push(%Q!-DLANG_PATH='"./lang"' -DSTEAD_PATH='"#{$prefix}/stead"' -DGAMES_PATH='"#{$prefix}/games"' -DTHEMES_PATH='"#{$prefix}/themes"' -DVERSION='"#{:version}"' -DICON_PATH='"#{$prefix}/icon"'!)
|
|
|
|
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 ("windows.c 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 steed"
|
|
|
|
end
|
|
|
|
Rake::Task[$prefix].invoke
|
|
|
|
FileList["lang/*.ini", "stead/*.lua", "themes/*/*.(ini|jpg|png|ogg|wav|ttf)"].each do |file|
|
|
|
|
cp file,"#{$prefix}"
|
|
|
|
end
|
|
|
|
FileList["modules/*.txt","*.html", "*.txt", "*.pdf"].each do |file|
|
|
|
|
cp file, "#{$prefix}/doc"
|
|
|
|
end
|
|
|
|
puts "Packaging complete."
|
2011-09-04 15:56:22 +03:00
|
|
|
end
|
|
|
|
desc "Packaging for Linux (generic)"
|
|
|
|
task :linux, [:version] do |t, args|
|
|
|
|
args.with_defaults(:version => VERSION)
|
2011-09-06 10:04:27 +03:00
|
|
|
$prefix = "./package/unix"
|
|
|
|
Rake::Task[$prefix].invoke
|
|
|
|
FileList["lang/*.ini", "stead/*.lua", "themes/*/*.(ini|jpg|png|ogg|wav|ttf)"].each do |file|
|
|
|
|
cp file,"#{$prefix}"
|
|
|
|
end
|
|
|
|
FileList["modules/*.txt","*.html", "*.txt", "*.pdf"].each do |file|
|
|
|
|
cp file, "#{$prefix}/doc"
|
|
|
|
end
|
|
|
|
FileList["src/*/*.(c|h)"].each do |file|
|
|
|
|
cp file, "#{$prefix}/src"
|
|
|
|
end
|
|
|
|
cp "Rakefile", $prefix
|
|
|
|
File.open("#{$prefix}/Rakefile", 'r+') { |f| newstr = f.read.gsub (Q(VERSION = "#{VERSION}"), Q(VERSION = "#{:version}")); f.rewind; f.puts(newstr) }
|
|
|
|
puts "Packaging complete."
|
2011-09-04 15:56:22 +03:00
|
|
|
end
|
|
|
|
desc "Packaging for Debian and Ubuntu"
|
|
|
|
task :debian, [:version] do |t, args|
|
|
|
|
args.with_defaults(:version => VERSION)
|
|
|
|
end
|
|
|
|
desc "Packaging for Arch Linux"
|
|
|
|
task :arch, [:version] do |t, args|
|
|
|
|
args.with_defaults(:version => VERSION)
|
|
|
|
end
|
|
|
|
task :all => [:android, :windows, :linux, :debian, :arch] do
|
|
|
|
end
|
|
|
|
end
|