summaryrefslogtreecommitdiff
path: root/080_blog/00030_The-Hell-of-Autotools/index.md
diff options
context:
space:
mode:
Diffstat (limited to '080_blog/00030_The-Hell-of-Autotools/index.md')
-rw-r--r--080_blog/00030_The-Hell-of-Autotools/index.md74
1 files changed, 74 insertions, 0 deletions
diff --git a/080_blog/00030_The-Hell-of-Autotools/index.md b/080_blog/00030_The-Hell-of-Autotools/index.md
new file mode 100644
index 0000000..746bd82
--- /dev/null
+++ b/080_blog/00030_The-Hell-of-Autotools/index.md
@@ -0,0 +1,74 @@
+The Hell of Autotools
+=====================
+ March 19, 2018
+In this trivial example we compile a custom **webkit2gtk+ extension** with
+**autotools**. For a start we need to provide two files, `Makefile.am`
+and `configure.ac`, beside our actual `ext.c` source file, which contains
+the extension code itself.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.c .numberLines}
+// File: ext.c //
+
+#include <webkit2/webkit-web-extension.h>
+
+G_MODULE_EXPORT void
+webkit_web_extension_initialize_with_user_data (WebKitWebExtension *extension,
+ GVariant *user_data)
+{
+ g_print("Hello Extension!\n");
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.makefile .numberLines}
+# File: Makefile.am #
+
+webextension_LTLIBRARIES = libmyappwebextension.la
+webextensiondir = /home/miguel/temp
+
+WEB_EXTENSION_CFLAGS = `pkg-config --cflags webkit2gtk-web-extension-4.0`
+WEB_EXTENSION_LIBS2 = `pkg-config --libs webkit2gtk-web-extension-4.0`
+
+libmyappwebextension_la_SOURCES = ext.c
+libmyappwebextension_la_CFLAGS = $(WEB_EXTENSION_CFLAGS)
+libmyappwebextension_la_LIBADD = $(WEB_EXTENSION_LIBS)
+libmyappwebextension_la_LDFLAGS = -module -avoid-version -no-undefined $(WEB_EXTENSION_LIBS2)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.makefile .numberLines}
+# File: configure.ac #
+
+AC_PREREQ([2.69])
+AC_INIT(ext,0.1,test@example.com)
+AM_INIT_AUTOMAKE
+AC_CONFIG_SRCDIR([ext.c])
+AC_PROG_CC
+LT_INIT
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Put the above files in a new fresh directory and you are ready to see the
+powers of autotools in action.
+
+Run the following commands on your pash prompt:
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash}
+touch NEWS README AUTHORS ChangeLog
+aclocal
+autoconf
+automake --add-missing
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+After this steps, we end up with 18 files in our directory. Finally we
+can _configure_, _build_ and _install_ our extension. The following
+commands will probably look familiar. Note that the _configure_ step
+generates 6 additional files, totaling in **24 files** before the actual
+_make_ command is run.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash}
+./configure
+make
+make install
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+... just to compile one **single C file**.