-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (85 loc) · 2.7 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
########################################################################
#
# SPL, the Shakespeare Programming Language
#
# Copyright (C) 2001 Karl Hasselström and Jon Åslund
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
########################################################################
NAME = spl
VERSION = 1.2.1
DISTNAME = $(NAME)-$(VERSION)
# compiler commands
AR = ar
CC = gcc
LEX = flex
RANLIB = ranlib
TAR = tar
YACC = bison
INCLUDEPATH = include
EDITORPATH = editor
EXAMPLEPATH = examples
# source / outputs
MAKESCANNERINCLUDE = $(wildcard $(INCLUDEPATH)/*.{wordlist,metaflex})
# compiler flags
YACCFLAGS = --verbose
CCFLAGS = -O2 -Wall
LEXFLAGS = -Cem
.PHONY: all clean examples install libspl tar
all: install examples
examples: install
$(MAKE) -C $(EXAMPLEPATH) all
grammar.tab.h grammar.tab.c: grammar.y
$(YACC) $(YACCFLAGS) -d $<
grammar.tab.o: grammar.tab.c grammar.tab.h telma.h
$(CC) $(CCFLAGS) -c $<
install: spl2c libspl.a spl.h
mkdir -p spl/bin spl/include spl/lib
cp -pf spl2c spl/bin
cp -pf spl.h spl/include
cp -pf libspl.a spl/lib
libspl.a: libspl.o strutils.o
$(AR) rc $@ $^
$(RANLIB) $@
libspl.o: libspl.c spl.h
$(CC) $(CCFLAGS) -c $<
makescanner: makescanner.o
$(CC) $< $(CCFLAGS) -o $@
makescanner.o: makescanner.c
$(CC) $(CCFLAGS) -c $<
scanner.c: scanner.l
$(LEX) $(LEXFLAGS) -t $< > $@
scanner.l: makescanner $(MAKESCANNERINCLUDE)
./$< $(INCLUDEPATH) > $@
scanner.o: scanner.c grammar.tab.h telma.h
$(CC) $(CCFLAGS) -c $<
spl2c: grammar.tab.o scanner.o strutils.o
$(CC) $^ $(CCFLAGS) -lfl -o $@
strutils.o: strutils.c strutils.h
$(CC) $(CCFLAGS) -c $<
tar: clean
mkdir -p $(DISTNAME)
cp `find . -type f -maxdepth 1` $(DISTNAME)
cp -r $(INCLUDEPATH) $(DISTNAME)
cp -r $(EDITORPATH) $(DISTNAME)
cp -r $(EXAMPLEPATH) $(DISTNAME)
$(TAR) zcvf $(DISTNAME).tar.gz $(DISTNAME)
# clean-up funtion
clean:
rm -f *~ $(EDITORPATH)/*~ $(INCLUDEPATH)/*~ *.l *.o *.a core grammar.output grammar.tab.h grammar.tab.c scanner.c makescanner spl2c *.tar.gz
rm -rf spl $(DISTNAME)
$(MAKE) -C $(EXAMPLEPATH) clean