Split configuration into config.mk and config.h. - sam - An updated version of the sam text editor.
 (HTM) git clone git://vernunftzentrum.de/sam.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit f7f1341bbf15cc480b78f20957aefee7d81fcf62
 (DIR) parent d411e3e2206e3534e76c0b4540c705087cc4520d
 (HTM) Author: Rob King <jking@deadpixi.com>
       Date:   Thu, 11 Aug 2016 12:55:50 -0500
       
       Split configuration into config.mk and config.h.
       
       This makes things considerably cleaner.
       
       Also remove lots of unused variables and constants.
       
       Diffstat:
         README.rst                          |       2 +-
         config.mk                           |      17 -----------------
         libXg/latin1.c                      |       6 ++++--
         rsam/rsam.c                         |       4 +++-
         sam/Makefile                        |      16 ++--------------
         sam/io.c                            |       2 +-
         sam/sam.c                           |      10 +++++-----
         sam/sam.h                           |      11 +----------
         sam/shell.c                         |       2 +-
         sam/unix.c                          |      10 ----------
         samterm/Makefile                    |       5 ++---
         samterm/main.c                      |      21 ---------------------
         samterm/samterm.h                   |       2 ++
         samterm/unix.c                      |       4 +---
       
       14 files changed, 23 insertions(+), 89 deletions(-)
       ---
 (DIR) diff --git a/README.rst b/README.rst
       @@ -21,7 +21,7 @@ Installation
        
        Basic Installation
        -------------------
       -Installation is fairly simple: edit config.mk and then run make install.
       +Installation is fairly simple: edit `config.mk` and `config.h` and then run make install.
        
        The `sam` command runs sam.
        The `B` command adds a new file to a running instance of sam, or starts sam if it's not already running.
 (DIR) diff --git a/config.mk b/config.mk
       @@ -10,22 +10,6 @@ BINDIR?=$(DESTDIR)/bin
        # MANDIR is where manual pages go
        MANDIR?=$(DESTDIR)/share/man/man1
        
       -# USE64BITS should be 1 for little-endian architectures with 64-bit pointers,
       -# 2 for big-endian architectures with 64-bit pointers, and 0 otherwise.
       -# x86_64 systems would generally use 1 here, while DEC Alpha systems would
       -# generally use 2.
       -USE64BITS?=1
       -
        # FREETYPEINC should name the directory of your freetype2 includes.
        FREETYPEINC?=/usr/include/freetype2
        
       -# TMPDIR should be set to a directory for temporary files with lots of room
       -TMPDIR?=/tmp
       -
       -# If you want to have keyboard control of dot's position, set the following
       -# variables to the appropriate ASCII control codes. The default values
       -# emulate the WordStar diamond. Setting any command to zero disables it.
       -LINEUP=0x05
       -LINEDOWN=0x18
       -CHARLEFT=0x13
       -CHARRIGHT=0x04
       -\ No newline at end of file
 (DIR) diff --git a/libXg/latin1.c b/libXg/latin1.c
       @@ -5,6 +5,8 @@
        #include <stdlib.h>
        #include <string.h>
        
       +#include "../config.h"
       +
        #define MAPPING_MAX 65535
        
        struct latin
       @@ -235,10 +237,10 @@ void
        initlatin(void)
        {
                FILE *keyboard = NULL;
       -        if (getenv("HOME"))
       +        if (getenv(HOMEENV))
                {
                        char path[1024] = {0};
       -                snprintf(path, 1023, "%s/.keyboard", getenv("HOME"));
       +                snprintf(path, 1023, "%s/.keyboard", getenv(HOMEENV));
                        keyboard = fopen(path, "r");
                }
        
 (DIR) diff --git a/rsam/rsam.c b/rsam/rsam.c
       @@ -14,6 +14,8 @@
        #include <sys/types.h>
        #include <unistd.h>
        
       +#include "../config.h"
       +
        #define PARENT_READ        readpipe[0]
        #define CHILD_WRITE        readpipe[1]
        #define CHILD_READ        writepipe[0]
       @@ -35,7 +37,7 @@ cleanup(void)
        int
        main(int argc, char **argv)
        {
       -        const char *home         = getenv("HOME") ? getenv("HOME") : "/tmp";
       +        const char *home         = getenv(HOMEENV) ? getenv(HOMEENV) : "/tmp";
                long        pathmax      = pathconf(home, _PC_PATH_MAX) != -1 ? pathconf(home, _PC_PATH_MAX) : PATH_MAX;
                int         writepipe[2] = {-1};
                int         readpipe[2]  = {-1};
 (DIR) diff --git a/sam/Makefile b/sam/Makefile
       @@ -12,16 +12,12 @@
        #
        include ../config.mk
        
       -#        If your system has 64-bit addresses, add -DUSE64BITS to $(OS).
       -OS=-DIRIX5 -DUSE64BITS=$(USE64BITS)
       +OS=-DIRIX5
        
        #        add -Iincludedir for any include directories that need to be searched
        #        for posix header files (for UMIPS, add -I/usr/include/posix)
        INCS=-I../include
        
       -#        Set the name of the environment variable containing the user's home directory
       -HOMEDIR=HOME
       -
        #        RSAMNAME and TERMNAME contain the names of the files containing the
        #        sam and samterm executables, respectively.  SAMDIR is the directory
        #        where sam is to be installed.  SAMSAVEDIR is the name of the directory
       @@ -31,9 +27,6 @@ TERMNAME=samterm
        SAMDIR=$(BINDIR)
        SAMSAVEDIR=$(BINDIR)
        
       -#        Set TMP to a good place for tmp files (with lots of room)
       -TMP=$(TMPDIR)
       -
        #        Set SHELLNAME and SHELLPATH to the name of a shell and the pathname
        #        of its executable
        SHELLNAME=sh
       @@ -49,12 +42,7 @@ RXSAMNAME=rsam
        
        SAMSAVE=/bin/sh\\n$(SAMSAVEDIR)/samsave
        
       -CFLAGS=$(OS) -D_LIBXG_EXTENSION $(INCS)\
       -                -DHOMEDIR=\"$(HOMEDIR)\" -DRSAMNAME=\"$(RSAMNAME)\" \
       -                -DTERMNAME=\"$(TERMNAME)\" -DTMP=\"$(TMP)\" \
       -                -DSHELLNAME=\"$(SHELLNAME)\" -DSHELLPATH=\"$(SHELLPATH)\" \
       -                -DRXNAME=\"$(RXNAME)\" -DRXPATHNAME=\"$(RXPATHNAME)\" \
       -                -DRXSAMNAME=\"$(RXSAMNAME)\" -DSAMSAVE=\"$(SAMSAVE)\"
       +CFLAGS=$(OS) -D_LIBXG_EXTENSION $(INCS)
        
        LIB=../libframe/libframe.a ../libXg/libXg.a
        CC?=gcc 
 (DIR) diff --git a/sam/io.c b/sam/io.c
       @@ -233,7 +233,7 @@ connectto(char *machine)
                        close(p1[1]);
                        close(p2[0]);
                        close(p2[1]);
       -                execl(getenv("RSH") ? getenv("RSH") : RXPATH, getenv("RSH") ? getenv("RSH") : RX, machine, rsamname, "-R", (char*)0);
       +                execl(getenv("RSH") ? getenv("RSH") : RXPATH, getenv("RSH") ? getenv("RSH") : RXPATH, machine, rsamname, "-R", (char*)0);
                        dprint("can't exec %s\n", RXPATH);
                        exits("exec");
        
 (DIR) diff --git a/sam/sam.c b/sam/sam.c
       @@ -28,8 +28,8 @@ char        *machine;
        char        *home;
        int        bpipeok;
        int        termlocked;
       -char        *samterm = SAMTERM;
       -char        *rsamname = RSAM;
       +char        *samterm = "samterm";
       +char        *rsamname = "rsam";
        
        Rune        baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'};
        
       @@ -62,7 +62,7 @@ main(int argc, char *argv[])
        
                    case 'r':
                        machine = optarg;
       -                rsamname = RXSAMNAME;
       +                rsamname = "rsam";
                        arg[targc++] = "-r";
                        arg[targc++] = optarg;
                        break;
       @@ -95,7 +95,7 @@ main(int argc, char *argv[])
                Strinit0(&wd);
                tempfile.listptr = emalloc(0);
                Strinit0(&plan9cmd);
       -        home = getenv(HOME);
       +        home = getenv(HOMEENV);
                if(home == 0)
                        home = "/";
                if(!dflag)
       @@ -157,7 +157,7 @@ rescue(void)
                                free(c);
                        }else
                                sprint(buf, "nameless.%d", nblank++);
       -                fprint(io, "#!%s '%s' $* <<'---%s'\n", SAMSAVECMD, buf, buf);
       +                fprint(io, "#!%s '%s' $* <<'---%s'\n", "samsave", buf, buf);
                        addr.r.p1 = 0, addr.r.p2 = f->nrunes;
                        writeio(f);
                        fprint(io, "\n---%s\n", (char *)buf);
 (DIR) diff --git a/sam/sam.h b/sam/sam.h
       @@ -2,6 +2,7 @@
        #include <u.h>
        #include <libc.h>
        #include "errors.h"
       +#include "../config.h"
        
        /*
         * BLOCKSIZE is relatively small to keep memory consumption down.
       @@ -344,16 +345,6 @@ extern Rune        samname[];        /* compiler dependent */
        extern Rune        *left[];
        extern Rune        *right[];
        
       -extern char        RSAM[];                /* system dependent */
       -extern char        SAMTERM[];
       -extern char        HOME[];
       -extern char        TMPDIR[];
       -extern char        SH[];
       -extern char        SHPATH[];
       -extern char        RX[];
       -extern char        RXPATH[];
       -extern char        SAMSAVECMD[];
       -
        extern char        *rsamname;        /* globals */
        extern char        *samterm;
        extern Rune        genbuf[];
 (DIR) diff --git a/sam/shell.c b/sam/shell.c
       @@ -93,7 +93,7 @@ plan9(File *f, int type, String *s, int nest)
                                close(0);        /* so it won't read from terminal */
                                open("/dev/null", 0);
                        }
       -                execl(SHPATH, SH, "-c", Strtoc(&plan9cmd), (char *)0);
       +                execl(SHPATH, SHPATH, "-c", Strtoc(&plan9cmd), (char *)0);
                        exits("exec");
                }
                if(pid == -1)
 (DIR) diff --git a/sam/unix.c b/sam/unix.c
       @@ -22,16 +22,6 @@ static Rune r2[] = {'\n', 0};
        static Rune r3[] = {'\'', '"', '`', 0};
        Rune *right[]= { r1, r2, r3, 0};
        
       -char        RSAM[] = RSAMNAME;
       -char        SAMTERM[] = TERMNAME;
       -char        HOME[] = HOMEDIR;
       -char        TMPDIR[] = TMP;
       -char        SH[] = SHELLNAME;
       -char        SHPATH[] = SHELLPATH;
       -char        RX[] = RXNAME;
       -char        RXPATH[] = RXPATHNAME;
       -char        SAMSAVECMD[] = SAMSAVE;
       -
        void
        print_ss(char *s, String *a, String *b)
        {
 (DIR) diff --git a/samterm/Makefile b/samterm/Makefile
       @@ -13,8 +13,7 @@
        
        include ../config.mk
        
       -#        If your system has 64-bit addresses, add -DUSE64BITS to $(OS).
       -OS=-DIRIX5  -DUSE64BITS=$(USE64BITS)
       +OS=-DIRIX5
        
        #        add -Iincludedir for any include directories that need to be searched
        #        for posix header files (for UMIPS, add -I/usr/include/posix)
       @@ -28,7 +27,7 @@ SAMTERM=$(BINDIR)/samterm
        #        or if you need extra libraries to load with X11 applications
        XLIBS=-lXt -lX11 -lXft
        
       -CFLAGS=$(OS) $(INCS) -D_LIBXG_EXTENSION -DLINEUP=$(LINEUP) -DLINEDOWN=$(LINEDOWN) -DCHARLEFT=$(CHARLEFT) -DCHARRIGHT=$(CHARRIGHT)
       +CFLAGS=$(OS) $(INCS) -D_LIBXG_EXTENSION
        
        LIBS=../libframe/libframe.a ../libXg/libXg.a
        CC?=gcc
 (DIR) diff --git a/samterm/main.c b/samterm/main.c
       @@ -28,22 +28,6 @@ int        chord = 0;
        char *machine = "localhost";
        int nofifo = 0;
        
       -#ifndef LINEUP
       -#define LINEUP 0x00
       -#endif
       -
       -#ifndef LINEDOWN
       -#define LINEDOWN 0x00
       -#endif
       -
       -#ifndef CHARLEFT
       -#define CHARLEFT 0x00
       -#endif
       -
       -#ifndef CHARRIGHT
       -#define CHARRIGHT 0x00
       -#endif
       -
        void
        main(int argc, char *argv[])
        {
       @@ -486,11 +470,6 @@ flushtyping(int clearesc)
                XFlush(_dpy);
        }
        
       -#define SCROLLKEY        0x80
       -#define UPKEY                0x81
       -#define ESC                0x1B
       -#define COMMANDKEY        0x0B
       -
        void
        type(Flayer *l, int res)        /* what a bloody mess this is */
        {
 (DIR) diff --git a/samterm/samterm.h b/samterm/samterm.h
       @@ -1,6 +1,8 @@
        /* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
        #define        SAMTERM
        
       +#include "../config.h"
       +
        #define        RUNESIZE        sizeof(Rune)
        #define        MAXFILES        256
        #define        NL        5
 (DIR) diff --git a/samterm/unix.c b/samterm/unix.c
       @@ -89,15 +89,13 @@ extstart(void)
        
        #ifndef        NOFIFO
                extern char *machine;
       -        char        *disp;
                char        *user;
                char        *home;
                int        fd;
                int        flags;
        
                user = getuser();
       -        disp = getenv("DISPLAY");
       -        home = getenv("HOME");
       +        home = getenv(HOMEENV);
        
                if (home == NULL)
                {