<commit_before>require 'mkmf'

$CFLAGS ||= ''
$LDFLAGS ||= ''

if RUBY_PLATFORM =~ /darwin/
  $LDFLAGS += ' -framework PCSC'
elsif RUBY_PLATFORM =~ /win/
  have_library('winscard')
else
  # pcsc is retarded and uses stuff like '#include <wintypes.h>'
  $CFLAGS += ' -I /usr/include/PCSC -I /usr/local/include/pcsc'
  have_library('pcsclite')
end

pcsc_headers = []
['wintypes.h', 'reader.h', 'winscard.h', 'pcsclite.h'].each do |header|
  ['', 'PCSC/', './pcsc_surrogate_'].each do |path_prefix|
    if have_header(path_prefix + header)
      pcsc_headers.push((path_prefix[0,1] == '.') ? "\"#{path_prefix + header}\"" : "<#{path_prefix + header}>")
      break
    end
  end
end

pcsc_defines = []

File.open('pcsc_autogen.h', 'w') do |f|
  pcsc_defines.each { |d| f.write "\#define #{d}\n" }
  pcsc_headers.each { |h| f.write "\#include #{h}\n" }
end 

create_makefile('smartcard/pcsc')

def win32_hack(mf_name)
  # evil, evil, evil -- hack the makefile to embed the manifest in the extension dll
  make_contents = File.open(mf_name, 'r') { |f| f.read }
  make_rules = make_contents.split(/(\n|\r)(\n|\r)+/)
  new_make_rules = make_rules.map do |rule|
    if rule =~ /^\$\(DLLIB\)\:/
      rule + "\n\tmt.exe -manifest $(@).manifest -outputresource:$(@);2"
    else
      rule
    end
  end
  File.open(mf_name, 'w') { |f| f.write new_make_rules.join("\n\n")}
end

if RUBY_PLATFORM =~ /win/
  win32_hack 'Makefile'
end<commit_msg>Updated extconf.rb 'cause it got broken on osx.<commit_after>require 'mkmf'

$CFLAGS ||= ''
$LDFLAGS ||= ''

if RUBY_PLATFORM =~ /darwin/
  $LDFLAGS += ' -framework PCSC'
elsif RUBY_PLATFORM =~ /win/
  have_library('winscard')
else
  # pcsc is retarded and uses stuff like '#include <wintypes.h>'
  $CFLAGS += ' -I /usr/include/PCSC -I /usr/local/include/pcsc'
  have_library('pcsclite')
end

pcsc_headers = []
['wintypes.h', 'reader.h', 'winscard.h', 'pcsclite.h'].each do |header|
  ['', 'PCSC/', './pcsc_surrogate_'].each do |path_prefix|
    if have_header(path_prefix + header)
      pcsc_headers.push((path_prefix[0,1] == '.') ? "\"#{path_prefix + header}\"" : "<#{path_prefix + header}>")
      break
    end
  end
end

pcsc_defines = []

File.open('pcsc_autogen.h', 'w') do |f|
  pcsc_defines.each { |d| f.write "\#define #{d}\n" }
  pcsc_headers.each { |h| f.write "\#include #{h}\n" }
end 

create_makefile('smartcard/pcsc')

def win32_hack(mf_name)
  # evil, evil, evil -- hack the makefile to embed the manifest in the extension dll
  make_contents = File.open(mf_name, 'r') { |f| f.read }
  make_rules = make_contents.split(/(\n|\r)(\n|\r)+/)
  new_make_rules = make_rules.map do |rule|
    if rule =~ /^\$\(DLLIB\)\:/
      rule + "\n\tmt.exe -manifest $(@).manifest -outputresource:$(@);2"
    else
      rule
    end
  end
  File.open(mf_name, 'w') { |f| f.write new_make_rules.join("\n\n")}
end

case RUBY_PLATFORM
when /darwin/
when /win/
  win32_hack 'Makefile'
end
{'fraction_non_alphanumeric': 0.19170096021947874, 'fraction_numerical': 0.004801097393689987, 'mean_word_length': 3.543613707165109, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2352034', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1182, 'n_words': 253}