Rewrite Makefile

Sweeping changes; the old Makefile was rudimentary and buggy.

NB: makedepend is optional. You don't need to run it.
This commit is contained in:
Lassi Kortela 2023-02-15 14:31:59 +02:00
parent 00a2baa9ca
commit 0d0d0afbfd
1 changed files with 38 additions and 41 deletions

View File

@ -1,39 +1,26 @@
# $Revision: 1.12 $
PREFIX = $$HOME/.local
BINDIR = $(PREFIX)/bin
DATADIR = $(PREFIX)/share
### You need a C compiler that compiles ANSI C code.
CC = gcc
CFLAGS = -Wall -pedantic -O
ELK_INCLUDE_DIR = $(PREFIX)/include
ELK_LIB_DIR = $(PREFIX)/lib
### If you need additional linker flags add them here.
LDFLAGS =
CTAGS = ctags -t -w
INSTALL = install
MAKEDEPEND = makedepend
### The directory where the Elk installation resides on your system.
ELKDIR = /usr/elk
### Additional libraries. You may want to insert the output of the
### shell-script $(ELKDIR)/lib/ldflags here.
LIBS = -lm
### The makedepend program (it's usually installed with the X11 binaries).
MAKEDEP = makedepend
CC = gcc
CFLAGS = -Wall -pedantic -O -I $(ELK_INCLUDE_DIR)
LDFLAGS = -L $(ELK_LIB_DIR) -lm -lelk
### The directory under which you will install the Scheme files.
DIR = /usr/local/lib/unroff
DEFAULT_DIR = $(DATADIR)/unroff
SCMDIR = $(DATADIR)/unroff/scm
### The default output format.
FORMAT = html
DEFAULT_FORMAT = html
### End of configurable variables.
### -------------------------------------------------------------------------
SHELL = /bin/sh
INCLUDE = -I$(ELKDIR)/include
ELK = $(ELKDIR)/lib/module.o
DEFS = -DDEFAULT_DIR=\"$(DIR)\" -DDEFAULT_FORMAT=\"$(FORMAT)\"
CTAGS = ctags -t -w
INCLUDE = -I $(ELK_INCLUDE_DIR)
DEFS = -D DEFAULT_DIR=\"$(DEFAULT_DIR)\" -D DEFAULT_FORMAT=\"$(DEFAULT_FORMAT)\"
SOURCES = \
args.c\
@ -67,27 +54,37 @@ OBJECTS = \
stream.o\
subst.o\
table.o\
unroff.o\
$(ELK)
unroff.o
ALL = unroff
all: unroff
all: $(ALL)
unroff: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS)
.c.o:
$(CC) $(CFLAGS) $(INCLUDE) $(DEFS) -c $<
clean:
rm -f *.o $(ALL)
install: unroff
$(INSTALL) unroff $(BINDIR)/unroff
mkdir -p $(SCMDIR)
mkdir -p $(SCMDIR)/html
mkdir -p $(SCMDIR)/misc
$(INSTALL) -m 644 ../scm/html/common.scm $(SCMDIR)/html/common.scm
$(INSTALL) -m 644 ../scm/html/m.scm $(SCMDIR)/html/m.scm
$(INSTALL) -m 644 ../scm/html/man.scm $(SCMDIR)/html/man.scm
$(INSTALL) -m 644 ../scm/html/ms.scm $(SCMDIR)/html/ms.scm
$(INSTALL) -m 644 ../scm/misc/hyper.scm $(SCMDIR)/misc/hyper.scm
$(INSTALL) -m 644 ../scm/troff.scm $(SCMDIR)/troff.scm
tags ctags: $(SOURCES)
clean:
rm -f $(OBJECTS) unroff
tags ctags: $(SOURCES)
$(CTAGS) $(SOURCES)
unroff: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
depend: Makefile $(SOURCES)
$(MAKEDEP) $(INCLUDE) $(SOURCES)
depend: Makefile $(SOURCES)
$(MAKEDEPEND) $(INCLUDE) $(SOURCES)
.PHONY: all clean ctags depend install tags
# DO NOT DELETE THIS LINE -- make depend depends on it.