(use files) (define libcrypt-presence-checker #< int main (void) { return crypt("foo", "bar") != NULL; } EOF ) (delete-file* "crypt-features") (define known-hash-types '(blowfish sha512 sha256 md5 des-extended des)) (define *compile-features* '()) (cond ((get-environment-variable "FORCE_CRYPT_HASHTYPES") => (lambda (f) (let* ((forced-types (with-input-from-string f read-file)) (supported-features (filter (lambda (x) (member x known-hash-types)) forced-types)) (features (map (lambda (h) (string->symbol (conc 'crypt-native- h))) supported-features))) (print "\n==============================================================") (print "Using forced native hash types:") (print features) (print "==============================================================\n") (set! *compile-features* features)))) ((feature? 'cross-chicken) (print "\n================================================================") (print "Looks like you're cross-compiling and didn't force any hash types.") (print "All hashing implementations will be provided by the egg.") (print "This is okay, but if you want full control you can abort the") (print "installation, and run chicken-install again with the ") (print "FORCE_CRYPT_HASHTYPES environment variable set to the natively") (print "supported hash types on the target system. You can choose from:\n") (pp known-hash-types) (print "================================================================\n")) ((try-compile libcrypt-presence-checker ldflags: "-lcrypt") (compile -L -lcrypt detect-native-crypt-features.scm) (run (./detect-native-crypt-features)) (let ((features (with-input-from-file "crypt-features" read))) ;; Useful for debugging (print "\n================================================================") (print "Detected support for the following hash types in system crypt():") (print features) (print "================================================================\n") (set! *compile-features* features))) (else (print "\n===============================================================") (print "NOTE: Your system does not have a native crypt() at all.") (print "All hashing implementations will be provided by the egg.") (print "===============================================================\n"))) (let* ((feature-flags (intersperse *compile-features* '-feature)) (flags (if (null? feature-flags) '() `(-feature has-native-crypt -feature ,@feature-flags)))) (compile -s -O2 crypt.scm -L -lcrypt ,@flags -j crypt)) (compile -s -O2 crypt.import.scm) (install-extension 'crypt '("crypt.so" "crypt.import.so") `((version 0.3)))