build: use gnu autotools
authorRan Benita <ran234@gmail.com>
Sun, 27 Nov 2011 16:54:53 +0000 (18:54 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 1 Dec 2011 15:21:37 +0000 (16:21 +0100)
This commit adds basic autoconf + automake files to build the project.
It also adds a main.c stub in order to simulate the main binary.

The configure script uses pkg-config to find the libraries. The usual
stuff should work. The only additional option right now is:
        ./configure --enable-debug [To enable debugging symbols]
The Makefile should also support the standard stuff:
        make [To build the kmscon binary]
        make check [To build the test_* binaries]
        make dist [To create a tarball]
        make clean
        make install
        etc.

To start from a clean tree (e.g. git clean -dfx), do something like the
following:
        ./autogen.sh
        ./configure --enable-debug CFLAGS=-O0
        make

It all should work well enough for now.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
src/main.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index b57717f..0000000
--- a/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# kmscon - Makefile
-# Written 2011 by David Herrmann <dh.herrmann@googlemail.com>
-#
-
-#
-# To compile the kmscon application, use:
-#   $ make
-# To compile the test suites, use:
-#   $ make tests
-#
-# This makefile is in no way complete nor sophisticated. If you have time to
-# replace it with autotools, I would be glad to apply your patches.
-#
-
-CFLAGS=-g -O0 -Wall `pkg-config --cflags --libs egl gbm gl cairo pango pangocairo` -Isrc
-
-all:
-       gcc -o kmscon src/*.c $(CFLAGS)
-
-tests:
-       gcc -o test_output tests/test_output.c src/*.c $(CFLAGS)
-       gcc -o test_console tests/test_console.c src/*.c $(CFLAGS)
-
-clean:
-       @rm -vf kmscon test_output test_console
-
-.PHONY: all tests clean
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..07fab13
--- /dev/null
@@ -0,0 +1,54 @@
+ACLOCAL_AMFLAGS = -I m4
+
+bin_PROGRAMS = kmscon
+check_PROGRAMS = test_console test_output
+noinst_LTLIBRARIES = libkmscon-core.la
+
+AM_CFLAGS = \
+       -Wall \
+       -I $(srcdir)/src
+AM_LDFLAGS = \
+       -Wl,--as-needed
+
+if DEBUG
+AM_CFLAGS += -g
+endif
+
+libkmscon_core_la_SOURCES = \
+       src/console.c src/console.h \
+       src/output.c src/output.h \
+       src/console_char.c
+
+libkmscon_core_la_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(EGL_CFLAGS) \
+       $(GBM_CFLAGS) \
+       $(OPENGL_CFLAGS) \
+       $(CAIRO_CFLAGS) \
+       $(PANGO_CFLAGS)
+libkmscon_core_la_LIBADD = \
+       $(EGL_LIBS) \
+       $(GBM_LIBS) \
+       $(OPENGL_LIBS) \
+       $(CAIRO_LIBS) \
+       $(PANGO_LIBS)
+
+kmscon_SOURCES = src/main.c
+kmscon_LDADD = libkmscon-core.la
+kmscon_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(CAIRO_CFLAGS)
+
+test_console_SOURCES = tests/test_console.c
+test_console_LDADD = libkmscon-core.la \
+       $(OPENGL_LIBS)
+test_console_CFLAGS = $(kmscon_CFLAGS) \
+       $(OPENGL_CFLAGS)
+
+test_output_SOURCES = tests/test_output.c
+test_output_LDADD = libkmscon-core.la \
+       $(OPENGL_LIBS)
+test_output_CPPFLAGS = $(kmscon_CFLAGS) \
+       $(OPENGL_CFLAGS)
+
+dist_doc_DATA = README TODO
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..53b02ce
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+mkdir -p m4/
+autoreconf -i
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..46e7d9b
--- /dev/null
@@ -0,0 +1,49 @@
+AC_PREREQ(2.68)
+
+AC_INIT([kmscon], [0.0])
+AC_SUBST(PACKAGE_URL, [https://github.com/dvdhrm/kmscon])
+AC_CONFIG_SRCDIR([src/main.c])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_HEADER(config.h)
+
+AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects dist-bzip2 no-dist-gzip tar-pax -Wall -Werror])
+AM_SILENT_RULES([yes])
+
+LT_PREREQ(2.2)
+LT_INIT
+
+AC_PROG_CC
+AM_PROG_CC_C_O
+
+PKG_CHECK_MODULES([EGL], [egl])
+AC_SUBST(EGL_CFLAGS)
+AC_SUBST(EGL_LIBS)
+
+PKG_CHECK_MODULES([GBM], [gbm])
+AC_SUBST(GBM_CFLAGS)
+AC_SUBST(GBM_LIBS)
+
+PKG_CHECK_MODULES([OPENGL], [gl])
+AC_SUBST(OPENGL_CFLAGS)
+AC_SUBST(OPENGL_LIBS)
+
+PKG_CHECK_MODULES([CAIRO], [cairo])
+AC_SUBST(CAIRO_CFLAGS)
+AC_SUBST(CAIRI_LIBS)
+
+PKG_CHECK_MODULES([PANGO], [pango pangocairo])
+AC_SUBST(PANGO_CFLAGS)
+AC_SUBST(PANGO_LIBS)
+
+AC_MSG_CHECKING([whether to build with debugging on])
+AC_ARG_ENABLE([debug],
+              [AS_HELP_STRING([--enable-debug],
+                              [whether to build with debugging on)])],
+                              [debug="$enableval"; AC_DEFINE([DEBUG], [0], [Debug])],
+                              [debug=no])
+AM_CONDITIONAL([DEBUG], [test x$debug = xyes])
+AC_MSG_RESULT([$debug])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/src/main.c b/src/main.c
new file mode 100644 (file)
index 0000000..9231934
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+        return EXIT_SUCCESS;
+}