hirc

[archived] IRC client
git clone https://hhvn.uk/hirc
git clone git://hhvn.uk/hirc
Log | Files | Refs

configure (3192B)


      1 #!/bin/sh
      2 #
      3 # configure from hirc
      4 #
      5 # Copyright (c) 2021-2022 hhvn <dev@hhvn.uk>
      6 #
      7 # Permission to use, copy, modify, and distribute this software for any
      8 # purpose with or without fee is hereby granted, provided that the above
      9 # copyright notice and this permission notice appear in all copies.
     10 #
     11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18 
     19 CC=${CC:-cc}
     20 
     21 trap "rm -f test.c test" EXIT
     22 echo "# Generated by configure" > config.mk
     23 
     24 printf '%s' "checking for libtls... "
     25 cat > test.c <<- EOF
     26 	#include <tls.h>
     27 	int main(void) { return 0; }
     28 EOF
     29 ${CC} -ltls -o test test.c >/dev/null 2>/dev/null && {
     30 	printf '%s\n' "yes"
     31 	cat >> config.mk <<- EOF
     32 		# libretls or libtls (standalone tls.h implementation) configuration
     33 		LDFLAGS	+= -ltls
     34 		CFLAGS	+= -DTLS
     35 	EOF
     36 } || {
     37 	printf '%s\n' "no"
     38 	cat >> config.mk <<- EOF
     39 		# no TLS configured
     40 		# install libretls or libtls (standalone tls.h implementation) for TLS
     41 	EOF
     42 }
     43 
     44 printf '%s' "checking for libtinfow... "
     45 cat > test.c <<- EOF
     46 	#include <ncurses.h>
     47 	int main(void) { return 0; }
     48 EOF
     49 ${CC} -ltinfow -o test test.c >/dev/null 2>/dev/null && {
     50 	printf '%s\n' "yes"
     51 	cat >> config.mk <<- EOF
     52 		# linking with tinfow
     53 		# on some systems both ncursesw and tinfow must be linked
     54 		# otherwise, thank ncurses for the nondescript segfault in initscr()...
     55 		LDFLAGS += -ltinfow
     56 	EOF
     57 } || {
     58 	printf '%s\n' "no"
     59 }
     60 
     61 printf '%s' "checking for strlcpy... "
     62 cat > test.c <<- EOF
     63 	#include <string.h>
     64 	int main(void) { char a[2]; strlcpy(a, "hello", sizeof(a)); return 0; }
     65 EOF
     66 ${CC} -o test test.c >/dev/null 2>/dev/null && ./test >/dev/null 2>/dev/null && {
     67 	printf '%s\n' "yes"
     68 } || {
     69 	printf '%s\n' "no"
     70 	cat >> config.mk <<- EOF
     71 		# linking an included version of strlcpy, as your system doesn't have it
     72 		CFLAGS	+= -DHIRC_STRLCPY
     73 		SRC	+= src/openbsd/strlcpy.c
     74 	EOF
     75 }
     76 
     77 printf '%s' "checking for strlcat... "
     78 cat > test.c <<- EOF
     79 	#include <string.h>
     80 	int main(void) { char a[3] = {'a', '\0', '\0'}; strlcat(a, "bc", sizeof(a)); return 0; }
     81 EOF
     82 ${CC} -o test test.c >/dev/null 2>/dev/null && ./test >/dev/null 2>/dev/null && {
     83 	printf '%s\n' "yes"
     84 } || {
     85 	printf '%s\n' "no"
     86 	cat >> config.mk <<- EOF
     87 		# linking an included version of strlcat, as your system doesn't have it
     88 		CFLAGS	+= -DHIRC_STRLCAT
     89 		SRC	+= src/openbsd/strlcat.c
     90 	EOF
     91 }
     92 
     93 printf '%s' "checking for wcslcpy... "
     94 cat > test.c <<- EOF
     95 	#include <wchar.h>
     96 	int main(void) { wchar_t a[2]; wcslcpy(a, L"hello", sizeof(a)); return 0; }
     97 EOF
     98 ${CC} -o test test.c >/dev/null 2>/dev/null && ./test >/dev/null 2>/dev/null && {
     99 	printf '%s\n' "yes"
    100 } || {
    101 	printf '%s\n' "no"
    102 	cat >> config.mk <<- EOF
    103 		# linking an included version of wcslcpy, as your system doesn't have it
    104 		CFLAGS	+= -DHIRC_WCSLCPY
    105 		SRC	+= src/openbsd/wcslcpy.c
    106 	EOF
    107 }