zygo

ncurses gopher client
Log | Files | Refs

commit a8b1844f2fb55c57dc179ef1bf6967e2012e3a7d
parent a661e29f3bc5c3106f36f03e217bc24482d437d2
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 16 Jan 2022 13:07:22 +0000

Makefile configure: use configure script

Diffstat:
MMakefile | 2+-
Dconfig.mk | 12------------
Aconfigure | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile @@ -23,7 +23,7 @@ include config.mk $(BIN): $(OBJ) $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJ) -$(OBJ): Makefile zygo.h +$(OBJ): Makefile config.mk zygo.h .c.o: $(CC) $(CFLAGS) -c $< -o $@ diff --git a/config.mk b/config.mk @@ -1,12 +0,0 @@ -# Public domain - -# debug -# CFLAGS += -g3 -O0 -DDEBUG -# SRC += debug.c - -# tls -LDFLAGS += -ltls -SRC += tls.c - -# plain -# SRC += plain.c diff --git a/configure b/configure @@ -0,0 +1,57 @@ +#!/bin/sh + +CC=${CC:-cc} + +trap "rm -f test.c test" EXIT +echo "# Generated by configure" > config.mk + +printf '%s' "checking for libtls... " +cat > test.c <<- EOF + #include <tls.h> + int main(void) { return 0; } +EOF +${CC} -ltls -o test test.c >/dev/null 2>/dev/null && { + printf '%s\n' "yes" + cat >> config.mk <<- EOF + # libretls or libtls (standalone tls.h implementation) configuration + LDFLAGS += -ltls + SRC += tls.c + EOF +} || { + printf '%s\n' "no" + cat >> config.mk <<- EOF + # no TLS configured + # install libretls or libtls (standalone tls.h implementation) for TLS + SRC += plain.c + EOF +} + +printf '%s' "checking for libtinfow... " +cat > test.c <<- EOF + #include <ncurses.h> + int main(void) { return 0; } +EOF +${CC} -ltinfow -o test test.c >/dev/null 2>/dev/null && { + printf '%s\n' "yes" + hastinfow=1 +} || { + printf '%s\n' "no" + hastinfow=0 +} + +[ $hastinfow -eq 1 ] && { + printf '%s' "should link with libtinfow... " + cat > test.c <<- EOF + #include <ncurses.h> + int main(void) { initscr(); endwin(); return 0; } + EOF + ${CC} -ltinfow -o test test.c >/dev/null 2>/dev/null && ./test >/dev/null 2>/dev/null && { + printf '%s\n' "yes" + cat >> config.mk <<- EOF + # linking with tinfow + # on some systems both ncursesw and tinfow must be linked + # otherwise, thank ncurses for the nondescript segfault in initscr()... + LDFLAGS += -ltinfow + EOF + } || printf '%s\n' "no" +}