~ubuntu-branches/ubuntu/natty/ntp/natty

« back to all changes in this revision

Viewing changes to m4/ntp_openssl.m4

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-11-30 11:14:31 UTC
  • mfrom: (4.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20101130111431-7r00o0ck9qzwmm9f
Tags: 1:4.2.6.p2+dfsg-1ubuntu1
* Merge from debian unstable, remaining changes are:
  + debian/ntp.conf, debian/ntpdate.default: Change default server to
    ntp.ubuntu.com.
  + debian/ntpdate.ifup: Stop ntp before running ntpdate when an interface
    comes up, then start again afterwards.
  + debian/ntp.init, debian/rules: Only stop when entering single user mode.
  + Add enforcing AppArmor profile (LP: #382905):
    - debian/control: add Conflicts/Replaces on apparmor-profiles <
      2.3.1+1403-0ubuntu10 (since we are now shipping usr.sbin.ntpd) and
      apparmor < 2.3.1+1403-0ubuntu10 (since we are now shipping tunables/ntpd)
    - debian/control: add Suggests on apparmor
    - debian/ntp.dirs: add apparmor directories
    - debian/ntp.preinst: force complain on certain upgrades
    - debian/ntp.postinst: reload apparmor profile
    - debian/ntp.postrm: remove the force-complain file
    - add debian/apparmor-profile*
    - debian/rules: install apparmor-profile and apparmor-profile.tunable
    - debian/README.Debian: add note on AppArmor
  + debian/{control,rules}: add and enable hardened build for PIE
    (Debian bug 542721).
  + debian/apparmor-profile: adjust location of drift files (LP: #456308)
  + debian/rules, debian/ntp.dirs, debian/source_ntp.py: Add apport hook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl ######################################################################
 
2
dnl OpenSSL support shared by top-level and sntp/configure.ac
 
3
AC_DEFUN([NTP_OPENSSL], [
 
4
        
 
5
AC_SUBST(OPENSSL)
 
6
AC_SUBST(OPENSSL_INC)
 
7
AC_SUBST(OPENSSL_LIB)
 
8
 
 
9
AC_MSG_CHECKING([for openssl library directory])
 
10
AC_ARG_WITH(openssl-libdir,
 
11
        AC_HELP_STRING([--with-openssl-libdir], [+ =/something/reasonable]),
 
12
[ans=$withval],
 
13
[case "$build" in
 
14
 $host) ans=yes ;;
 
15
 *)     ans=no ;;
 
16
esac])
 
17
case "$ans" in
 
18
 no) ;;
 
19
 yes) # Look in:
 
20
    ans="/usr/lib /usr/lib/openssl /usr/sfw/lib /usr/local/lib /usr/local/ssl/lib /lib"
 
21
    ;;
 
22
 *) # Look where they said
 
23
    ;;
 
24
esac
 
25
case "$ans" in
 
26
 no) ;;
 
27
 *) # Look for libcrypto.a and libssl.a:
 
28
    for i in $ans no
 
29
    do
 
30
        case "$host" in
 
31
         *-*-darwin*)
 
32
            test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
 
33
            ;;
 
34
         *)
 
35
            test -f $i/libcrypto.so -a -f $i/libssl.so && break
 
36
            test -f $i/libcrypto.a -a -f $i/libssl.a && break
 
37
            ;;
 
38
        esac
 
39
    done
 
40
    case "$i" in
 
41
     no)
 
42
        ans=no
 
43
        OPENSSL_LIB=
 
44
        ;;
 
45
     *) ans=$i
 
46
        OPENSSL_LIB=$ans
 
47
        ;;
 
48
    esac
 
49
    ;;
 
50
esac
 
51
AC_MSG_RESULT([$ans])
 
52
 
 
53
AC_MSG_CHECKING([for openssl include directory])
 
54
AC_ARG_WITH(openssl-incdir,
 
55
        AC_HELP_STRING([--with-openssl-incdir], [+ =/something/reasonable]),
 
56
[ans=$withval],
 
57
[case "$build" in
 
58
 $host) ans=yes ;;
 
59
 *)     ans=no ;;
 
60
esac])
 
61
case "$ans" in
 
62
 no) ;;
 
63
 yes) # look in:
 
64
    ans="/usr/include /usr/sfw/include /usr/local/include /usr/local/ssl/include"
 
65
    ;;
 
66
 *) # Look where they said
 
67
    ;;
 
68
esac
 
69
case "$ans" in
 
70
 no) ;;
 
71
 *) # look for openssl/opensslconf.h:
 
