Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions ext/filemagic/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
require 'mkmf'

HEADER_DIRS = [
'/opt/local/include', # MacPorts
'/usr/local/include', # compiled from source and Homebrew
'/opt/homebrew/include', # compiled from source and Homebrew (ARM based Macs)
'/usr/include', # system
]

LIB_DIRS = [
'/opt/local/lib', # MacPorts
'/usr/local/lib', # compiled from source and Homebrew
'/opt/homebrew/lib', # compiled from source and Homebrew (ARM based Macs)
'/usr/lib', # system
]

$CFLAGS << ' -Wall' if ENV['WALL']
$LDFLAGS << ' -static-libgcc' if RUBY_PLATFORM =~ /cygwin|mingw|mswin/

dir_config('magic', HEADER_DIRS, LIB_DIRS)
dir_config('gnurx', HEADER_DIRS, LIB_DIRS)

have_library('gnurx')
dir_config('magic')
dir_config('gnurx')

if have_library('magic', 'magic_open') && have_header('magic.h')
have_func('magic_version')
have_header('file/patchlevel.h')
create_makefile('filemagic/ruby_filemagic')
if have_library('magic', 'magic_open')
if have_header('magic.h')
have_library('gnurx')
have_func('magic_version')
have_header('file/patchlevel.h')
create_makefile('filemagic/ruby_filemagic')
else
abort '*** ERROR: missing magic.h (required to compile this module)'
end
else
abort '*** ERROR: missing required library to compile this module'
abort '*** ERROR: missing magic library (required to build this module)'
end