vsf_findlibs.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. # Cheesy hacky location of additional link libraries.
  3. locate_library() { [ ! "$1*" = "`echo $1*`" ]; }
  4. find_func() { egrep $1 $2 >/dev/null; }
  5. if find_func hosts_access tcpwrap.o; then
  6. echo "-lwrap";
  7. locate_library /lib/libnsl.so && echo "-lnsl";
  8. locate_library /lib64/libnsl.so && echo "-lnsl";
  9. fi
  10. # Look for PAM (done weirdly due to distribution bugs (e.g. Debian) or the
  11. # crypt library.
  12. if find_func pam_start sysdeputil.o; then
  13. locate_library /lib/libpam.so.0 && echo "/lib/libpam.so.0";
  14. locate_library /usr/lib/libpam.so && echo "-lpam";
  15. locate_library /usr/lib64/libpam.so && echo "-lpam";
  16. locate_library /lib/x86_64-linux-gnu/libpam.so.0 && echo "-lpam";
  17. # HP-UX ends shared libraries with .sl
  18. locate_library /usr/lib/libpam.sl && echo "-lpam";
  19. # AIX ends shared libraries with .a
  20. locate_library /usr/lib/libpam.a && echo "-lpam";
  21. else
  22. locate_library /lib/libcrypt.so && echo "-lcrypt";
  23. locate_library /usr/lib/libcrypt.so && echo "-lcrypt";
  24. locate_library /usr/lib64/libcrypt.so && echo "-lcrypt";
  25. locate_library /lib/x86_64-linux-gnu/libcrypt.so && echo "-lcrypt";
  26. fi
  27. # Look for the dynamic linker library. Needed by older RedHat when
  28. # you link in PAM
  29. locate_library /lib/libdl.so && echo "-ldl";
  30. # Look for libsocket. Solaris needs this.
  31. locate_library /lib/libsocket.so && echo "-lsocket";
  32. # Look for libnsl. Solaris needs this.
  33. locate_library /lib/libnsl.so && echo "-lnsl";
  34. # Look for libresolv. Solaris needs this.
  35. locate_library /lib/libresolv.so && echo "-lresolv";
  36. # Look for libutil. Older FreeBSD need this for setproctitle().
  37. locate_library /usr/lib/libutil.so && echo "-lutil";
  38. # For older HP-UX...
  39. locate_library /usr/lib/libsec.sl && echo "-lsec";
  40. # Look for libcap (capabilities)
  41. if locate_library /lib/libcap.so.1; then
  42. echo "/lib/libcap.so.1";
  43. elif locate_library /lib/libcap.so.2; then
  44. echo "/lib/libcap.so.2";
  45. else
  46. locate_library /usr/lib/libcap.so && echo "-lcap";
  47. locate_library /lib/libcap.so && echo "-lcap";
  48. locate_library /lib64/libcap.so && echo "-lcap";
  49. fi
  50. # Solaris needs this for nanosleep()..
  51. locate_library /lib/libposix4.so && echo "-lposix4";
  52. locate_library /usr/lib/libposix4.so && echo "-lposix4";
  53. # Tru64 (nanosleep)
  54. locate_library /usr/shlib/librt.so && echo "-lrt";
  55. # Solaris sendfile
  56. locate_library /usr/lib/libsendfile.so && echo "-lsendfile";
  57. # OpenSSL
  58. if find_func SSL_library_init ssl.o; then
  59. echo "-lssl -lcrypto";
  60. fi
  61. exit 0;