summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac82
1 files changed, 77 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 535aac9..7342276 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,8 @@
AC_INIT(gwm, 0.0, gtw@gnu.org)
+AC_PREREQ([2.60])
AC_CONFIG_SRCDIR(gwm.c)
AM_INIT_AUTOMAKE
-AC_CONFIG_FILES(Makefile)
+AC_CONFIG_FILES(Makefile gwm.ld)
AC_CONFIG_HEADERS(config.h)
if test -f config.options; then
@@ -42,7 +43,6 @@ AC_DEFUN([GWM_OPTIONAL_PACKAGE],[
fi
])
-AC_DEFINE(_GNU_SOURCE, 1, [Enable GNU extensions on systems that have them.])
AH_BOTTOM([/* If we haven't been told that we're debugging, assume we aren't. */
#ifndef DEBUG
#define NDEBUG 1
@@ -50,6 +50,7 @@ AH_BOTTOM([/* If we haven't been told that we're debugging, assume we aren't. */
# Checks for programs:
AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
PKG_PROG_PKG_CONFIG
# Checks for libraries:
@@ -79,7 +80,7 @@ AM_CONDITIONAL(RENDER, [test x$gwm_found_render = xyes])
AC_SEARCH_LIBS(iconv, iconv)
# Checks for header files:
-AC_CHECK_HEADERS(iconv.h mcheck.h poll.h)
+AC_CHECK_HEADERS(iconv.h mcheck.h sys/mman.h poll.h sys/param.h)
# Checks for types:
AC_TYPE_UINT64_T
@@ -87,8 +88,79 @@ AC_TYPE_UINT64_T
# Checks for functions:
AC_CHECK_FUNCS(iconv mtrace ppoll)
-PKG_CFLAGS=`$PKG_CONFIG --cflags $gwm_packages`
-PKG_LIBS=`$PKG_CONFIG --libs $gwm_packages`
+# Check for a reasonable section alignment to pass to the linker. First,
+# try looking for typical compile-time constants in system header files...
+AC_MSG_CHECKING([linker section alignment])
+gwm_align=512
+gwm_found_align=no
+while test $gwm_align -le 65536; do
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if EXEC_PAGESIZE == ]] $gwm_align [[ || PAGE_SIZE == ]] $gwm_align [[ || PAGESIZE == ]] $gwm_align [[
+int main() { return 0; }
+#else
+Failure.
+#endif
+]])], [gwm_found_align=yes; break], [])
+ gwm_align=$(expr $gwm_align \* 2)
+done
+if test $gwm_found_align = no; then
+ # No luck so far...
+ if test $cross_compiling != yes; then
+ for gwm_prog in pagesize "getconf PAGE_SIZE"; do
+ if $gwm_prog > /dev/null 2>&1; then
+ gwm_align=512
+ gwm_found_align=no
+ while test $gwm_align -le 65536; do
+ if test $($gwm_prog 2> /dev/null) = $gwm_align; then
+ gwm_found_align=yes
+ break
+ fi
+ gwm_align=$(expr $gwm_align \* 2)
+ done
+ if test $gwm_found_align = yes; then break; fi
+ fi
+ done
+ fi
+fi
+if test $gwm_found_align = no; then
+ gwm_align=4096 # complete guess
+fi
+AC_MSG_RESULT([$gwm_align])
+SECTION_ALIGN=$gwm_align
+AC_SUBST(SECTION_ALIGN)
+
+AC_MSG_CHECKING([for linker script support])
+gwm_ldflags="$LDFLAGS"
+LDFLAGS="$LDFLAGS -Wl,-Tconftest.ld"
+cat > conftest.ld <<EOF
+SECTIONS
+{
+ init_start = .;
+ .gwminit.text : { init*(.text ) }
+ .gwminit.rodata : { init*(.rodata ) }
+ init_end = .;
+}
+INSERT AFTER .text;
+EOF
+AC_LINK_IFELSE([AC_LANG_SOURCE([[
+extern char init_start, init_end;
+int main() { (void) ( &init_end - &init_start ); return 0; }
+]])], [gwm_linker_scripts=yes
+ AC_DEFINE(HAVE_INIT_SECTION, 1)
+ AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
+LDFLAGS="$gwm_ldflags"
+AM_CONDITIONAL(LINKER_SCRIPTS, [test x$gwm_linker_scripts = xyes])
+AH_TEMPLATE(HAVE_INIT_SECTION,[Define if the linker supports scripts (used to locate the init section).])
+
+PKG_CFLAGS=$($PKG_CONFIG --cflags $gwm_packages)
+PKG_LIBS=$($PKG_CONFIG --libs $gwm_packages)
AC_SUBST(PKG_CFLAGS)
AC_SUBST(PKG_LIBS)