Skip to content

Commit ceaeee4

Browse files
committed
Use the TAGLIB_DIR env. var. to use non-standard taglib prefix
If the TAGLIB_DIR env. var. is not specified, taglib is assumed to be installed at standard locations. Otherwise, it is assumed that taglib headers are located at $TAGLIB_DIR/include and taglib libraries at $TAGLIB_DIR/lib. This prefix is taken into account by both the swig and compile rake tasks.
1 parent c210c21 commit ceaeee4

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ Build and install gem into system gems:
9595

9696
rake install
9797

98+
The `swig` and `compile` rake tasks can use the `TAGLIB_DIR` environment
99+
variable to build against non-standard taglib installations. It is assumed
100+
that taglib headers are located at `$TAGLIB_DIR/include` and taglib libraries
101+
at `$TAGLIB_DIR/lib`. To run taglib-ruby with non-standard taglib
102+
installations, use the `LD_LIBRARY_PATH` env. variable.
103+
98104
### Workflow
99105

100106
* Check out the latest master to make sure the feature hasn't been

ext/extconf_common.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ def error msg
2020
abort
2121
end
2222

23-
dir_config('tag')
23+
if ENV.has_key?('TAGLIB_DIR') and !File.directory?(ENV['TAGLIB_DIR'])
24+
error "When defined, the TAGLIB_DIR environment variable must point to a valid directory."
25+
end
26+
27+
# If specified, use the TAGLIB_DIR environment variable as the prefix
28+
# for finding taglib headers and libs. See MakeMakefile#dir_config
29+
# for more details.
30+
dir_config('tag', (ENV['TAGLIB_DIR'] if ENV.has_key?('TAGLIB_DIR')))
2431

2532
# When compiling statically, -lstdc++ would make the resulting .so to
2633
# have a dependency on an external libstdc++ instead of the static one.

tasks/swig.rake

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
# Tasks for generating SWIG wrappers in ext
22

3+
# Execute SWIG for the specified extension.
4+
# Arguments:
5+
# mod:: The name of the SWIG wrapper to process.
6+
#
7+
# If the TAGLIB_DIR environment variable points to a directory,
8+
# $TAGLIB_DIR/include will be searched first for taglib headers.
39
def run_swig(mod)
410
swig = `which swig`.chomp
511
if swig.empty?
612
swig = `which swig2.0`.chomp
713
end
8-
sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} -I/usr/local/include -I/usr/include #{mod}.i"
14+
15+
# Standard search location for headers
16+
include_args = %w{-I/usr/local/include -I/usr/include}
17+
18+
if ENV.has_key?('TAGLIB_DIR')
19+
unless File.directory?(ENV['TAGLIB_DIR'])
20+
abort "When defined, the TAGLIB_DIR environment variable must point to a valid directory."
21+
end
22+
23+
# Push it in front to get it searched first.
24+
include_args.unshift('-I' + ENV['TAGLIB_DIR'] + '/include')
25+
end
26+
27+
sh "cd ext/#{mod} && #{swig} -c++ -ruby -autorename -initname #{mod} #{include_args.join(' ')} #{mod}.i"
928
end
1029

1130
task :swig =>

0 commit comments

Comments
 (0)