diff --git a/.gitignore b/.gitignore index 78cdbb5..aeae0d6 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ # Custom /Makefile.in +/include/Makefile.in ########################################### # Only generated when configuring in root # @@ -51,5 +52,6 @@ # Custom /Makefile +/include/Makefile /autotools-project diff --git a/Makefile.am b/Makefile.am index 325fd95..d9a0fcb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = include + AM_CFLAGS = \ -std=c99 \ -pedantic \ @@ -7,6 +9,10 @@ AM_CFLAGS = \ -I$(top_srcdir)/include bin_PROGRAMS = autotools-project +lib_LIBRARIES = libautotools-project.a autotools_project_SOURCES = \ src/main.c + +libautotools_project_a_SOURCES = \ + src/lib.c diff --git a/README.md b/README.md index 8393736..78a80c7 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,4 @@ Don't forget to change the following files: * `Makefile.am` * `README.md` -Remove submodule `vendor/cross` if you don't need it. +Remove directory `include` and submodule `vendor/cross` if you don't need them. diff --git a/configure.ac b/configure.ac index 42b9e76..80f6b02 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AM_INIT_AUTOMAKE([1.9 subdir-objects]) AC_CONFIG_FILES([ Makefile + include/Makefile ]) AC_LANG([C]) diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..3a495c4 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,2 @@ +nobase_include_HEADERS = \ + autotools-project.h diff --git a/include/autotools-project.h b/include/autotools-project.h new file mode 100644 index 0000000..f43ed77 --- /dev/null +++ b/include/autotools-project.h @@ -0,0 +1,14 @@ +#ifndef _AUTOTOOLS_PROJECT_H +#define _AUTOTOOLS_PROJECT_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +int autotools_project(int a, int b); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib.c b/src/lib.c new file mode 100644 index 0000000..670dda6 --- /dev/null +++ b/src/lib.c @@ -0,0 +1,10 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +int autotools_project(const int a, const int b) +{ + return a + b; +} diff --git a/src/main.c b/src/main.c index de1e707..9f21cbd 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,7 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + int main(const int argc __attribute__((unused)), char **const argv __attribute__((unused))) { return 0;