diff --git a/Makefile.am b/Makefile.am index 5de108f..38abe8d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ bin_PROGRAMS = tg-timer EXTRA_PROGRAMS = tg-timer-dbg \ tg-timer-prf \ tg-timer-vlg -MOSTLYCLEANFILES := $(EXTRA_PROGRAMS) +MOSTLYCLEANFILES = $(EXTRA_PROGRAMS) tg_timer_SOURCES = src/algo.c \ src/audio.c \ @@ -28,10 +28,10 @@ LIBS = $(GTK_LIBS) \ AM_CPPFLAGS = -DPROGRAM_NAME=\"Tg\" -DVERSION=\"$(PACKAGE_VERSION)\" tg_timer_dbg_CPPFLAGS = $(AM_CPPFLAGS) -DDEBUG -AM_CFLAGS = $(GTK_CFLAGS) \ - $(GTHREAD_CFLAGS) \ - $(PORTAUDIO_CFLAGS) \ - $(FFTW_CFLAGS) +AM_CFLAGS += $(GTK_CFLAGS) \ + $(GTHREAD_CFLAGS) \ + $(PORTAUDIO_CFLAGS) \ + $(FFTW_CFLAGS) tg_timer_dbg_CFLAGS = $(AM_CFLAGS) -ggdb tg_timer_prf_CFLAGS = $(AM_CFLAGS) -pg tg_timer_vlg_CFLAGS = $(AM_CFLAGS) -g @@ -57,11 +57,11 @@ dist_desktop_DATA = icons/tg-timer.desktop \ dist_man_MANS = docs/tg-timer.1 -EXTRA_DIST := autogen.sh \ - icons \ - packaging \ - LICENSE \ - README.md +EXTRA_DIST = autogen.sh \ + icons \ + packaging \ + LICENSE \ + README.md .rc.o: $(WINDRES) $< -O coff -o $@ diff --git a/configure.ac b/configure.ac index 9dec552..6d8a6d0 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ define([tg_version], m4_normalize(m4_include([version]))) AC_CONFIG_MACRO_DIRS([m4]) AC_INIT([Tg], [tg_version], [vacaboja@gmail.com], [tg-timer], [https://github.com/vacaboja/tg]) -AM_INIT_AUTOMAKE([foreign subdir-objects]) +AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) AC_PROG_CC AC_CHECK_LIB([pthread], [pthread_mutex_init], [], [AC_MSG_ERROR([pthread not found])]) @@ -18,6 +18,8 @@ AM_CONDITIONAL([BE_WINDOWS], [test x$OS = xWindows_NT]) AM_COND_IF([BE_WINDOWS], [AC_CONFIG_LINKS([icons/tg-timer.ico:icons/tg-timer.ico])]); CC_CHECK_LDFLAGS([-Wl,--as-needed], [AC_SUBST([AM_LDFLAGS], [-Wl,--as-needed])], []) +CC_CHECK_CFLAGS([-Wall], [AC_SUBST([AM_CFLAGS], [-Wall])], []) +CC_CHECK_CFLAGS([-Wextra], [AC_SUBST([AM_CFLAGS], [-Wextra])], []) AC_OUTPUT([Makefile icons/Makefile]) @@ -28,6 +30,6 @@ AC_MSG_RESULT([ prefix: ${prefix} compiler: ${CC} - cflags: ${CFLAGS}${AM_CFLAGS} - ldflags: ${LDFLAGS}${AM_LDFLAGS} + cflags: ${CFLAGS} ${AM_CFLAGS} + ldflags: ${LDFLAGS} ${AM_LDFLAGS} ]) diff --git a/m4/attributes.m4 b/m4/attributes.m4 index 51ac88b..c7ef73e 100644 --- a/m4/attributes.m4 +++ b/m4/attributes.m4 @@ -1,7 +1,6 @@ dnl Macros to check the presence of generic (non-typed) symbols. dnl Copyright (c) 2006-2008 Diego Pettenò dnl Copyright (c) 2006-2008 xine project -dnl Copyright (c) 2012 Lucas De Marchi dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by @@ -33,32 +32,52 @@ dnl distribute a modified version of the Autoconf Macro, you may extend dnl this special exception to the GPL to apply to your modified version as dnl well. -dnl Check if FLAG in ENV-VAR is supported by compiler and append it -dnl to WHERE-TO-APPEND variable. Note that we invert -Wno-* checks to -dnl -W* as gcc cannot test for negated warnings. If a C snippet is passed, -dnl use it, otherwise use a simple main() definition that just returns 0. -dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG], [C-SNIPPET]) +dnl Check if the flag is supported by compiler +dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) -AC_DEFUN([CC_CHECK_FLAG_APPEND], [ - AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2], - AS_TR_SH([cc_cv_$2_$3]), - [eval "AS_TR_SH([cc_save_$2])='${$2}'" - eval "AS_TR_SH([$2])='${cc_save_$2} -Werror `echo "$3" | sed 's/^-Wno-/-W/'`'" - AC_LINK_IFELSE([AC_LANG_SOURCE(ifelse([$4], [], - [int main(void) { return 0; } ], - [$4]))], - [eval "AS_TR_SH([cc_cv_$2_$3])='yes'"], - [eval "AS_TR_SH([cc_cv_$2_$3])='no'"]) - eval "AS_TR_SH([$2])='$cc_save_$2'"]) +AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ + AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]), + [ac_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $1" + AC_COMPILE_IFELSE([int a;], + [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"], + [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"]) + CFLAGS="$ac_save_CFLAGS" + ]) - AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes], - [eval "$1='${$1} $3'"]) + AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], + [$2], [$3]) ]) -dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2], [C-SNIPPET]) -AC_DEFUN([CC_CHECK_FLAGS_APPEND], [ - for flag in [$3]; do - CC_CHECK_FLAG_APPEND([$1], [$2], $flag, [$4]) +dnl Check if the flag is supported by compiler (cacheable) +dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) + +AC_DEFUN([CC_CHECK_CFLAGS], [ + AC_CACHE_CHECK([if $CC supports $1 flag], + AS_TR_SH([cc_cv_cflags_$1]), + CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! + ) + + AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], + [$2], [$3]) +]) + +dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) +dnl Check for CFLAG and appends them to CFLAGS if supported +AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ + AC_CACHE_CHECK([if $CC supports $1 flag], + AS_TR_SH([cc_cv_cflags_$1]), + CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! + ) + + AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], + [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3]) +]) + +dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) +AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [ + for flag in $1; do + CC_CHECK_CFLAG_APPEND($flag, [$2], [$3]) done ]) @@ -93,13 +112,13 @@ AC_DEFUN([CC_NOUNDEFINED], [ *-freebsd* | *-openbsd*) ;; *) dnl First of all check for the --no-undefined variant of GNU ld. This allows - dnl for a much more readable command line, so that people can understand what + dnl for a much more readable commandline, so that people can understand what dnl it does without going to look for what the heck -z defs does. - for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do - CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"]) - break + for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do + CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"]) + break done - ;; + ;; esac AC_SUBST([LDFLAGS_NOUNDEFINED]) @@ -128,7 +147,7 @@ AC_DEFUN([CC_CHECK_ATTRIBUTE], [ AS_TR_SH([cc_cv_attribute_$1]), [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])], + AC_COMPILE_IFELSE([$3], [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"], [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"]) CFLAGS="$ac_save_CFLAGS" @@ -235,8 +254,8 @@ AC_DEFUN([CC_FLAG_VISIBILITY], [ [cc_flag_visibility_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], - cc_cv_flag_visibility='yes', - cc_cv_flag_visibility='no') + cc_cv_flag_visibility='yes', + cc_cv_flag_visibility='no') CFLAGS="$cc_flag_visibility_save_CFLAGS"]) AS_IF([test "x$cc_cv_flag_visibility" = "xyes"], @@ -252,11 +271,11 @@ AC_DEFUN([CC_FUNC_EXPECT], [ [cc_cv_func_expect], [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" - AC_COMPILE_IFELSE([AC_LANG_SOURCE( + AC_COMPILE_IFELSE( [int some_function() { int a = 3; return (int)__builtin_expect(a, 3); - }])], + }], [cc_cv_func_expect=yes], [cc_cv_func_expect=no]) CFLAGS="$ac_save_CFLAGS" @@ -276,11 +295,11 @@ AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [ [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" for cc_attribute_align_try in 64 32 16 8 4 2; do - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_COMPILE_IFELSE([ int main() { static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0; return c; - }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break]) + }], [cc_cv_attribute_aligned=$cc_attribute_align_try; break]) done CFLAGS="$ac_save_CFLAGS" ])