-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (68 loc) · 2.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Makefile
SHELL := /bin/bash
OS := $(shell uname -s)
ifeq ($(findstring gcc, $(CC)), gcc)
CFLAGS = -O2 -ansi
else
CFLAGS = -O2 -std=c89
endif
CC = gcc
V = 0
PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man/man6
LIB = $(PREFIX)/share/inform615
MAIN = inform
# collect all source .c files
SRC = $(wildcard src/*.c)
# change suffixes from .c to .o
OBJ = $(SRC:.c=.o)
.c.o:
ifeq ($V, 0)
@echo " CC " $*.o
@$(CC) $(CFLAGS) -c $*.c -o $*.o
else
$(CC) $(CFLAGS) -c $*.c -o $*.o
endif
$(MAIN): $(OBJ)
ifeq ($V, 0)
@echo " CCLD " $@
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
else
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
endif
@strip $(MAIN)
.PHONY: clean
clean:
rm -f $(OBJ) $(MAIN)
.PHONY: install
install:
install -d $(DESTDIR)$(PREFIX)/bin
install -d $(DESTDIR)$(MANDIR)
install -d $(DESTDIR)$(LIB)
install -d $(DESTDIR)$(LIB)/{bin,demos,minform,tutor}
install -c -m 755 $(MAIN) $(DESTDIR)$(PREFIX)/bin
install -c -m 755 bin/inf $(DESTDIR)$(PREFIX)/bin
install -c -m 644 bin/a8.bin $(DESTDIR)$(LIB)/bin
install -c -m 644 demos/minform.inf $(DESTDIR)$(LIB)/demos
install -c -m 644 minform/* $(DESTDIR)$(LIB)/minform
install -c -m 644 tutor/* $(DESTDIR)$(LIB)/tutor
install -c -m 644 inf.6 $(DESTDIR)$(MANDIR)
gzip $(DESTDIR)$(MANDIR)/inf.6
ifeq ($(OS), Darwin)
@mv $(LIB)/minform/grammar.h $(DESTDIR)$(LIB)/minform/grammar.h.tmp
@mv $(LIB)/minform/grammar.h.tmp $(DESTDIR)$(LIB)/minform/Grammar.h
@mv $(LIB)/minform/parser.h $(DESTDIR)$(LIB)/minform/parser.h.tmp
@mv $(LIB)/minform/parser.h.tmp $(DESTDIR)$(LIB)/minform/Parser.h
@mv $(LIB)/minform/verblib.h $(DESTDIR)$(LIB)/minform/verblib.h.tmp
@mv $(LIB)/minform/verblib.h.tmp $(DESTDIR)$(LIB)/minform/VerbLib.h
else
@ln -s $(LIB)/minform/grammar.h $(DESTDIR)$(LIB)/minform/Grammar.h
@ln -s $(LIB)/minform/parser.h $(DESTDIR)$(LIB)/minform/Parser.h
@ln -s $(LIB)/minform/verblib.h $(DESTDIR)$(LIB)/minform/VerbLib.h
endif
.PHONY: uninstall
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(MAIN)
rm -f $(DESTDIR)$(PREFIX)/bin/inf
rm -f $(DESTDIR)$(MANDIR)/inf.6.gz
rm -rf $(DESTDIR)$(LIB)