source: project/release/4/crypt/trunk/crypt.setup @ 30605

Last change on this file since 30605 was 30605, checked in by sjamaan, 7 years ago

crypt: Improve message in notice to indicate that -lcrypt may be incorrectly supplied

File size: 3.5 KB
Line 
1;; -*- Scheme -*-
2
3(use files)
4
5(define libcrypt-presence-checker #<<EOF
6#include <unistd.h>
7int main (void) {
8  return crypt("foo", "bar") != NULL;
9}
10EOF
11)
12
13(delete-file* "crypt-features")
14
15(define known-hash-types
16  '(blowfish sha512 sha256 md5 des-extended des))
17
18(define *compile-features* '())
19
20;; OpenBSD is odd: it doesn't have libcrypt, crypt is part of libc
21(define uses-libcrypt
22  (cond ((get-environment-variable "FORCE_CRYPT_USE_LIBCRYPT")
23         => (lambda (f)
24              (or (string-ci=? f "true")
25                  (string-ci=? f "1")
26                  (string-ci=? f "yes"))))
27        (else (cond-expand
28                (openbsd #f)
29                (else #t)))))
30
31(define libcrypt-flags
32  (if uses-libcrypt '(-L -lcrypt) '()))
33
34(cond
35 ((get-environment-variable "FORCE_CRYPT_HASHTYPES") =>
36  (lambda (f)
37    (let* ((forced-types (with-input-from-string f read-file))
38           (supported-features
39            (filter (lambda (x) (member x known-hash-types)) forced-types))
40           (features (map (lambda (h) (string->symbol (conc 'crypt-native- h)))
41                          supported-features)))
42      (print "\n==============================================================")
43      (print "Using forced native hash types:")
44      (print features)
45      (print "==============================================================\n")
46      (set! *compile-features* features))))
47
48 ((feature? 'cross-chicken)
49   (print "\n================================================================")
50   (print "Looks like you're cross-compiling and didn't force any hash types.")
51   (print "All hashing implementations will be provided by the egg.")
52   (print "This is okay, but if you want full control you can abort the")
53   (print "installation, and run chicken-install again with the ")
54   (print "FORCE_CRYPT_HASHTYPES environment variable set to the natively")
55   (print "supported hash types on the target system.  You can choose from:\n")
56   (pp known-hash-types)
57   (print "================================================================\n"))
58 
59 ((try-compile libcrypt-presence-checker
60               cflags: "-D_XOPEN_SOURCE"
61               ldflags: (if uses-libcrypt "-lcrypt" ""))
62  (compile -C -D_XOPEN_SOURCE ,@libcrypt-flags detect-native-crypt-features.scm)
63  (run (./detect-native-crypt-features))
64  (let ((features (with-input-from-file "crypt-features" read)))
65    ;; Useful for debugging
66    (print "\n================================================================")
67    (print "Detected support for the following hash types in system crypt():")
68    (print features)
69    (print "================================================================\n")
70   (set! *compile-features* features)))
71 
72 (else
73   (print "\n==============================================================")
74   (print "NOTE: Your system appears not to have a native crypt() at all!")
75   (print "All hashing implementations will be provided by the egg.")
76   (newline)
77   (print "HINT: Linker flag (-lcrypt) may be wrong, please check this.")
78   (print "If they really are wrong, please consider filing a bugreport.")
79   (print "==============================================================\n")))
80
81(let* ((feature-flags (intersperse *compile-features* '-feature))
82       (flags (if (null? feature-flags)
83                  '()
84                  `(-feature has-native-crypt -feature ,@feature-flags))))
85  (compile -s -O2 crypt.scm ,@libcrypt-flags -C -D_XOPEN_SOURCE ,@flags -j crypt))
86
87(compile -s -O2 crypt.import.scm)
88
89(install-extension
90  'crypt
91  '("crypt.so" "crypt.import.so")
92  `((version 0.5)))
Note: See TracBrowser for help on using the repository browser.