From 8ef0b47703a5669980a66bca2fee3b8fec68241f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannick=20Duch=C3=AAne?= Date: Thu, 7 May 2020 20:34:01 +0200 Subject: [PATCH 1/2] Makefile-alt with CURSESCFLAGS and CURSESLIBS options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An alternate Makefile better suited to people using `pkg-config` for their ncurses library (the one on my Ubuntu 16.04 32bits is obsolete, it is still v5 while MTM expects v6). I could have added an invocation to `pkg-config`, but it makes it more general if it just use two `CURSESCFLAGS` and `CURSESLIBS`. Not `CURSESLIBS` is not always just a matter of paths, it may be a matter of linker options. Ex for me, `pkg-config` says: $ pkg-config --cflags ncursesw > -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/home/yannick/apps/ncurses/include/ncursesw -I/home/yannick/apps/ncurses/include $ pkg-config --libs ncursesw > -L/home/yannick/apps/ncurses/lib -Wl,-rpath,/home/yannick/apps/ncurses/lib -lncursesw Note the `-Wl,-rpath …` part, which is why a library path is not always enough. For a custom ncurses library, an `-I…` option is also required for the C compilation. This is why I’m proposing alternate Makefile addition, with `CURSESCFLAGS` and `CURSESLIBS` options. --- Makefile-alt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Makefile-alt diff --git a/Makefile-alt b/Makefile-alt new file mode 100644 index 0000000..b6aa5da --- /dev/null +++ b/Makefile-alt @@ -0,0 +1,32 @@ +CC ?= gcc +CFLAGS ?= -std=c99 -Wall -Wextra -pedantic -Os +CURSESCFLAGS ?= +CURSESLIBS ?= -lncursesw +DESTDIR ?= /usr/local +MANDIR ?= $(DESTDIR)/man/man1 + +CFLAGS := $(CFLAGS) $(CURSESCFLAGS) +LIBS := -lutil $(CURSESLIBS) +FEATURES := -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED + +all: mtm + +mtm: vtparser.c mtm.c config.h + echo $(CC) $(CFLAGS) $(FEATURES) -o $@ vtparser.c mtm.c $(LIBS) + $(CC) $(CFLAGS) $(FEATURES) -o $@ vtparser.c mtm.c $(LIBS) + strip -s mtm + +config.h: config.def.h + cp -i config.def.h config.h + +install: mtm + mkdir -p $(DESTDIR)/bin + mkdir -p $(MANDIR) + cp mtm $(DESTDIR)/bin + cp mtm.1 $(MANDIR) + +install-terminfo: mtm.ti + tic -s -x mtm.ti + +clean: + rm -f *.o mtm From 527a98985ddba02d7ec275fbe4b646efd561051b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannick=20Duch=C3=AAne?= Date: Thu, 7 May 2020 20:43:39 +0200 Subject: [PATCH 2/2] Update Makefile-alt Oops --- Makefile-alt | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile-alt b/Makefile-alt index b6aa5da..ebb2b63 100644 --- a/Makefile-alt +++ b/Makefile-alt @@ -12,7 +12,6 @@ FEATURES := -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EX all: mtm mtm: vtparser.c mtm.c config.h - echo $(CC) $(CFLAGS) $(FEATURES) -o $@ vtparser.c mtm.c $(LIBS) $(CC) $(CFLAGS) $(FEATURES) -o $@ vtparser.c mtm.c $(LIBS) strip -s mtm