From 61c2c18e6f122aba1b90dc1396f5bd53b31c4e4c Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Tue, 11 Jun 2019 20:04:17 +0500 Subject: [PATCH] Improve "ext/digest/extconf.rb" --- ext/digest/extconf.rb | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) mode change 100644 => 100755 ext/digest/extconf.rb diff --git a/ext/digest/extconf.rb b/ext/digest/extconf.rb old mode 100644 new mode 100755 index 0c2714a..d8b7715 --- a/ext/digest/extconf.rb +++ b/ext/digest/extconf.rb @@ -1,9 +1,26 @@ +#!/usr/bin/env ruby # frozen_string_literal: true require 'mkmf' -have_header('ruby/digest.h') -have_func('rb_str_set_len') +def cflags(*args) + args.each do |str| + $CFLAGS += " #{str.shellescape} " + end +end -$CFLAGS << " -fvisibility=hidden" -create_makefile('digest/keccak') +def have_header!(*args) + exit 1 unless have_header(*args) +end + +def have_func!(header, *args) + exit 1 unless have_func(*args, header) +end + +cflags '-fvisibility=hidden' + +have_header! 'ruby/digest.h' + +have_func! 'rb_str_set_len' + +create_makefile 'digest/keccak' or exit 1