11# frozen-string-literal: true
22
3- # Default opt dirs to help mkmf find taglib
4- opt_dirs = [ '/usr/local' , '/opt/local' , '/sw' ]
5-
6- # Heroku vendor dir
7- vendor = ENV . fetch ( 'GEM_HOME' , '' ) [ /^[^ ]*\/ vendor\/ / ]
8- opt_dirs << "#{ vendor } taglib" if vendor
9- opt_dirs_joined = opt_dirs . join ( ':' )
10-
11- configure_args = "--with-opt-dir=#{ opt_dirs_joined } "
12- ENV [ 'CONFIGURE_ARGS' ] = configure_args + ENV . fetch ( 'CONFIGURE_ARGS' , '' )
3+ taglib_dir = ENV [ 'TAGLIB_DIR' ]
4+
5+ unless taglib_dir
6+ # Default opt dirs to help mkmf find taglib
7+ opt_dirs = [ '/usr/local' , '/opt/local' , '/sw' ]
8+
9+ # Heroku vendor dir
10+ vendor = ENV . fetch ( 'GEM_HOME' , '' ) [ /^[^ ]*\/ vendor\/ / ]
11+ opt_dirs << "#{ vendor } taglib" if vendor
12+ opt_dirs_joined = opt_dirs . join ( ':' )
13+
14+ configure_args = "--with-opt-dir=#{ opt_dirs_joined } "
15+ ENV [ 'CONFIGURE_ARGS' ] = configure_args + ENV . fetch ( 'CONFIGURE_ARGS' , '' )
16+ end
1317
1418require 'mkmf'
1519
@@ -18,14 +22,14 @@ def error(msg)
1822 abort
1923end
2024
21- if ENV . key? ( 'TAGLIB_DIR' ) && !File . directory? ( ENV [ 'TAGLIB_DIR' ] )
25+ if taglib_dir && !File . directory? ( taglib_dir )
2226 error 'When defined, the TAGLIB_DIR environment variable must point to a valid directory.'
2327end
2428
2529# If specified, use the TAGLIB_DIR environment variable as the prefix
2630# for finding taglib headers and libs. See MakeMakefile#dir_config
2731# for more details.
28- dir_config ( 'tag' , ( ENV [ 'TAGLIB_DIR' ] if ENV . key? ( 'TAGLIB_DIR' ) ) )
32+ dir_config ( 'tag' , taglib_dir )
2933
3034# When compiling statically, -lstdc++ would make the resulting .so to
3135# have a dependency on an external libstdc++ instead of the static one.
@@ -46,5 +50,10 @@ def error(msg)
4650
4751$CFLAGS << ' -DSWIG_TYPE_TABLE=taglib'
4852
53+ # TagLib 2.0 requires C++17. Some compilers default to an older standard
54+ # so we add this '-std=' option to make sure the compiler accepts C++17
55+ # code.
56+ $CXXFLAGS << ' -std=c++17'
57+
4958# Allow users to override the Ruby runtime's preferred CXX
5059RbConfig ::MAKEFILE_CONFIG [ 'CXX' ] = ENV [ 'TAGLIB_RUBY_CXX' ] if ENV [ 'TAGLIB_RUBY_CXX' ]
0 commit comments