Browse Source

Update autotools

Yann Weber 7 years ago
parent
commit
6e27cc6484
4 changed files with 50 additions and 20 deletions
  1. 2
    2
      Makefile.am
  2. 26
    12
      configure.ac
  3. 18
    0
      m4/ax_check_cflags.m4
  4. 4
    6
      src/Makefile.am

+ 2
- 2
Makefile.am View File

1
-SUBDIRS = src tests
2
-ACLOCAL_AMFLAGS = -I m4
1
+SUBDIRS = src . tests
2
+#ACLOCAL_AMFLAGS = -I m4

+ 26
- 12
configure.ac View File

4
 AC_PREREQ([2.69])
4
 AC_PREREQ([2.69])
5
 AC_INIT([ttail], [0.0.1], [yann.weber@member.fsf.org])
5
 AC_INIT([ttail], [0.0.1], [yann.weber@member.fsf.org])
6
 
6
 
7
-#AC_CONFIG_SRCDIR([src/ttail.c])
7
+AC_CONFIG_HEADERS([src/include/config.h])
8
+AC_CONFIG_SRCDIR([src/ttail.c])
8
 AC_CONFIG_MACRO_DIR([m4])
9
 AC_CONFIG_MACRO_DIR([m4])
9
 
10
 
10
 # Checks for programs.
11
 # Checks for programs.
12
+AC_GNU_SOURCE
11
 AC_PROG_CC
13
 AC_PROG_CC
12
 AM_PROG_CC_C_O 
14
 AM_PROG_CC_C_O 
13
 AC_PROG_MAKE_SET
15
 AC_PROG_MAKE_SET
16
+AC_PROG_RANLIB
14
 
17
 
15
 # Checks for libraries.
18
 # Checks for libraries.
16
 AC_SEARCH_LIBS([dlopen], [dl dld], [], [
19
 AC_SEARCH_LIBS([dlopen], [dl dld], [], [
23
 
26
 
24
 # Checks for typedefs, structures, and compiler characteristics.
27
 # Checks for typedefs, structures, and compiler characteristics.
25
 AC_TYPE_SIZE_T
28
 AC_TYPE_SIZE_T
26
-
29
+#CFLAGS="$CFLAGS -I$(top_builddir)/src/include/"
27
 # Checks for library functions.
30
 # Checks for library functions.
28
 AC_FUNC_MALLOC
31
 AC_FUNC_MALLOC
29
 AC_FUNC_REALLOC
32
 AC_FUNC_REALLOC
30
 
33
 
31
-AC_ARG_ENABLE([fmt_regex],
32
-	AS_HELP_STRING([--disable-fmt-regex], [Disable regex format detection]))
33
-
34
-AS_IF([test "x$enable_fmt_regex" != "xno"], [
35
-	AC_DEFINE([TTAIL_FMT_REGEX], [1],
36
-		[define if using regex format])
37
-	AC_SUBST([WANT_LIBFMT_REGEX],[1])
34
+AC_ARG_ENABLE([debug],[  --enable-debug turn on debugging],
35
+[case "${enableval}" in
36
+	yes) debug=true ;;
37
+	no)  debug=false ;;
38
+	*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
39
+esac],[debug=false])
40
+AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
41
+
42
+AS_IF([test x$debug = xtrue], [
43
+	AX_CHECK_CFLAGS([-Wall])
44
+	AX_CHECK_CFLAGS([-g])
45
+	AX_CHECK_CFLAGS([-ggdb])
46
+	AX_CHECK_CFLAGS([-O0])
47
+],
48
+[
49
+	AX_CHECK_CFLAGS([-O2])
50
+	AX_CHECK_CFLAGS([-std=c99 -pedantic])
51
+	AX_CHECK_CFLAGS([-ansi])
52
+	AX_CHECK_CFLAGS([-Wall -Werror])
53
+	AX_CHECK_CFLAGS([-fgnu89-inline])
38
 ])
54
 ])
55
+AX_CHECK_CFLAGS([-D_XOPEN_SOURCE -D_GNU_SOURCE])
39
 
56
 
40
 AM_INIT_AUTOMAKE
57
 AM_INIT_AUTOMAKE
41
 
58
 
42
-AM_CONDITIONAL([WANT_LIBFMT_REGEX], [test "x$enable_fmt_regex" != "xno"])
43
-
44
 AC_CONFIG_FILES([Makefile
59
 AC_CONFIG_FILES([Makefile
45
 		src/Makefile
60
 		src/Makefile
46
 		tests/Makefile])
61
 		tests/Makefile])
47
-AC_CONFIG_HEADERS([src/include/config.h])
48
 
62
 
49
 AC_OUTPUT
63
 AC_OUTPUT

+ 18
- 0
m4/ax_check_cflags.m4 View File

1
+# AX_CHECK_CFLAGS(ADDITIONAL-CFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
2
+#
3
+# checks whether the $(CC) compiler accepts the ADDITIONAL-CFLAGS
4
+# if so, they are added to the CXXFLAGS
5
+AC_DEFUN([AX_CHECK_CFLAGS],
6
+[
7
+	AC_MSG_CHECKING([whether compiler accepts "$1"])
8
+	echo "int main(int argc, char** argv){ return 0; }" > conftest.c
9
+	if $CC $CFLAGS -o conftest.o conftest.c [$1] > /dev/null 2>&1
10
+	then
11
+	AC_MSG_RESULT([yes])
12
+	CFLAGS="${CFLAGS} [$1]"
13
+	[$2]
14
+	else
15
+	AC_MSG_RESULT([no])
16
+	[$3]
17
+	fi
18
+])dnl AX_CHECK_CFLAGS

+ 4
- 6
src/Makefile.am View File

1
 bin_PROGRAMS = ttail
1
 bin_PROGRAMS = ttail
2
+noinst_LIBRARIES=libttail.a
2
 
3
 
3
-
4
-ttail_SOURCES = ttail.c dateformats.c options.c
5
-if WANT_LIBFMT_REGEX
6
-ttail_SOURCES += fmt_regex.c
7
-endif
8
-ttail_CFLAGS = -std=c99 -Wall -Werror -D_XOPEN_SOURCE -D_GNU_SOURCE -I$(top_srcdir)/src/include
4
+libttail_a_SOURCES = ttail.c
5
+ttail_SOURCES = main.c ttail.c
6
+#ttail_CFLAGS = @CFLAGS@

Loading…
Cancel
Save