all repos — nimisewi_c @ b9307275555b201aecaca213003e14da142909bf

simple random toki pona phrase generator

fixed compiler warning about integer type

also added NIMISEWI_STATIC_BUILD option.

anyway, i'm curious, if such changes require a version bump or not.

FossilOrigin-Name: ae170493ce2c0aef31cb81ff7c448134862967ad8a7918d1fde94f05542c6466
la-ninpre leobrekalini@gmail.com
Sat, 11 Sep 2021 10:22:39 +0000
commit

b9307275555b201aecaca213003e14da142909bf

parent

fde06c9cc478deb3ef231d1c947c852e300b937b

2 files changed, 38 insertions(+), 10 deletions(-)

jump to
M CMakeLists.txtCMakeLists.txt

@@ -3,9 +3,10 @@

# project specification project(nimisewi - VERSION 0.3.2 + VERSION 0.3.3 DESCRIPTION "small program that generates random toki pona noun phrase" - HOMEPAGE_URL "https://fsl.aaoth.xyz/nimisewi.c/home") + HOMEPAGE_URL "https://fsl.aaoth.xyz/nimisewi.c/home" + LANGUAGES C) # get compiler name and version

@@ -19,6 +20,11 @@

# configuration header configure_file(config.h.in config.h) + +# warnings + +add_compile_options(-g -W -Wall -Wextra -pedantic -Wmissing-prototypes + -Wstrict-prototypes -Wwrite-strings) # main executable

@@ -58,13 +64,13 @@ if(HAVE_BSD_STRING_H AND HAVE_BSD_STDLIB_H)

set(CMAKE_REQUIRED_LIBRARIES "bsd") check_symbol_exists(strlcat "bsd/string.h" HAVE_STRLCAT) - if (HAVE_STRLCAT) + if(HAVE_STRLCAT) list(APPEND EXTRA_DEFINITIONS HAVE_BSD_STRING_H HAVE_STRLCAT) endif() # HAVE_STRLCAT check_symbol_exists(arc4random_uniform "bsd/stdlib.h" HAVE_ARC4RANDOM_UNIFORM) - if (HAVE_ARC4RANDOM_UNIFORM) + if(HAVE_ARC4RANDOM_UNIFORM) list(APPEND EXTRA_DEFINITIONS HAVE_BSD_STDLIB_H HAVE_ARC4RANDOM_UNIFORM) endif() # HAVE_ARC4RANDOM_UNIFORM

@@ -90,19 +96,27 @@ check_c_source_compiles(

"#include<sha2.h>\nint main(void){return 0;}" HAVE_LIBMD_STATIC) - if(NOT (HAVE_LIBBSD_STATIC - AND HAVE_LIBPTHREAD_STATIC - AND HAVE_LIBMD_STATIC)) - message(WARNING ${WARNING_STATIC_BUILD}) - endif() # NOT (HAVE_LIBBSD_STATIC AND ...) + if(NOT HAVE_LIBBSD_STATIC) + list(APPEND _MISSING_STATIC_LIBS libbsd) + if(NOT HAVE_LIBPTHREAD_STATIC) + list(APPEND _MISSING_STATIC_LIBS libpthread) + if(NOT HAVE_LIBMD_STATIC) + list(APPEND _MISSING_STATIC_LIBS libmd) + message(WARNING ${WARNING_STATIC_BUILD}) + endif() # NOT HAVE_LIBMD_STATIC + endif() # NOT HAVE_LIBPTHREAD_STATIC + endif() # NOT HAVE_LIBBSD_STATIC list(APPEND EXTRA_LIBS bsd pthread md) else() # NOT ANDROID + if(NOT (HAVE_LIBBSD_STATIC)) + list(APPEND _MISSING_STATIC_LIBS libbsd) message(WARNING ${WARNING_STATIC_BUILD}) endif() list(APPEND EXTRA_LIBS bsd) + endif() # NOT ANDROID unset(CMAKE_REQUIRED_LIBRARIES)

@@ -136,6 +150,7 @@ check_c_source_compiles(

"#include<stdio.h>\nint main(void){return 0;}" HAVE_LIBC_STATIC ) if(NOT HAVE_LIBC_STATIC) + list(APPEND _MISSING_STATIC_LIBS libc) message(WARNING ${WARNING_STATIC_BUILD}) endif() # NOT HAVE_LIBC_STATIC

@@ -152,6 +167,19 @@ else() # HAVE_BSD_STRING_H AND ...

set(NIMISEWI_CGI_STATIC_BUILD TRUE) endif() # HAVE_BSD_STRING_H AND ... endif() # HAVE_LIBBSD_STATIC + +# options + +option(NIMISEWI_STATIC_BUILD "build static version of nimisewi" OFF) +if(NIMISEWI_STATIC_BUILD) + if(NIMISEWI_CGI_STATIC_BUILD) + target_link_options(nimisewi.cgi PUBLIC -static) + else() # NIMISEWI_CGI_STATIC_BUILD + message(SEND_ERROR + "missing ${_MISSING_STATIC_LIBS}. will not link statically. \ + consider installing such libraries or switching off this option") + endif() # NIMISEWI_CGI_STATIC_BUILD +endif() # NIMISEWI_STATIC_BUILD # optional binaries
M main.cmain.c

@@ -43,7 +43,7 @@ if (argc == 2) {

if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) { printf("%s\n", PACKAGE_STRING); printf("%s\n", PACKAGE_DESCRIPTION); - printf("compiled on %s %s using %s (%d-bit)\n", + printf("compiled on %s %s using %s (%lu-bit)\n", __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); #ifdef HAVE_PLEDGE printf("HAVE_PLEDGE\n");