72
    for i in $ans no
 
73
    do
 
74
        test -f $i/openssl/opensslconf.h && break
 
75
    done
 
76
    case "$i" in
 
77
     no)
 
78
        ans=no
 
79
        OPENSSL_INC=
 
80
        ;;
 
81
     *) ans=$i
 
82
        OPENSSL_INC=$ans
 
83
        ;;
 
84
    esac
 
85
    ;;
 
86
esac
 
87
AC_MSG_RESULT([$ans])
 
88
 
 
89
AC_MSG_CHECKING([if we will use crypto])
 
90
AC_ARG_WITH(crypto,
 
91
        AC_HELP_STRING([--with-crypto], [+ =openssl]),
 
92
[ans=$withval], [ans=yes])
 
93
case "$ans" in
 
94
 no)
 
95
    ;;
 
96
 yes|openssl)
 
97
    if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INC"
 
98
    then
 
99
        ans=no
 
100
    else
 
101
        ans=yes
 
102
    fi
 
103
esac
 
104
ntp_openssl=$ans
 
105
AC_MSG_RESULT([$ans])
 
106
 
 
107
case "$ntp_openssl" in
 
108
 yes)
 
109
    # We have OpenSSL inc/lib - use them.
 
110
    CPPFLAGS="$CPPFLAGS -I$OPENSSL_INC"
 
111
    LDFLAGS="$LDFLAGS -L$OPENSSL_LIB"
 
112
    case "$need_dash_r" in
 
113
     1) LDFLAGS="$LDFLAGS -R$OPENSSL_LIB"
 
114
    esac
 
115
    AC_SUBST(LCRYPTO, [-lcrypto])
 
116
    AC_DEFINE(OPENSSL, , [Use OpenSSL?])
 
117
esac
 
118
 
 
119
#
 
120
# Older OpenSSL headers have a number of callback prototypes inside
 
121
# other function prototypes which trigger copious warnings with gcc's
 
122
# -Wstrict-prototypes, which is included in -Wall.
 
123
#
 
124
# An example:
 
125
#
 
126
# int i2d_RSA_NET(const RSA *a, unsigned char **pp, 
 
127
#                 int (*cb)(), int sgckey);
 
128
#                 ^^^^^^^^^^^
 
129
#
 
130
 
131
#
 
132
openssl_triggers_warnings=unknown
 
133
SAVED_CFLAGS="$CFLAGS"
 
134
 
 
135
case "$GCC$ntp_openssl" in
 
136
 yesyes)
 
137
    CFLAGS="$CFLAGS -Werror"
 
138
    AC_COMPILE_IFELSE(
 
139
        AC_LANG_SOURCE([[ /* see if -Werror breaks gcc */ ]]),
 
140
        [gcc_handles_Werror=yes],
 
141
        [gcc_handles_Werror=no]
 
142
    )
 
143
    case "$gcc_handles_Werror" in
 
144
     no)
 
145
        # if this gcc doesn't do -Werror go ahead and use
 
146
        # -Wstrict-prototypes.
 
147
        openssl_triggers_warnings=yes
 
148
        ;;
 
149
     yes)
 
150
        CFLAGS="$CFLAGS -Wstrict-prototypes"
 
151
        AC_COMPILE_IFELSE(
 
152
            AC_LANG_PROGRAM(
 
153
                [[
 
154
                    #include "openssl/asn1_mac.h"
 
155
                    #include "openssl/bn.h"
 
156
                    #include "openssl/err.h"
 
157
                    #include "openssl/evp.h"
 
158
                    #include "openssl/pem.h"
 
159
                    #include "openssl/rand.h"
 
160
                    #include "openssl/x509v3.h"
 
161
                ]],
 
162
                [[ /* empty body */ ]]
 
163
            ),
 
164
            [openssl_triggers_warnings=no],
 
165
            [openssl_triggers_warnings=yes]
 
166
        )
 
167
    esac
 
168
    case "$openssl_triggers_warnings" in
 
169
     yes)
 
170
        CFLAGS="$SAVED_CFLAGS -Wno-strict-prototypes"
 
171
        ;;
 
172
     *)
 
173
        CFLAGS="$SAVED_CFLAGS -Wstrict-prototypes"
 
174
    esac
 
175
    ;;
 
176
 yesno)
 
177
    # gcc without OpenSSL
 
178
    CFLAGS="$SAVED_CFLAGS -Wstrict-prototypes"
 
179
esac
 
180
 
 
181
])
 
182
dnl ======================================================================