hirc

IRC client
Log | Files | Refs

commit 42e5fa5c901ed48bb93e2037291db7cee78ca88a
parent 9596c9c231126604c4d257c16955d4c694bfd467
Author: hhvn <dev@hhvn.uk>
Date:   Thu,  2 Dec 2021 20:15:57 +0000

Makefile configure .gitignore: seamless configure script

Diffstat:
M.gitignore | 1+
MMakefile | 15+++++++--------
Aconfigure | 31+++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,4 @@ hirc hirc.1 *.o +config.mk diff --git a/Makefile b/Makefile @@ -9,17 +9,16 @@ OBJ = main.o handle.o hist.o nick.o \ config.o strlcpy.o MAN = hirc.1 COMMIT = $(shell git log HEAD...HEAD~1 --pretty=format:%h) - -# Comment to disable TLS -LDTLS = -ltls -CTLS = -DTLS - CFLAGS = -g -O0 $(CTLS) -LDFLAGS = -lncursesw $(LDTLS) -# Gentoo and other distributions/OSes may need -ltinfow +LDFLAGS = -lncursesw + +include config.mk all: $(BIN) $(MAN) +config.mk: + ./configure + $(BIN): $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) @@ -40,7 +39,7 @@ uninstall: -rm -f $(MANDIR)/man1/$(MAN) clean: - -rm -f $(OBJ) $(MAN) $(BIN) + -rm -f config.mk $(OBJ) $(MAN) $(BIN) .c.o: $(CC) $(CFLAGS) -c $< diff --git a/configure b/configure @@ -0,0 +1,31 @@ +#!/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 + LDFLAGS += -ltls + CFLAGS += -DTLS + EOF +} || printf '%s\n' "no" + +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" + cat >> config.mk <<- EOF + LDFLAGS += -ltinfow + EOF +} || printf '%s\n' "no"