1
0
Fork 0

Add build system

This adds a autoconfig base build system and some test files.
To build:

1) autoreconf
2) ./configure
3) make
This commit is contained in:
Hans-Joerg Schurr 2020-02-21 19:12:20 +01:00
parent e522d98bef
commit 8f6d3f6897
8 changed files with 197 additions and 0 deletions

18
.gitignore vendored
View File

@ -12,3 +12,21 @@
*.ps
*.pdf
src/.deps
src/.dirstamp
src/config.h*
src/stamp-h1
src/src
Makefile
Makefile.in
aclocal.m4
autom4te.cache
compile
config.log
config.status
configure
depcomp
hvif
install-sh
missing

1
Makefile.am Normal file
View File

@ -0,0 +1 @@
include src/Makefile.am

79
configure.ac Normal file
View File

@ -0,0 +1,79 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([hvif-light], [0.0.1], [commits@schurr.at])
AC_CONFIG_MACRO_DIR(m4)
AM_INIT_AUTOMAKE([subdir-objects foreign 1.13])
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([src/hvif-light.h])
AC_CONFIG_HEADERS([src/config.h])
# Checks C compiler (with empty default flags).
: ${CFLAGS=""}
AC_PROG_CC
AX_CHECK_COMPILE_FLAG([-std=c11],
[ CFLAGS+=" -std=c11" ],
[ AC_MSG_ERROR([C compiler doesn't support C11 mode])] )
# TODO: Update checks once we have code
# Checks for header files.
AC_CHECK_HEADERS([limits.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT32_T
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memmove memset mkdir pow strchr strdup strstr strtol])
# User defined options: debug, lto
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],[compile with debug options])],
[debug=${enableval}], [debug=no])
AC_ARG_ENABLE([lto],
[AS_HELP_STRING([--disable-lto], [disable link time optimization])],
[lto=${enableval}], [lto=yes])
AC_MSG_NOTICE([Setting up compiler flags])
CFLAGS+=" -Wall -Wpedantic -Wextra"
if test x$debug = xyes; then
CFLAGS+=" -O0"
CFLAGS+=" -g -g3 -gdwarf-2"
CFLAGS+=" -ftrapv"
CPPFLAGS+="-DDEBUG"
YFLAGS+=" --debug -v"
lto=no
else
CFLAGS+=" -O3"
CPPFLAGS+=" -DNDEBUG"
CFLAGS+=" -fomit-frame-pointer"
AX_CHECK_COMPILE_FLAG([-finline-limit=1000000 ],
[ CFLAGS+=" -finline-limit=1000000" ])
fi
if test x$lto = xyes; then
AX_CHECK_COMPILE_FLAG([-flto],
[ CFLAGS+=" -flto" ],
[ AC_MSG_WARN([C compiler doesn't support link time optimization])] )
fi
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
AS_ECHO("")
AS_ECHO("")
AS_ECHO("Configuration summary")
AS_ECHO("CC = $CC")
AS_ECHO("CFLAGS = $CFLAGS")
AS_ECHO("CPPLAGS = $CPPFLAGS")
AS_ECHO("YFLAGS = $YFLAGS")
AS_ECHO("LFLAGS = $LFLAGS")

View File

@ -0,0 +1,53 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 6
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

21
src/Makefile.am Normal file
View File

@ -0,0 +1,21 @@
NULL =
bin_PROGRAMS = hvif
# veriT configuration
hvif_CPPFLAGS = \
$(AM_CPPFLAGS) \
-I$(top_builddir)/src \
$(NULL)
hvif_LDADD = \
$(AM_LDADD) \
-lm \
$(NULL)
hvif_SOURCES = \
$(BUILT_SOURCES) \
src/main.c \
src/hvif-light.c \
src/hvif-light.h \
$(NULL)

5
src/hvif-light.c Normal file
View File

@ -0,0 +1,5 @@
#include "hvif-light.h"
unsigned test(unsigned x) {
return 2*x;
}

7
src/hvif-light.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef HVIF_LIGHT_H
#define HVIF_LIGHT_H
unsigned test(unsigned x);
#endif // HVIF_LIGHT_H

13
src/main.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "hvif-light.h"
int main(void) {
unsigned x = 12;
unsigned y = test(x);
printf("This is " PACKAGE_STRING " and 2*%u = %u.\n", x, y);
return EXIT_SUCCESS;
}