]> git.ipfire.org Git - thirdparty/pdns.git/blame - m4/pdns_pie.m4
Merge pull request #9073 from pieterlexis/runtime-dirs-virtual-hosting
[thirdparty/pdns.git] / m4 / pdns_pie.m4
CommitLineData
d6e5e940
AT
1dnl
2dnl Check for support for position independent executables
3dnl
4dnl Copyright (C) 2013 Red Hat, Inc.
5dnl
6dnl This library is free software; you can redistribute it and/or
7dnl modify it under the terms of the GNU Lesser General Public
8dnl License as published by the Free Software Foundation; either
9dnl version 2.1 of the License, or (at your option) any later version.
10dnl
11dnl This library is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14dnl Lesser General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU Lesser General Public
17dnl License along with this library. If not, see
18dnl <http://www.gnu.org/licenses/>.
19dnl
20
21AC_DEFUN([AC_CC_PIE],[
f5f2cb87 22 AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
d6e5e940
AT
23 PIE_CFLAGS=
24 PIE_LDFLAGS=
f2a87945 25 OLD_CXXFLAGS=$CXXFLAGS
d6e5e940
AT
26 case "$host" in
27 *-*-mingw* | *-*-msvc* | *-*-cygwin* )
28 ;; dnl All code is position independent on Win32 target
29 *)
4586bf7a 30 CXXFLAGS="-fPIE -DPIE"
5079ae92 31 gl_COMPILER_OPTION_IF([-pie], [
4586bf7a 32 PIE_CFLAGS="-fPIE -DPIE"
5079ae92
RK
33 PIE_LDFLAGS="-pie"
34 ], [
35 dnl some versions of clang require -Wl,-pie instead of -pie
1e0ac621 36 gl_COMPILER_OPTION_IF([[-Wl,-pie]], [
4586bf7a 37 PIE_CFLAGS="-fPIE -DPIE"
5079ae92 38 PIE_LDFLAGS="-Wl,-pie"
3eb3186e 39 ], [],
3bcfbffc
RK
40 [AC_LANG_PROGRAM([[
41#include <pthread.h>
42__thread unsigned int t_id;
43 ]], [[t_id = 1;]])]
3eb3186e
RK
44 )
45 ],
3bcfbffc
RK
46 [AC_LANG_PROGRAM([[
47#include <pthread.h>
48__thread unsigned int t_id;
49 ]], [[t_id = 1;]])]
dced89b1 50 )
d6e5e940 51 esac
f2a87945 52 CXXFLAGS=$OLD_CXXFLAGS
d6e5e940
AT
53 AC_SUBST([PIE_CFLAGS])
54 AC_SUBST([PIE_LDFLAGS])
55])