diff options
Diffstat (limited to 'm4')
-rw-r--r-- | m4/efl_attribute.m4 | 83 | ||||
-rw-r--r-- | m4/efl_binary.m4 | 71 | ||||
-rw-r--r-- | m4/efl_compiler.m4 | 90 | ||||
-rw-r--r-- | m4/efl_path_max.m4 | 36 | ||||
-rw-r--r-- | m4/project_init.m4 | 115 |
5 files changed, 395 insertions, 0 deletions
diff --git a/m4/efl_attribute.m4 b/m4/efl_attribute.m4 new file mode 100644 index 0000000..4f31d93 --- /dev/null +++ b/m4/efl_attribute.m4 @@ -0,0 +1,83 @@ +dnl Copyright (C) 2011 Vincent Torri <vtorri at univ-evry dot fr> +dnl That code is public domain and can be freely used or copied. + +dnl Macros for checking if the compiler supports some __attribute__ uses + +dnl Usage: EFL_ATTRIBUTE_VECTOR +dnl call AC_DEFINE for HAVE_GCC_ATTRIBUTE_VECTOR if __attribute__((vector)) is available + +AC_DEFUN([EFL_ATTRIBUTE_VECTOR], +[ +AC_MSG_CHECKING([for __attribute__ ((vector))]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +typedef int v4si __attribute__ ((vector_size (16))); + ]], + [[ +if (sizeof(v4si) == 16) + return 0; +else + return -1; + ]])], + [have_attribute_vector="yes"], + [have_attribute_vector="no"]) +AC_MSG_RESULT([${have_attribute_vector}]) + +if test "x${have_attribute_vector}" = "xyes" ; then + AC_DEFINE([HAVE_GCC_ATTRIBUTE_VECTOR], [1], [Define to 1 if your compiler supports __attribute__ ((vector)).]) +fi +]) + +dnl Usage: EFL_ATTRIBUTE_ALWAYS_INLINE +dnl call AC_DEFINE for alway_inline if __attribute__((always_inline)) is available + +AC_DEFUN([EFL_ATTRIBUTE_ALWAYS_INLINE], +[ + +have_attribute_forceinline="no" + +AC_MSG_CHECKING([for __forceinline]) + +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <windows.h> +static __forceinline void foo(void) {} + ]], + [[ + ]])], + [ + have_attribute_always_inline="yes" + have_attribute_forceinline="yes" + ], + [have_attribute_always_inline="no"]) + +AC_MSG_RESULT([${have_attribute_always_inline}]) + +if test "x${have_attribute_always_inline}" = "xno" ; then + AC_MSG_CHECKING([for __attribute__ ((__always_inline__))]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +static __attribute__((__always_inline__)) inline void foo(void) {} + ]], + [[ + ]])], + [have_attribute_always_inline="yes"], + [have_attribute_always_inline="no"]) + AC_MSG_RESULT([${have_attribute_always_inline}]) +fi + +if test "x${have_attribute_always_inline}" = "xyes" ; then + if test "x${have_attribute_forceinline}" = "xyes" ; then + AC_DEFINE([EFL_ALWAYS_INLINE], [__forceinline], [Macro declaring a function to always be inlined.]) + else + AC_DEFINE([EFL_ALWAYS_INLINE], [__attribute__ ((__always_inline__)) inline], [Macro declaring a function to always be inlined.]) + fi +else + AC_DEFINE([EFL_ALWAYS_INLINE], [static inline], [Macro declaring a function to always be inlined.]) +fi +]) + +dnl End of efl_attribute.m4 diff --git a/m4/efl_binary.m4 b/m4/efl_binary.m4 new file mode 100644 index 0000000..c774688 --- /dev/null +++ b/m4/efl_binary.m4 @@ -0,0 +1,71 @@ +dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr> +dnl That code is public domain and can be freely used or copied. + +dnl Macro that check if a binary is built or not + +dnl Usage: EFL_ENABLE_BIN(binary) +dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being transformed into _) +dnl Define have_binary (- is transformed into _) +dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being transformed into _) + +AC_DEFUN([EFL_ENABLE_BIN], +[ + +m4_pushdef([UP], m4_translit([[$1]], [-a-z], [_A-Z]))dnl +m4_pushdef([DOWN], m4_translit([[$1]], [-A-Z], [_a-z]))dnl + +have_[]m4_defn([DOWN])="yes" + +dnl configure option + +AC_ARG_ENABLE([$1], + [AC_HELP_STRING([--disable-$1], [disable building of ]DOWN)], + [ + if test "x${enableval}" = "xyes" ; then + have_[]m4_defn([DOWN])="yes" + else + have_[]m4_defn([DOWN])="no" + fi + ]) + +AC_MSG_CHECKING([whether to build ]DOWN[ binary]) +AC_MSG_RESULT([$have_[]m4_defn([DOWN])]) + +if test "x$have_[]m4_defn([DOWN])" = "xyes"; then + UP[]_PRG=DOWN[${EXEEXT}] +fi + +AC_SUBST(UP[]_PRG) + +AM_CONDITIONAL(BUILD_[]UP, test "x$have_[]m4_defn([DOWN])" = "xyes") + +AS_IF([test "x$have_[]m4_defn([DOWN])" = "xyes"], [$2], [$3]) + +]) + + +dnl Macro that check if a binary is built or not + +dnl Usage: EFL_WITH_BIN(package, binary, default_value) +dnl Call AC_SUBST(_binary) (_binary is the lowercase of binary, - being transformed into _ by default, or the value set by the user) + +AC_DEFUN([EFL_WITH_BIN], +[ + +m4_pushdef([DOWN], m4_translit([[$2]], [-A-Z], [_a-z]))dnl + +dnl configure option + +AC_ARG_WITH([$2], + [AC_HELP_STRING([--with-$2=PATH], [specify a specific path to ]DOWN[ @<:@default=$3@:>@])], + [_efl_with_binary=${withval}], + [_efl_with_binary=$(pkg-config --variable=prefix $1)/bin/$3]) + +DOWN=${_efl_with_binary} +AC_MSG_NOTICE(DOWN[ set to ${_efl_with_binary}]) + +with_binary_[]m4_defn([DOWN])=${_efl_with_binary} + +AC_SUBST(DOWN) + +]) diff --git a/m4/efl_compiler.m4 b/m4/efl_compiler.m4 new file mode 100644 index 0000000..32819f2 --- /dev/null +++ b/m4/efl_compiler.m4 @@ -0,0 +1,90 @@ +dnl Copyright (C) 2012 Vincent Torri <vincent dot torri at gmail dot com> +dnl This code is public domain and can be freely used or copied. + +dnl Macro that check if compiler of linker flags are available + + +dnl Macro that checks for a compiler flag availability +dnl +dnl _EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS) +dnl AC_SUBST : EFL_CFLAGS (EFL being replaced by its value) +dnl have_flag: yes or no. +AC_DEFUN([_EFL_CHECK_COMPILER_FLAGS], +[dnl +m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl + +dnl store in options -Wfoo if -Wno-foo is passed +option="m4_bpatsubst([[$2]], [-Wno-], [-W])" +CFLAGS_save="${CFLAGS}" +CFLAGS="${CFLAGS} ${option}" +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([whether the compiler supports $2]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]])], + [have_flag="yes"], + [have_flag="no"]) +AC_MSG_RESULT([${have_flag}]) + +AC_LANG_POP([C]) +CFLAGS="${CFLAGS_save}" +if test "x${have_flag}" = "xyes" ; then + UPEFL[_CFLAGS]="${UPEFL[_CFLAGS]} [$2]" +fi +AC_SUBST(UPEFL[_CFLAGS])dnl +m4_popdef([UPEFL])dnl +]) + +dnl EFL_CHECK_COMPILER_FLAGS(EFL, FLAGS) +dnl Checks if FLAGS are supported and add to EFL_CLFAGS. +dnl +dnl It will first try every flag at once, if one fails will try them one by one. +AC_DEFUN([EFL_CHECK_COMPILER_FLAGS], +[dnl +_EFL_CHECK_COMPILER_FLAGS([$1], [$2]) +if test "${have_flag}" != "yes"; then +m4_foreach_w([flag], [$2], [_EFL_CHECK_COMPILER_FLAGS([$1], m4_defn([flag]))]) +fi +]) + + +dnl Macro that checks for a linker flag availability +dnl +dnl _EFL_CHECK_LINKER_FLAGS(EFL, FLAGS) +dnl AC_SUBST : EFL_LDFLAGS (EFL being replaced by its value) +dnl have_flag: yes or no +AC_DEFUN([_EFL_CHECK_LINKER_FLAGS], +[dnl +m4_pushdef([UPEFL], m4_translit([[$1]], [-a-z], [_A-Z]))dnl + +LDFLAGS_save="${LDFLAGS}" +LDFLAGS="${LDFLAGS} $2" +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([whether the linker supports $2]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[]])], + [have_flag="yes"], + [have_flag="no"]) +AC_MSG_RESULT([${have_flag}]) + +AC_LANG_POP([C]) +LDFLAGS="${LDFLAGS_save}" +if test "x${have_flag}" = "xyes" ; then + UPEFL[_LDFLAGS]="${UPEFL[_LDFLAGS]} [$2]" +fi +AC_SUBST(UPEFL[_LDFLAGS])dnl +m4_popdef([UPEFL])dnl +]) + +dnl EFL_CHECK_LINKER_FLAGS(EFL, FLAGS) +dnl Checks if FLAGS are supported and add to EFL_CLFAGS. +dnl +dnl It will first try every flag at once, if one fails will try them one by one. +AC_DEFUN([EFL_CHECK_LINKER_FLAGS], +[dnl +_EFL_CHECK_LINKER_FLAGS([$1], [$2]) +if test "${have_flag}" != "yes"; then +m4_foreach_w([flag], [$2], [_EFL_CHECK_LINKER_FLAGS([$1], m4_defn([flag]))]) +fi +])dnl diff --git a/m4/efl_path_max.m4 b/m4/efl_path_max.m4 new file mode 100644 index 0000000..f57bfd2 --- /dev/null +++ b/m4/efl_path_max.m4 @@ -0,0 +1,36 @@ +dnl Check for PATH_MAX in limits.h, and define a default value if not found +dnl This is a workaround for systems not providing PATH_MAX, like GNU/Hurd + +dnl EFL_CHECK_PATH_MAX([DEFAULT_VALUE_IF_NOT_FOUND]) +dnl +dnl If PATH_MAX is not defined in <limits.h>, defines it +dnl to DEFAULT_VALUE_IF_NOT_FOUND if it exists, or fallback +dnl to using 4096 + +AC_DEFUN([EFL_CHECK_PATH_MAX], +[ + +default_max=m4_default([$1], "4096") +AC_LANG_PUSH([C]) + +AC_MSG_CHECKING([for PATH_MAX in limits.h]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <limits.h> + ]], + [[ +int i = PATH_MAX; + ]])], + [AC_MSG_RESULT([yes])], + [ + AC_DEFINE_UNQUOTED([PATH_MAX], + [${default_max}], + [default value since PATH_MAX is not defined]) + AC_MSG_RESULT([no: using ${default_max}]) + ]) + +AC_LANG_POP([C]) + +]) +dnl end of efl_path_max.m4 diff --git a/m4/project_init.m4 b/m4/project_init.m4 new file mode 100644 index 0000000..12645a8 --- /dev/null +++ b/m4/project_init.m4 @@ -0,0 +1,115 @@ + +dnl PROJECT_VERSION(major, minor, micro, release) +dnl This setup PROJECT version information and should be called BEFORE AC_INIT(). +dnl +dnl release parameter is 'dev' to use from SVN or libtool -release field. +dnl It may be empty if not dev (svn/live build) and no -release is to be used. +dnl +dnl Examples: +dnl PROJECT_VERSION(1, 7, 99, dev) +dnl PROJECT_VERSION(1, 7, 99, ver-1234) +dnl This will define couple of m4 symbols: +dnl v_maj = given major number (first parameter) +dnl v_min = given minor number (second parameter) +dnl v_mic = given micro number (third parameter) +dnl v_rev = if release, it's 0, otherwise it's dev_version. +dnl v_rel = if release, it's -release followed by fourth parameter, +dnl otherwise it's empty. (mostly for libtool) +dnl v_ver = if release, it's major.minor.micro, otherwise it's +dnl major.minor.micro.dev_version +dnl dev_version = development version (svn revision). +dnl def_build_profile = dev or release based on 'dev' release parameter. +AC_DEFUN([PROJECT_VERSION], +[dnl +m4_define([v_maj], [$1])dnl +m4_define([v_min], [$2])dnl +m4_define([v_mic], [$3])dnl +m4_define([dev_version], m4_esyscmd([(git rev-list --count HEAD 2>/dev/null || echo 0) | tr -d '\n']))dnl +m4_define([v_rev], m4_if($4, dev, [dev_version], [0]))dnl +m4_define([v_rel], m4_if($4, dev, [], m4_ifblank($4, [], [-release $4])))dnl +m4_define([def_build_profile], m4_if($4, dev, [dev], [release]))dnl +m4_define([v_ver], m4_if($4, dev, [v_maj.v_min.v_mic.v_rev], [v_maj.v_min.v_mic]))dnl +]) + +dnl PROJECT_COLOR +dnl will check if terminal supports color and if color is wanted by user. +dnl +dnl Used Variables: +dnl WANT_COLOR: if no, forces no color output. +dnl TERM: used to check if color should be enabled. +dnl +dnl Defined Variables: +dnl COLOR_YES: to be used in positive/yes conditions +dnl COLOR_NO: to be used in negative/no conditions +dnl COLOR_OTHER: to be used to highlight some other condition +dnl COLOR_RESET: to reset color +dnl want_color: yes or no +AC_DEFUN([PROJECT_COLOR], +[dnl +case "$TERM" in + xterm|xterm-color|Eterm|aterm|kterm|rxvt*|screen|gnome|interix) + want_color="${WANT_COLOR:-yes}" + ;; + *) + want_color="no" + ;; +esac + +if test "${want_color}" = "yes"; then + COLOR_YES=`echo -e "\033@<:@1;32m"` + COLOR_NO=`echo -e "\033@<:@1;31m"` + COLOR_OTHER=`echo -e "\033@<:@1;36m"` + COLOR_RESET=`echo -e "\033@<:@0m"` +else + COLOR_YES="" + COLOR_NO="" + COLOR_OTHER="" + COLOR_RESET="" +fi +]) + +dnl PROJECT_INIT() +dnl Will AC_DEFINE() the following: +dnl VMAJ = v_maj +dnl VMIN = v_min +dnl VMIC = v_mic +dnl VREV = v_rev +dnl Will AC_SUBST() the following: +dnl VMAJ = v_maj +dnl VMIN = v_min +dnl VMIC = v_mic +dnl PROJECT_LTLIBRARY_FLAGS="-no-undefined -version-info ..." +dnl PROJECT_LTMODULE_FLAGS="-no-undefined -avoid-version" +dnl Will define the following m4: +dnl lt_cur = libtool 'current' field of libtool's -version-info +dnl lt_rev = libtool 'revision' field of libtool's -version-info +dnl lt_age = libtool 'age' field of libtool's -version-info +AC_DEFUN([PROJECT_INIT], +[dnl +AC_REQUIRE([PROJECT_COLOR])dnl +AC_DEFINE_UNQUOTED([VMAJ], [v_maj], [Major version])dnl +AC_DEFINE_UNQUOTED([VMIN], [v_min], [Minor version])dnl +AC_DEFINE_UNQUOTED([VMIC], [v_mic], [Micro version])dnl +AC_DEFINE_UNQUOTED([VREV], [v_rev], [Revison])dnl +VMAJ=v_maj +VMIN=v_min +VMIC=v_mic +AC_SUBST([VMAJ])dnl +AC_SUBST([VMIN])dnl +AC_SUBST([VMIC])dnl +dnl +dnl TODO: warning - lt_cur: +dnl the previous code assumed v_maj + v_min, but this will be a problem when +dnl we bump v_maj and reset v_min. 1 + 7 == 7 + 1, so if v_maj is bumped +dnl we multiply it by 100. +m4_define([lt_cur], m4_if(m4_cmp(v_maj, 1), 0, m4_eval(v_maj + v_min), m4_eval(v_maj * 100 + v_min)))dnl +m4_define([lt_rev], v_mic)dnl +m4_define([lt_age], v_min)dnl +dnl +PROJECT_LTLIBRARY_FLAGS="-no-undefined -version-info lt_cur:lt_rev:lt_age v_rel" +AC_SUBST(PROJECT_LTLIBRARY_FLAGS)dnl +PROJECT_LTMODULE_FLAGS="-no-undefined -avoid-version" +AC_SUBST([PROJECT_LTMODULE_FLAGS])dnl +AC_MSG_NOTICE([Initialized AC_PACKAGE_NAME (AC_PACKAGE_VERSION) development=dev_version v_rel]) +]) + |