diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bae3c4b..e0d7936 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure ${{matrix.assert}} ${{matrix.guard}} CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' + run: ./configure --enable-tests ${{matrix.assert}} ${{matrix.guard}} CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' - name: make run: make - name: check diff --git a/Makefile.am b/Makefile.am index 2781adf..576c150 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,16 +10,18 @@ AM_CFLAGS = \ lib_LIBRARIES = libkernaux.a -TESTS = \ - examples/assert_guards \ - examples/assert_simple - noinst_PROGRAMS = $(TESTS) libkernaux_a_SOURCES = \ src/assert.c \ src/libc.c +if ENABLE_TESTS +TESTS = \ + examples/assert_guards \ + examples/assert_simple +endif + if ASM_I386 libkernaux_a_SOURCES += src/asm/i386.S endif @@ -34,10 +36,12 @@ endif if WITH_CMDLINE libkernaux_a_SOURCES += src/cmdline.c +if ENABLE_TESTS TESTS += \ examples/cmdline \ tests/test_cmdline endif +endif if WITH_CONSOLE libkernaux_a_SOURCES += src/console.c @@ -45,8 +49,10 @@ endif if WITH_ELF libkernaux_a_SOURCES += src/elf.c +if ENABLE_TESTS TESTS += tests/test_elf endif +endif if WITH_FRAMEBUFFER libkernaux_a_SOURCES += src/framebuffer.c @@ -54,13 +60,17 @@ endif if WITH_ITOA libkernaux_a_SOURCES += src/itoa.c +if ENABLE_TESTS TESTS += tests/test_itoa endif +endif if WITH_MBR libkernaux_a_SOURCES += src/mbr.c +if ENABLE_TESTS TESTS += tests/test_mbr endif +endif if WITH_MULTIBOOT2 libkernaux_a_SOURCES += \ @@ -71,6 +81,7 @@ libkernaux_a_SOURCES += \ src/multiboot2/info_helpers.c \ src/multiboot2/info_is_valid.c \ src/multiboot2/info_print.c +if ENABLE_TESTS TESTS += \ tests/test_multiboot2_header_helpers \ tests/test_multiboot2_header_print \ @@ -84,29 +95,36 @@ noinst_PROGRAMS += \ tests/multiboot2_info_print1 \ tests/multiboot2_info_print2 endif +endif if WITH_PRINTF libkernaux_a_SOURCES += src/printf.c +if ENABLE_TESTS TESTS += \ examples/printf \ examples/printf_va \ tests/test_printf endif +endif if WITH_PFA libkernaux_a_SOURCES += src/pfa.c +if ENABLE_TESTS TESTS += \ examples/pfa \ tests/test_pfa \ tests/test_pfa_assert endif +endif if WITH_UNITS libkernaux_a_SOURCES += src/units.c +if ENABLE_TESTS TESTS += \ examples/units_human \ tests/test_units_human endif +endif examples_assert_guards_SOURCES = \ $(libkernaux_a_SOURCES) \ diff --git a/README.md b/README.md index 2f530f2..426bb81 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ environment. ``` ./autogen.sh -./configure --enable-assert --enable-guard +./configure --enable-tests --enable-assert --enable-guard make ``` @@ -176,15 +176,8 @@ configure: WARNING: ## ----------------------------------------------------- checking for stddef.h... no ``` -When configured with cross-compiler, library can't be build and installed with -just `make && sudo make install`. Instead use the following commands: - -* `make libkernaux.a` -* `sudo make install-exec install-data` - -To install into specific directory use full path: -`DESTDIR="$(pwd)/dest" make install-exec install-data` instead of -`DESTDIR=dest make install-exec install-data`. +To install into specific directory use full path: `DESTDIR="$(pwd)/dest" make +install` instead of `DESTDIR=dest make install`. Check if compilation targets i386: `objdump -d src/asm/i386.o`. It should output something like this: diff --git a/config/dev-native b/config/dev-native index 62238e6..4e454f7 100755 --- a/config/dev-native +++ b/config/dev-native @@ -7,4 +7,4 @@ if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi PREFIX="$REPO/dest/dev-native" -"$REPO/configure" --prefix="$PREFIX" +"$REPO/configure" --prefix="$PREFIX" --enable-tests diff --git a/config/root-native b/config/root-native index dfac400..4018f45 100755 --- a/config/root-native +++ b/config/root-native @@ -5,4 +5,4 @@ set -e REPO="$(realpath "$(dirname "$(realpath "$0")")/..")" if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi -"$REPO/configure" +"$REPO/configure" --enable-tests diff --git a/configure.ac b/configure.ac index 1bb80a2..d60cdad 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,7 @@ AC_INIT([libkernaux], AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([src/pfa.c]) +AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -17,6 +18,7 @@ AC_ARG_ENABLE([assert], AS_HELP_STRING([--enable-assert], [enable run AC_ARG_ENABLE([guard], AS_HELP_STRING([--enable-guard], [enable argument guards])) AC_ARG_ENABLE([guard-cond], AS_HELP_STRING([--enable-guard-cond], [enable condition guard])) AC_ARG_ENABLE([guard-null], AS_HELP_STRING([--enable-guard-null], [enable NULL-guard])) +AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [enable tests and examples])) dnl Packages (enabled by default) AC_ARG_WITH( [cmdline], AS_HELP_STRING([--without-cmdline], [without command line parser])) @@ -53,6 +55,10 @@ if test -z "$with_libc_strlen"; then with_libc_strlen=yes; fi ]) AS_IF([test "$with_libc" = yes], do_with_libc) + + +AS_IF([test "$host_cpu" != "$build_cpu" -a "$enable_tests" = yes], AC_MSG_ERROR([can not build cross-platform tests])) + AS_IF([test "$with_itoa" = no -a "$with_printf" != no], AC_MSG_ERROR([package `printf' requires package `itoa'])) AS_IF([test "$with_itoa" = no -a "$with_units" != no], AC_MSG_ERROR([package `units' requires package `itoa'])) @@ -67,6 +73,7 @@ dnl Features (disabled by default) AM_CONDITIONAL([ENABLE_ASSERT], [test "$enable_assert" = yes]) AM_CONDITIONAL([ENABLE_GUARD_COND], [test "$enable_guard_cond" = yes]) AM_CONDITIONAL([ENABLE_GUARD_NULL], [test "$enable_guard_null" = yes]) +AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" = yes]) dnl Packages (enabled by default) AM_CONDITIONAL([WITH_CMDLINE], [test "$with_cmdline" != no]) @@ -96,6 +103,7 @@ dnl Features (disabled by default) AS_IF([test "$enable_assert" = yes], [AC_DEFINE([KERNAUX_ENABLE_ASSERT], [1], [enabled runtime assertions])]) AS_IF([test "$enable_guard_cond" = yes], [AC_DEFINE([KERNAUX_ENABLE_GUARD_COND], [1], [enabled condition guard])]) AS_IF([test "$enable_guard_null" = yes], [AC_DEFINE([KERNAUX_ENABLE_GUARD_NULL], [1], [enabled NULL-guard])]) +AS_IF([test "$enable_tests" = yes], [AC_DEFINE([ENABLE_TESTS], [1], [enabled tests and examples])]) dnl Packages (enabled by default) AS_IF([test "$with_cmdline" != no], [AC_DEFINE([WITH_CMDLINE], [1], [with command line parser])])