1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00
libkernaux/configure.ac

311 lines
14 KiB
Text
Raw Normal View History

############################
# Specify program versions #
############################
2020-11-27 04:28:13 -05:00
AC_PREREQ([2.68])
LT_PREREQ([2.4.6])
#######################
# Initialize Autoconf #
#######################
2020-11-27 05:33:23 -05:00
AC_INIT([libkernaux],
2022-06-13 08:05:47 -04:00
m4_normalize(m4_include([VERSION])),
2021-12-12 07:13:52 -05:00
[https://github.com/tailix/libkernaux/issues],
2020-11-27 05:33:23 -05:00
[libkernaux],
2021-12-12 07:13:52 -05:00
[https://github.com/tailix/libkernaux])
2020-11-27 04:28:13 -05:00
2022-01-17 07:33:28 -05:00
AC_CANONICAL_BUILD
2020-11-29 23:13:13 -05:00
AC_CANONICAL_HOST
2020-11-29 22:27:43 -05:00
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([src/assert.c])
AC_CONFIG_FILES([
Makefile
examples/Makefile
include/Makefile
libc/Makefile
libc/include/Makefile
include/kernaux.h
include/kernaux/drivers/console.h
include/kernaux/multiboot2.h
include/kernaux/printf.h
2022-06-13 03:02:05 -04:00
include/kernaux/version.h
tests/Makefile
])
2021-12-15 05:45:40 -05:00
2022-02-10 07:25:46 -05:00
###############
# Define args #
###############
2022-01-19 06:40:12 -05:00
dnl Features (enabled by default)
AC_ARG_ENABLE([debug], AS_HELP_STRING([--disable-debug], [disable debugging]))
AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmetic]))
AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror]))
2022-01-19 06:40:12 -05:00
dnl Features (disabled by default)
AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [build for freestanding environment]))
AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc]))
AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [enable usual tests and examples]))
AC_ARG_ENABLE([tests-all], AS_HELP_STRING([--enable-tests-all], [enable all tests]))
AC_ARG_ENABLE([tests-python], AS_HELP_STRING([--enable-tests-python], [enable tests that require Python 3 with YAML and Jinja2]))
2021-12-15 05:45:40 -05:00
dnl Packages (enabled by default)
AC_ARG_WITH( [all], AS_HELP_STRING([--without-all], [without all default packages]))
2022-01-19 06:14:46 -05:00
AC_ARG_WITH( [cmdline], AS_HELP_STRING([--without-cmdline], [without command line parser]))
AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [without ELF utils]))
AC_ARG_WITH( [free-list], AS_HELP_STRING([--without-free-list], [without free list memory allocator]))
2022-06-14 08:03:17 -04:00
AC_ARG_WITH( [io], AS_HELP_STRING([--without-io], [without input/output]))
2022-01-19 06:14:46 -05:00
AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without Master Boot Record]))
2022-06-15 03:58:14 -04:00
AC_ARG_WITH( [memmap], AS_HELP_STRING([--without-memmap], [without memory map]))
2022-01-19 06:14:46 -05:00
AC_ARG_WITH( [multiboot2], AS_HELP_STRING([--without-multiboot2], [without Multiboot 2 information parser]))
AC_ARG_WITH( [ntoa], AS_HELP_STRING([--without-ntoa], [without itoa/ftoa]))
AC_ARG_WITH( [pfa], AS_HELP_STRING([--without-pfa], [without Page Frame Allocator]))
AC_ARG_WITH( [printf], AS_HELP_STRING([--without-printf], [without printf]))
AC_ARG_WITH( [printf-fmt], AS_HELP_STRING([--without-printf-fmt], [without printf format parser]))
2022-01-19 06:14:46 -05:00
AC_ARG_WITH( [units], AS_HELP_STRING([--without-units], [without measurement units utils]))
dnl Packages (disabled by default)
AC_ARG_WITH( [drivers], AS_HELP_STRING([--with-drivers], [with drivers]))
AC_ARG_WITH( [libc], AS_HELP_STRING([--with-libc], [with libc replacement]))
2022-02-10 08:16:00 -05:00
################
# Default args #
################
AC_DEFUN([do_enable_tests_all],
[
if test -z "$enable_tests"; then enable_tests=yes; fi
if test -z "$enable_tests_python"; then enable_tests_python=yes; fi
])
AS_IF([test "$enable_tests_all" = yes], do_enable_tests_all)
2022-02-10 08:16:00 -05:00
AC_DEFUN([do_without_all],
[
if test -z "$with_cmdline"; then with_cmdline=no; fi
if test -z "$with_elf"; then with_elf=no; fi
if test -z "$with_free_list"; then with_free_list=no; fi
2022-06-14 08:03:17 -04:00
if test -z "$with_io"; then with_io=no; fi
2022-02-10 08:16:00 -05:00
if test -z "$with_mbr"; then with_mbr=no; fi
2022-06-15 03:58:14 -04:00
if test -z "$with_memmap"; then with_memmap=no; fi
2022-02-10 08:16:00 -05:00
if test -z "$with_multiboot2"; then with_multiboot2=no; fi
if test -z "$with_ntoa"; then with_ntoa=no; fi
if test -z "$with_pfa"; then with_pfa=no; fi
if test -z "$with_printf"; then with_printf=no; fi
if test -z "$with_printf_fmt"; then with_printf_fmt=no; fi
2022-02-10 08:16:00 -05:00
if test -z "$with_units"; then with_units=no; fi
])
AS_IF([test "$with_all" = no], do_without_all)
2022-02-10 07:25:46 -05:00
##################
# Normalize args #
##################
dnl Features (enabled by default)
AS_IF([test "$enable_debug" = no ], [enable_debug=no], [enable_debug=yes])
AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_float=yes])
AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes])
2022-02-10 07:25:46 -05:00
dnl Features (disabled by default)
AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [enable_freestanding=no])
AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no])
AS_IF([test "$enable_tests" = yes], [enable_tests=yes], [enable_tests=no])
AS_IF([test "$enable_tests_all" = yes], [enable_tests_all=yes], [enable_tests_all=no])
AS_IF([test "$enable_tests_python" = yes], [enable_tests_python=yes], [enable_tests_python=no])
2022-02-10 07:25:46 -05:00
dnl Packages (enabled by default)
AS_IF([test "$with_all" = no ], [with_all=no], [with_all=yes])
AS_IF([test "$with_cmdline" = no ], [with_cmdline=no], [with_cmdline=yes])
AS_IF([test "$with_elf" = no ], [with_elf=no], [with_elf=yes])
AS_IF([test "$with_free_list" = no ], [with_free_list=no], [with_free_list=yes])
2022-06-14 08:03:17 -04:00
AS_IF([test "$with_io" = no ], [with_io=no], [with_io=yes])
AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes])
2022-06-15 03:58:14 -04:00
AS_IF([test "$with_memmap" = no ], [with_memmap=no], [with_memmap=yes])
AS_IF([test "$with_multiboot2" = no ], [with_multiboot2=no], [with_multiboot2=yes])
AS_IF([test "$with_ntoa" = no ], [with_ntoa=no], [with_ntoa=yes])
AS_IF([test "$with_pfa" = no ], [with_pfa=no], [with_pfa=yes])
AS_IF([test "$with_printf" = no ], [with_printf=no], [with_printf=yes])
AS_IF([test "$with_printf_fmt" = no ], [with_printf_fmt=no], [with_printf_fmt=yes])
AS_IF([test "$with_units" = no ], [with_units=no], [with_units=yes])
2022-02-10 07:25:46 -05:00
dnl Packages (disabled by default)
AS_IF([test "$with_drivers" = yes], [with_drivers=yes], [with_drivers=no])
AS_IF([test "$with_libc" = yes], [with_libc=yes], [with_libc=no])
2022-02-10 07:25:46 -05:00
2022-05-23 16:02:57 -04:00
#############
# Test args #
#############
AS_IF([test "$enable_tests" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests]))
AS_IF([test "$enable_tests_python" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests]))
AS_IF([test "$enable_tests" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests]))
AS_IF([test "$enable_tests_python" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests]))
AS_IF([test "$with_printf" = yes -a "$with_ntoa" = no], AC_MSG_ERROR([package `printf' requires package `ntoa']))
AS_IF([test "$with_printf" = yes -a "$with_printf_fmt" = no], AC_MSG_ERROR([package `printf' requires package `printf-fmt']))
AS_IF([test "$with_units" = yes -a "$with_ntoa" = no], AC_MSG_ERROR([package `units' requires package `ntoa']))
2022-05-23 16:02:57 -04:00
#########################
# Automake conditionals #
#########################
dnl Architecture
AM_CONDITIONAL([ASM_I386], [test "$host_cpu" = i386])
AM_CONDITIONAL([ASM_RISCV64], [test "$host_cpu" = riscv64])
AM_CONDITIONAL([ASM_X86_64], [test "$host_cpu" = x86_64])
2021-12-15 05:45:40 -05:00
2022-01-19 06:40:12 -05:00
dnl Features (enabled by default)
AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = yes])
AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes])
AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes])
2022-01-19 06:40:12 -05:00
dnl Features (disabled by default)
AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes])
AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes])
AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" = yes])
AM_CONDITIONAL([ENABLE_TESTS_PYTHON], [test "$enable_tests_python" = yes])
2021-12-15 05:45:40 -05:00
dnl Packages (enabled by default)
AM_CONDITIONAL([WITH_CMDLINE], [test "$with_cmdline" = yes])
AM_CONDITIONAL([WITH_ELF], [test "$with_elf" = yes])
AM_CONDITIONAL([WITH_FREE_LIST], [test "$with_free_list" = yes])
2022-06-14 08:03:17 -04:00
AM_CONDITIONAL([WITH_IO], [test "$with_io" = yes])
AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes])
2022-06-15 03:58:14 -04:00
AM_CONDITIONAL([WITH_MEMMAP], [test "$with_memmap" = yes])
AM_CONDITIONAL([WITH_MULTIBOOT2], [test "$with_multiboot2" = yes])
AM_CONDITIONAL([WITH_NTOA], [test "$with_ntoa" = yes])
AM_CONDITIONAL([WITH_PFA], [test "$with_pfa" = yes])
AM_CONDITIONAL([WITH_PRINTF], [test "$with_printf" = yes])
AM_CONDITIONAL([WITH_PRINTF_FMT], [test "$with_printf_fmt" = yes])
AM_CONDITIONAL([WITH_UNITS], [test "$with_units" = yes])
dnl Packages (disabled by default)
AM_CONDITIONAL([WITH_DRIVERS], [test "$with_drivers" = yes])
AM_CONDITIONAL([WITH_LIBC], [test "$with_libc" = yes])
2022-05-23 16:02:57 -04:00
####################
# Autoconf defines #
####################
dnl Architecture
AS_IF([test "$host_cpu" = i386], [AC_DEFINE([ASM_I386], [1], [architecture is i386])])
AS_IF([test "$host_cpu" = riscv64], [AC_DEFINE([ASM_RISCV64], [1], [architecture is RISC-V 64-bit])])
AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86_64], [1], [architecture is x86_64])])
2021-12-17 18:43:19 -05:00
2022-01-19 06:40:12 -05:00
dnl Features (enabled by default)
AS_IF([test "$enable_debug" = yes], [AC_DEFINE([ENABLE_DEBUG], [1], [enabled debugging])])
AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmetic])])
AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])])
2022-01-19 06:40:12 -05:00
dnl Features (disabled by default)
AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])])
AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])])
AS_IF([test "$enable_tests" = yes], [AC_DEFINE([ENABLE_TESTS], [1], [enabled usual tests and examples])])
AS_IF([test "$enable_tests_python" = yes], [AC_DEFINE([ENABLE_TESTS_PYTHON], [1], [enabled tests that require Python 3 with YAML and Jinja2])])
2020-11-29 22:27:43 -05:00
dnl Packages (enabled by default)
AS_IF([test "$with_cmdline" = yes], [AC_DEFINE([WITH_CMDLINE], [1], [with command line parser])])
AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF], [1], [with ELF utils])])
AS_IF([test "$with_free_list" = yes], [AC_DEFINE([WITH_FREE_LIST], [1], [with free list memory allocator])])
2022-06-14 08:03:17 -04:00
AS_IF([test "$with_io" = yes], [AC_DEFINE([WITH_IO], [1], [with input/output])])
AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with Master Boot Record])])
2022-06-15 03:58:14 -04:00
AS_IF([test "$with_memmap" = yes], [AC_DEFINE([WITH_MEMMAP], [1], [with memory map])])
AS_IF([test "$with_multiboot2" = yes], [AC_DEFINE([WITH_MULTIBOOT2], [1], [with Multiboot 2 information parser])])
AS_IF([test "$with_ntoa" = yes], [AC_DEFINE([WITH_NTOA], [1], [with ntoa])])
AS_IF([test "$with_pfa" = yes], [AC_DEFINE([WITH_PFA], [1], [with Page Frame Allocator])])
AS_IF([test "$with_printf" = yes], [AC_DEFINE([WITH_PRINTF], [1], [with printf])])
AS_IF([test "$with_printf_fmt" = yes], [AC_DEFINE([WITH_PRINTF_FMT], [1], [with printf format parser])])
AS_IF([test "$with_units", = yes], [AC_DEFINE([WITH_UNITS], [1], [with measurement units utils])])
dnl Packages (disabled by default)
AS_IF([test "$with_drivers" = yes], [AC_DEFINE([WITH_DRIVERS], [1], [with drivers])])
AS_IF([test "$with_libc" = yes], [AC_DEFINE([WITH_LIBC], [1], [with libc replacement])])
dnl Additional
AS_IF([test "$enable_debug" = yes], [AC_DEFINE([KERNAUX_DEBUG], [1], [enabled debugging])])
2022-05-23 16:02:57 -04:00
##########################
# Autoconf substitutions #
##########################
dnl Packages (enabled by default)
2022-06-14 12:57:44 -04:00
AS_IF([test "$with_cmdline" = no], [AC_SUBST([comment_line_cmdline], [//])])
AS_IF([test "$with_elf" = no], [AC_SUBST([comment_line_elf], [//])])
AS_IF([test "$with_free_list" = no], [AC_SUBST([comment_line_free_list], [//])])
2022-06-14 12:57:44 -04:00
AS_IF([test "$with_io" = no], [AC_SUBST([comment_line_io], [//])])
AS_IF([test "$with_mbr" = no], [AC_SUBST([comment_line_mbr], [//])])
2022-06-15 03:58:14 -04:00
AS_IF([test "$with_memmap" = no], [AC_SUBST([comment_line_memmap], [//])])
2022-06-14 12:57:44 -04:00
AS_IF([test "$with_multiboot2" = no], [AC_SUBST([comment_line_multiboot2], [//])])
AS_IF([test "$with_ntoa" = no], [AC_SUBST([comment_line_ntoa], [//])])
AS_IF([test "$with_pfa" = no], [AC_SUBST([comment_line_pfa], [//])])
AS_IF([test "$with_printf" = no], [AC_SUBST([comment_line_printf], [//])])
AS_IF([test "$with_printf_fmt" = no], [AC_SUBST([comment_line_printf_fmt], [//])])
AS_IF([test "$with_units" = no], [AC_SUBST([comment_line_units], [//])])
###################
# Set build flags #
###################
AC_DEFUN([do_enable_freestanding], [CFLAGS+=' -nostdlib -ffreestanding -fno-pic -fno-stack-protector '])
AC_DEFUN([do_disable_freestanding], [CFLAGS+=' -fpic '])
AS_IF([test "$enable_freestanding" = yes], do_enable_freestanding, do_disable_freestanding)
#######################
# Initialize Automake #
#######################
AM_INIT_AUTOMAKE([1.16 subdir-objects])
2020-11-27 04:28:13 -05:00
##############
# Run checks #
##############
2020-11-27 04:28:13 -05:00
AC_LANG([C])
2020-11-27 05:33:23 -05:00
AM_PROG_AR
AM_PROG_AS
2020-11-27 04:28:13 -05:00
AC_PROG_CC
2020-11-27 08:43:58 -05:00
AC_PROG_CC_C99
2020-12-05 23:04:02 -05:00
AC_C_INLINE
2020-12-06 05:27:55 -05:00
AC_CHECK_HEADER_STDBOOL
2021-12-17 13:22:05 -05:00
AC_CHECK_HEADERS([stdarg.h stddef.h stdint.h])
2020-11-27 04:28:13 -05:00
######################
# Initialize Libtool #
######################
LT_INIT([disable-shared])
##########
# Finish #
##########
2020-11-27 04:28:13 -05:00
AC_OUTPUT