-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
55 lines (42 loc) · 1.8 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'rake'
require 'rake/clean'
require 'fileutils'
CXX = ENV['CXX'] || 'clang++'
CFLAGS = "-Wall -Wextra -pedantic -Werror-implicit-function-declaration -Wno-gnu-zero-variadic-macro-arguments -funroll-loops -std=c++11 -pipe -Iinclude #{ENV['CFLAGS']}"
LDFLAGS = "-lGL -lGLEW -lglut #{ENV['LDFLAGS']}"
SOURCES = FileList['source/**/*.cpp']
OBJECTS = SOURCES.ext('o')
EXAMPLES = FileList['examples/*.cpp']
TESTS = FileList['tests/*.cpp']
CLEAN.include(OBJECTS.existing).include(EXAMPLES.ext('').existing).include(TESTS.ext('').existing)
CLOBBER.include('libgloglotto.so', 'libgloglotto-static.a')
task :default => ['libgloglotto.so', 'libgloglotto-static.a']
task :install, [:path] => ['libgloglotto.so', 'libgloglotto-static.a'] do |t, args|
path = args[:path] || '/usr/local'
FileUtils.install 'include/gloglotto', path
FileUtils.install FileList['source/*.tpp'], "#{path}/include/gloglotto"
FileUtils.install FileList['source/maths/*.tpp'], "#{path}/include/gloglotto/maths"
end
task :examples => 'libgloglotto-static.a' do
EXAMPLES.each {|file|
sh "#{CXX} #{CFLAGS} -o #{file.sub(/\.cpp/, '')} #{file} #{LDFLAGS} -L. -lgloglotto-static"
}
end
task :doc do
sh "cldoc #{CFLAGS} -- --output doc #{FileList['include/**/**'].exclude { |f| File.directory?(f) }} #{FileList['source/**/*.cpp']}"
end
task :test do
TESTS.each {|file|
sh "#{CXX} #{CFLAGS} -Itests/amirite -o #{file.sub(/\.cpp/, '')} #{file} #{LDFLAGS} -L. -lgloglotto-static"
sh "./#{file.sub(/\.cpp/, '')}"
}
end
file 'libgloglotto.so' => OBJECTS do
sh "#{CXX} #{CFLAGS} -fPIC #{OBJECTS} -shared -Wl,-soname,libgloglotto -o libgloglotto.so #{LDFLAGS}"
end
file 'libgloglotto-static.a' => OBJECTS do
sh "ar rcs libgloglotto-static.a #{OBJECTS}"
end
rule '.o' => '.cpp' do |t|
sh "#{CXX} #{CFLAGS} -fPIC -o #{t.name} -c #{t.source}"
end