Add library example

This commit is contained in:
Alex Kotov 2022-06-07 07:10:53 +03:00
parent 9ee872884d
commit 1c0a3c58ec
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
8 changed files with 40 additions and 1 deletions

2
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -17,6 +17,7 @@ AM_INIT_AUTOMAKE([1.9 subdir-objects])
AC_CONFIG_FILES([
Makefile
include/Makefile
])
AC_LANG([C])

2
include/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
nobase_include_HEADERS = \
autotools-project.h

View File

@ -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

10
src/lib.c Normal file
View File

@ -0,0 +1,10 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <autotools-project.h>
int autotools_project(const int a, const int b)
{
return a + b;
}

View File

@ -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;