Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Commit

Permalink
Clean up configure.ac, and be more strict about errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eklitzke committed Mar 20, 2018
1 parent 8fc8eb9 commit cf6c259
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -19,3 +19,5 @@ configure
config.h
stamp-h1
\.test_env/
libtool.m4
lt*.m4
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -30,7 +30,7 @@ install:
# use an explicit /usr/bin path when running the tests.
script:
- ./autogen.sh
- ./configure
- ./configure --disable-silent-rules --enable-werror
- make $MAKEOPTS
- file ./src/pyflame
- ./runtests.sh -v /usr/bin/"${PYVERSION}"
54 changes: 42 additions & 12 deletions configure.ac
Expand Up @@ -14,10 +14,12 @@ AS_CASE([$host_os],
[linux-gnu*], [],
[AC_MSG_ERROR([Pyflame can only be built for Linux hosts])])

enable_threads=no
AS_IF([test x"$host_cpu" = xx86_64],
[AC_MSG_NOTICE([x86-64 system, threads will be supported])
AC_DEFINE([ENABLE_THREADS], [1], [Threads are enabled.])
AC_DEFINE([USE_ELF64], [1], [Expect 64-bit ELF symbols.])
enable_threads=yes;
],
[AC_MSG_NOTICE([Threading support will be disabled (only works on x86-64)])
AC_DEFINE([ENABLE_THREADS], [0], [Threads are enabled.])
Expand All @@ -26,7 +28,10 @@ AS_IF([test x"$host_cpu" = xx86_64],

AC_DEFINE_UNQUOTED([HOST_CPU], ["$host_cpu"], [CPU of target architecture.])

AM_INIT_AUTOMAKE([dist-bzip2 foreign subdir-objects -Wall -Werror])
AM_INIT_AUTOMAKE([dist-bzip2 foreign subdir-objects])

dnl make the compilation flags quiet unless V=1 is used
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

# Checks for programs.
AC_PROG_CXX
Expand All @@ -44,26 +49,35 @@ LT_INIT
# Ensure Linux kernel headers are present
AC_CHECK_HEADERS([linux/ptrace.h], [], [AC_MSG_ERROR([Linux kernel headers missing])])

AC_LANG([C++])
AC_LANG_PUSH([C++])

# This is commented out because it doesn't work right on Ubuntu 12.04 (Precise)
# AX_CXX_COMPILE_STDCXX_11
# Minimum C++ version is C++11
AX_CHECK_COMPILE_FLAG(["-std=c++11"],
[AX_APPEND_FLAG(["-std=c++11"], [CXXFLAGS])],
[AX_CHECK_COMPILE_FLAG(["-std=c++0x"],
[AX_APPEND_FLAG(["-std=c++0x"], [CXXFLAGS])],
[AC_MSG_ERROR([failed to detect C++11 support])])])
[AC_MSG_ERROR([failed to detect C++11 support])])

# Yes please.
AX_APPEND_COMPILE_FLAGS([-Wall], [CXXFLAGS])

# Turn warnings into errors
AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--enable-werror],
[Treat certain compiler warnings as errors (default is no)])],
[enable_werror=$enableval],
[enable_werror=no])

AX_CHECK_COMPILE_FLAG([-Wall],
[AX_APPEND_FLAG([-Wall], [CXXFLAGS])])
if test "x$enable_werror" = "xyes"; then
AX_APPEND_COMPILE_FLAGS([-Werror], [CXXFLAGS])
fi

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([fcntl.h limits.h unistd.h])
AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
Expand All @@ -86,15 +100,18 @@ AC_DEFINE_UNQUOTED(
["$versionstr"],
[A string containing build information.])

enable_py26=no
PKG_CHECK_MODULES([PY26], [python2], [enable_py26="yes"], [AC_MSG_WARN([Building without Python 2.6/2.7 support])])
AM_CONDITIONAL([ENABLE_PY26], [test x"$enable_py26" = xyes])
AM_COND_IF([ENABLE_PY26], [AC_DEFINE([ENABLE_PY26], [1], [Python 2.6/2.7 will be enabled])])

enable_py34=no
PKG_CHECK_MODULES([PY34], [python-3.4], [enable_py34="yes"],
[PKG_CHECK_MODULES([PY34], [python-3.5], [enable_py34="yes"], [AC_MSG_WARN([Building without Python 3.4/3.5 support])])])
AM_CONDITIONAL([ENABLE_PY34], [test x"$enable_py34" = xyes])
AM_COND_IF([ENABLE_PY34], [AC_DEFINE([ENABLE_PY34], [1], [Python 3.4/3.5 will be enabled])])

enable_py36=no
PKG_CHECK_MODULES([PY36], [python-3.6], [enable_py36="yes"], [AC_MSG_WARN([Building without Python 3.6 support])])
AM_CONDITIONAL([ENABLE_PY36], [test x"$enable_py36" = xyes])
AM_COND_IF([ENABLE_PY36], [AC_DEFINE([ENABLE_PY36], [1], [Python 3.6 will be enabled])])
Expand All @@ -104,6 +121,19 @@ AS_IF([test x"$enable_py26" = xyes -o x"$enable_py34" = xyes -o x"$enable_py36"
[AC_MSG_ERROR([Failed to find a supported Python.h])]
)

AC_CONFIG_FILES([Makefile
src/Makefile])
AC_LANG_POP

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

echo
echo "Options used to compile and link:"
echo
echo " with threads = $enable_threads"
echo " with Python 2.6/7 = $enable_py26"
echo " with Python 3.4/5 = $enable_py34"
echo " with Python 3.6+ = $enable_py36"
echo
echo " CXX = $CXX"
echo " CXXFLAGS = $CXXFLAGS"
echo
2 changes: 0 additions & 2 deletions m4/.gitignore

This file was deleted.

67 changes: 67 additions & 0 deletions m4/ax_append_compile_flags.m4
@@ -0,0 +1,67 @@
# ============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
# ============================================================================
#
# SYNOPSIS
#
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. During the check the flag is always added to the
# current language's flags.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
# AX_APPEND_LINK_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.

#serial 6

AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
done
])dnl AX_APPEND_COMPILE_FLAGS
37 changes: 37 additions & 0 deletions m4/ax_require_defined.m4
@@ -0,0 +1,37 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_REQUIRE_DEFINED(MACRO)
#
# DESCRIPTION
#
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
# been defined and thus are available for use. This avoids random issues
# where a macro isn't expanded. Instead the configure script emits a
# non-fatal:
#
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
#
# It's like AC_REQUIRE except it doesn't expand the required macro.
#
# Here's an example:
#
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
#
# LICENSE
#
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 2

AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
])dnl AX_REQUIRE_DEFINED
14 changes: 7 additions & 7 deletions src/frob.cc
Expand Up @@ -16,6 +16,13 @@
// frob3.cc, which define PYFLAME_PY_VERSION. Since Makefile.am for more
// information.

#include <Python.h>
#include <frameobject.h>

#if PYFLAME_PY_VERSION >= 34
#include <unicodeobject.h>
#endif

#include <sys/types.h>
#include <algorithm>
#include <cstddef>
Expand All @@ -25,13 +32,6 @@
#include <sstream>
#include <string>

#include <Python.h>
#include <frameobject.h>

#if PYFLAME_PY_VERSION >= 34
#include <unicodeobject.h>
#endif

#include "./config.h"
#include "./exc.h"
#include "./ptrace.h"
Expand Down

0 comments on commit cf6c259

Please sign in to comment.