summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/date/extconf.rb4
-rw-r--r--lib/mkmf.rb30
3 files changed, 36 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 92c33bb6c4..7d702cc9d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Apr 11 10:59:58 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/mkmf.rb (append_cppflags, append_cflags, append_ldflags):
+ utility methods to append compiler options.
+
Sat Apr 11 08:22:24 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/rdoc/text.rb: removed duplicated code.
diff --git a/ext/date/extconf.rb b/ext/date/extconf.rb
index 6f479eaa26..a0c30fa948 100644
--- a/ext/date/extconf.rb
+++ b/ext/date/extconf.rb
@@ -1,5 +1,3 @@
require 'mkmf'
-if try_cflags("-std=iso9899:1999")
- $CFLAGS += " " << "-std=iso9899:1999"
-end
+append_cflags("-std=iso9899:1999")
create_makefile('date_core')
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 014e7ed53b..8a21666b76 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -613,6 +613,16 @@ MSG
try_header(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
end
+ def append_cppflags(flags, *opts)
+ Array(flags).each do |flag|
+ if checking_for "whether #{flag} is accepted as CPPFLAGS" {
+ try_cppflags(flag, *opts)
+ }
+ $CPPFLAGS << " " << flag
+ end
+ end
+ end
+
def with_cflags(flags)
cflags = $CFLAGS
$CFLAGS = flags
@@ -625,6 +635,16 @@ MSG
try_compile(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
end
+ def append_cflags(flags, *opts)
+ Array(flags).each do |flag|
+ if checking_for "whether #{flag} is accepted as CFLAGS" {
+ try_cflags(flag, *opts)
+ }
+ $CFLAGS << " " << flag
+ end
+ end
+ end
+
def with_ldflags(flags)
ldflags = $LDFLAGS
$LDFLAGS = flags
@@ -637,6 +657,16 @@ MSG
try_link(MAIN_DOES_NOTHING, flags, {:werror => true}.update(opts))
end
+ def append_ldflags(flags, *opts)
+ Array(flags).each do |flag|
+ if checking_for "whether #{flag} is accepted as LDFLAGS" {
+ try_ldflags(flag, *opts)
+ }
+ $LDFLAGS << " " << flag
+ end
+ end
+ end
+
def try_static_assert(expr, headers = nil, opt = "", &b)
headers = cpp_include(headers)
try_compile(<<SRC, opt, &b)