module AutoconfDerived def rcFindInstall printf 'Looking for BSD compatible install utility... '; if !$settings.cache['install_prog'].is_a?(NilClass) $settings.subst_vars['INSTALL']=$settings.cache['install_prog']; printf '(cached) '; elsif !ENV['INSTALL'].is_a?(String) || ENV['INSTALL'].empty? $settings.subst_vars['INSTALL']='/usr/bin/install -c'; else $settings.subst_vars['INSTALL']=ENV['INSTALL']; end # Cache the base program $settings.cache['install_prog']=$settings.subst_vars['INSTALL']; # subst the rest as usual $settings.subst_vars['INSTALL_DATA']=$settings.subst_vars['INSTALL'] + ' -m 644'; $settings.subst_vars['INSTALL_SCRIPT']=$settings.subst_vars['INSTALL']; $settings.subst_vars['INSTALL_PROGRAM']=$settings.subst_vars['INSTALL']; print $settings.subst_vars['INSTALL'] + "\n"; end # Checks for a library # You pash it a hash: # key = library to look for # value = an array dependencies (so they can be ordered properly) def rcCheckLibrary (l) l.each { |key, val| printf 'Looking for lib%s (depends on: ', key; val.each {|v| printf ' lib%s', v; } printf "). didn't check.\n"; } end # Check for a function f in library l with dependencies d # l and d are arrays # if l is an array it will go looking for f in each element of l # stopping at the first one it finds # if d is specified it will first try without and then with for each element of l # if l is a string, it's just one lib to look at # if l is nil, it assumes the function should be in libc def rcCheckFunction(f,l=nil,d=nil) end # Check for the presence of a header, or multiple headers delimited with spaces # you can specify C++ by setting the lang argument to C++. def rcCheckHeader (h, lang='C') h.split(' ').each { |cur_h| printf 'Looking for (%s) %s... ', lang, cur_h; test_head = String.new (nil.to_s) if !$settings.cache['have_header_stdio.h'].is_a?(NilClass) && $settings.cache['have_header_stdio.h'] != 'no' test_head = test_head + "\n#include \n"; end if !$settings.cache['have_header_sys/types.h'].is_a?(NilClass) && $settings.cache['have_header_sys/types.h'] != 'no' test_head = test_head + "\n#include \n"; end if !$settings.cache['have_header_sys/stat.h'].is_a?(NilClass) && $settings.cache['have_header_sys/stat.h'] != 'no' test_head = test_head + "\n#include \n"; end if !$settings.cache['have_header_stdlib.h'].is_a?(NilClass) && $settings.cache['have_header_stdlib.h'] != 'no' test_head = test_head + "\n#include \n"; end if $pre_headers && !$settings.cache['have_header_stddef.h'].is_a?(NilClass) && $settings.cache['have_header_stddef.h'] != 'no' test_head = test_head + "\n#include \n"; end if $pre_headers && !$settings.cache['have_header_strings.h'].is_a?(NilClass) && $settings.cache['have_header_strings.h'] != 'no' test_head = test_head + "\n#include \n"; end if $pre_headers && !$settings.cache['have_header_inttypes.h'].is_a?(NilClass) && $settings.cache['have_header_inttypes.h'] != 'no' test_head = test_head + "\n#include \n"; end if $pre_headers && !$settings.cache['have_header_stdint.h'].is_a?(NilClass) && $settings.cache['have_header_stdint.h'] != 'no' test_head = test_head + "\n#include \n"; end if $pre_headers && !$settings.cache['have_header_unistd.h'].is_a?(NilClass) && $settings.cache['have_header_unistd.h'] != 'no' test_head = test_head + "\n#include \n"; end #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif test_prog = sprintf("\n#include <%s>\n\nint main()\n{\n\treturn 0;\n}\n", cur_h) if $dump_test_prog $stderr.puts test_prog; end cache_string = sprintf('have_header_%s', cur_h) if $settings.cache[cache_string] print '(cached) '; else retval=$settings.languages[lang].run_compiler(test_prog); if retval != 0 puts 'no'; printf 'Looking for (%s) %s again... ', lang, cur_h; test_prog = sprintf("%s\n#include <%s>\n\nint main()\n{\n\treturn 0;\n}\n", test_head, cur_h) retval=$settings.languages[lang].run_compiler(test_prog); if retval != 0 $settings.cache[cache_string] = 'no'; else $settings.cache[cache_string] = 'yes'; end else $settings.cache[cache_string] = 'yes'; end end if $settings.cache[cache_string] == 'no' printf "nope\n"; else printf "%s\n", cur_h; end } end # From GNU Autoconf, here's what we aim to do: # check for stdlib.h, stdarg.h, string.h, float.h # check for the text "memchr" in string.h, because SunOS 4.x doesn't declare memchr there this # check for the text "free" in stdlib.h, ISC 2.0.2 doesn't do this # check for proper ctype macros because /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. # For now I'm only doing the first one since, well, I'm lazy. def rcCheckANSICHeaders test_prog = ' #include #include #include #include int main() { return 0; } '; print 'ANSI compliant headers... '; if $settings.cache['check_ansi_headers'] print '(cached) '; else retval=$settings.languages['C'].run_compiler(test_prog); if retval != 0 $settings.cache['check_ansi_headers'] = 'no'; else $settings.cache['check_ansi_headers'] = 'yes'; end end #$pc_define_vars{STDC_HEADERS} = ($pc_cache_vars{check_ansi_headers} eq 'yes') ? 1 : undef; if $settings.cache['check_ansi_headers'] == 'no' printf "nope\n"; else printf "located, 10-4 good buddy.\n"; end end end include AutoconfDerived;