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
ELK_INCLUDE_DIR = $(PREFIX)/include
ELK_LIB_DIR = $(PREFIX)/lib
CTAGS = ctags -t -w
INSTALL = install
MAKEDEPEND = makedepend
### You need a C compiler that compiles ANSI C code.
CC = gcc CC = gcc
CFLAGS = -Wall -pedantic -O CFLAGS = -Wall -pedantic -O -I $(ELK_INCLUDE_DIR)
LDFLAGS = -L $(ELK_LIB_DIR) -lm -lelk
### If you need additional linker flags add them here.
LDFLAGS =
### 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
### The directory under which you will install the Scheme files. ### 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. DEFAULT_FORMAT = html
FORMAT = html
INCLUDE = -I $(ELK_INCLUDE_DIR)
DEFS = -D DEFAULT_DIR=\"$(DEFAULT_DIR)\" -D DEFAULT_FORMAT=\"$(DEFAULT_FORMAT)\"
### 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
SOURCES = \ SOURCES = \
args.c\ args.c\
@ -67,27 +54,37 @@ OBJECTS = \
stream.o\ stream.o\
subst.o\ subst.o\
table.o\ table.o\
unroff.o\ unroff.o
$(ELK)
ALL = unroff all: unroff
all: $(ALL) unroff: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS)
.c.o: .c.o:
$(CC) $(CFLAGS) $(INCLUDE) $(DEFS) -c $< $(CC) $(CFLAGS) $(INCLUDE) $(DEFS) -c $<
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
clean: clean:
rm -f *.o $(ALL) rm -f $(OBJECTS) unroff
tags ctags: $(SOURCES) tags ctags: $(SOURCES)
$(CTAGS) $(SOURCES) $(CTAGS) $(SOURCES)
unroff: $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS)
depend: Makefile $(SOURCES) depend: Makefile $(SOURCES)
$(MAKEDEP) $(INCLUDE) $(SOURCES) $(MAKEDEPEND) $(INCLUDE) $(SOURCES)
.PHONY: all clean ctags depend install tags
# DO NOT DELETE THIS LINE -- make depend depends on it. # DO NOT DELETE THIS LINE -- make depend depends on it.