tUse suckless-style makefile and config.mk - ve - a minimal text editor (work in progress)
 (HTM) git clone git://src.adamsgaard.dk/ve
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 1bc14ba4486a54f84e5ddfe2a6b67da1479e0e60
 (DIR) parent 7a8cfc0fc10085e622932f958235613b9ca8e149
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Wed,  7 Aug 2019 22:00:35 +0200
       
       Use suckless-style makefile and config.mk
       
       Diffstat:
         M Makefile                            |      33 +++++++++++++++++++++-----------
         A config.mk                           |      11 +++++++++++
         M ve.c                                |       9 +--------
       
       3 files changed, 34 insertions(+), 19 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       t@@ -1,13 +1,15 @@
        .POSIX:
        
       +include config.mk
       +
        CFLAGS = -g -std=c99 -pedantic -Wall -Wextra
        LDFLAGS = 
        SRC = ve.c
        OBJ = $(SRC:.c=.o)
        BIN = ve
       +VECFLAGS = -DVERSION=\"$(VERSION)\" -DPROGNAME=\"$(BIN)\" -D_DEFAULT_SOURCE $(CFLAGS)
        
        PREFIX ?= /usr/local
       -INSTALL ?= install
        STRIP ?= strip
        
        default: $(BIN)
       t@@ -15,23 +17,32 @@ default: $(BIN)
        $(BIN): $(OBJ)
                $(CC) $(LDFLAGS) $(OBJ) -o $@
        
       +.c.o:
       +        $(CC) $(VECFLAGS) -c $<
       +
       +options:
       +        @echo $(BIN) build options:
       +        @echo "CFLAGS   = $(VECFLAGS)"
       +        @echo "LDFLAGS  = $(LDFLAGS)"
       +        @echo "CC       = $(CC)"
       +
        install: $(BIN)
                $(STRIP) $(BIN)
       -        $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin
       -        $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin
       +        mkdir -p $(DESTDIR)$(PREFIX)/bin
       +        mkdir -p $(DESTDIR)$(MANPREFIX)/man1
       +        mkdir -p $(DESTDIR)$(DOCPREFIX)/$(BIN)
       +        install -m 644 README LICENSE $(DESTDIR)$(DOCPREFIX)/$(BIN)
       +        install -m 775 $(BIN) $(DESTDIR)$(PREFIX)/bin
       +        sed "s/VERSION/$(VERSION)/g" < $(BIN).1 > $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
       +        chmod 644 $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
        
        uninstall:
                $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
       -
       -test: $(BIN)
       -        make -C test/
       -
       -memtest: $(BIN)
       -        valgrind --error-exitcode=1 --leak-check=full $(BIN) -h
       -        valgrind --error-exitcode=1 --leak-check=full $(BIN) -v
       +        $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1
       +        $(RM) -r $(DESTDIR)$(DOCPREFIX)/$(BIN)
        
        clean:
                $(RM) *.o
                $(RM) $(BIN)
        
       -.PHONY: default install uninstall test memtest clean
       +.PHONY: default install uninstall clean options
 (DIR) diff --git a/config.mk b/config.mk
       t@@ -0,0 +1,11 @@
       +# Customize to fit your system
       +VERSION = 0.1.0
       +
       +# paths
       +PREFIX    = /usr/local
       +MANPREFIX = ${PREFIX}/share/man
       +DOCPREFIX = ${PREFIX}/share/doc
       +
       +# build config
       +CFLAGS = -g -std=c99 -pedantic -Wall -Wextra
       +LDFLAGS = 
 (DIR) diff --git a/ve.c b/ve.c
       t@@ -1,10 +1,5 @@
        /* see LICENSE for license details */
        
       -/* add feature test macro for getline and strdup compatibility */
       -#define _DEFAULT_SOURCE
       -#define _BSD_SOURCE
       -#define _GNU_SOURCE
       -
        #include <ctype.h>
        #include <errno.h>
        #include <fcntl.h>
       t@@ -21,8 +16,6 @@
        
        
        /* macros */
       -#define PROGNAME "ve"
       -#define VERSION "0.0.1"
        #define TAB_WIDTH 4
        #define STATUS_MESSAGE_TIMEOUT 3
        #define ABUF_INIT {NULL, 0}
       t@@ -1051,7 +1044,7 @@ main(int argc, char* argv[])
                        file_open(argv[1]);
                }
        
       -        editor_set_status_message("%s v%s", PROGNAME, VERSION);
       +        editor_set_status_message("%s %s", PROGNAME, VERSION);
        
                while (1) {
                        editor_refresh_screen();