Pristine Ack-5.5
[Ack-5.5.git] / util / flex / Makefile
1 # make file for "flex" tool
2
3 # @(#) $Id: Makefile,v 1.2 1994/06/24 10:56:32 ceriel Exp $ (LBL)
4
5 # Porting considerations:
6 #
7 #    For System V Unix machines, add -DUSG to CFLAGS (if it's not
8 #         automatically defined)
9 #    For Vax/VMS, add "-DVMS -DUSG" to CFLAGS.
10 #    For MS-DOS, add "-DMS_DOS -DUSG" to CFLAGS.  Create \tmp if not present.
11 #         You will also want to rename flex.skel to something with a three
12 #         character extension, change SKELETON_FILE below appropriately,
13 #         See MSDOS.notes for more info.
14 #    For Amiga, add "-DAMIGA -DUSG" to CFLAGS.
15 #    For SCO Unix, add "-DSCO_UNIX" to CFLAGS.
16 #
17 #    For C compilers which don't know about "void", add -Dvoid=int to CFLAGS.
18 #
19 #    If your C compiler is ANSI standard but does not include the <stdlib.h>
20 #    header file (some installations of gcc have this problem), then add
21 #    -DDONT_HAVE_STDLIB_H to CFLAGS.
22 #
23 # By default, flex will be configured to generate 8-bit scanners only
24 # if the -8 flag is given.  If you want it to always generate 8-bit
25 # scanners, add "-DDEFAULT_CSIZE=256" to CFLAGS.  Note that doing
26 # so will double the size of all uncompressed scanners.
27
28 # If on your system you have trouble building flex due to 8-bit
29 # character problems, remove the -8 from FLEX_FLAGS and the
30 # "#define FLEX_8_BIT_CHARS" from the beginning of flexdef.h.
31
32
33 # the first time around use "make first_flex"
34
35
36 # Installation targeting.  Files will be installed under the tree rooted
37 # at DESTDIR.  User commands will be installed in BINDIR, library files
38 # in LIBDIR (which will be created if necessary), auxiliary files in
39 # AUXDIR, manual pages will be installed in MANDIR with extension MANEXT.
40 # Raw, unformatted troff source will be installed if INSTALLMAN=man, nroff
41 # preformatted versions will be installed if INSTALLMAN=cat.
42 DESTDIR =
43 BINDIR = /usr/local
44 LIBDIR = /usr/local/lib
45 AUXDIR = /usr/local/lib
46 MANDIR = /usr/man/manl
47 MANEXT = l
48 INSTALLMAN = man
49
50 # MAKE = make
51
52
53 SKELETON_FILE = $(DESTDIR)$(AUXDIR)/flex.skel
54 SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_FILE)\"
55 CFLAGS = -O
56 LDFLAGS = -s
57
58 COMPRESSION =
59 FLEX_FLAGS = -ist8 -Sflex.skel
60 # which "flex" to use to generate scan.c from scan.l
61 FLEX = ./flex
62 # CC = cc
63
64 AR = ar
65 RANLIB = ranlib
66
67 FLEXOBJS = \
68         ccl.o \
69         dfa.o \
70         ecs.o \
71         gen.o \
72         main.o \
73         misc.o \
74         nfa.o \
75         parse.o \
76         scan.o \
77         sym.o \
78         tblcmp.o \
79         yylex.o
80
81 FLEX_C_SOURCES = \
82         ccl.c \
83         dfa.c \
84         ecs.c \
85         gen.c \
86         main.c \
87         misc.c \
88         nfa.c \
89         parse.c \
90         scan.c \
91         sym.c \
92         tblcmp.c \
93         yylex.c
94
95 FLEX_LIB_OBJS = \
96         libmain.o
97
98 FLEXLIB = flexlib.a
99
100
101 all : flex $(FLEXLIB)
102
103 flex : $(FLEXOBJS)
104         $(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
105
106 first_flex:
107         cp initscan.c scan.c
108         $(MAKE) $(MFLAGS) flex
109
110 parse.h parse.c : parse.y
111         $(YACC) -d parse.y
112         @mv y.tab.c parse.c
113         @mv y.tab.h parse.h
114
115 scan.c : scan.l
116         $(FLEX) $(FLEX_FLAGS) $(COMPRESSION) scan.l >scan.c
117
118 scan.o : scan.c parse.h flexdef.h
119
120 main.o : main.c flexdef.h
121         $(CC) $(CFLAGS) -c $(SKELFLAGS) main.c
122
123 ccl.o : ccl.c flexdef.h
124 dfa.o : dfa.c flexdef.h
125 ecs.o : ecs.c flexdef.h
126 gen.o : gen.c flexdef.h
127 misc.o : misc.c flexdef.h
128 nfa.o : nfa.c flexdef.h
129 parse.o : parse.c flexdef.h
130 sym.o : sym.c flexdef.h
131 tblcmp.o : tblcmp.c flexdef.h
132 yylex.o : yylex.c flexdef.h
133
134 flex.man : flex.1
135         nroff -man flex.1 >flex.man
136
137 $(FLEXLIB) : $(FLEX_LIB_OBJS)
138         $(AR) cru $(FLEXLIB) $(FLEX_LIB_OBJS)
139
140 lint : $(FLEX_C_SOURCES)
141         lint $(FLEX_C_SOURCES) > flex.lint
142
143 distrib :
144         mv scan.c initscan.c
145         chmod 444 initscan.c
146         $(MAKE) $(MFLAGS) clean
147
148 install: flex $(DESTDIR)$(LIBDIR) flex.skel install.$(INSTALLMAN) install-lib
149         install -s -m 755 flex $(DESTDIR)$(BINDIR)/flex
150         install -c -m 644 flex.skel $(SKELETON_FILE)
151
152 install-lib: $(DESTDIR)$(LIBDIR) $(FLEXLIB)
153         install -c -m 644 $(FLEXLIB) $(DESTDIR)$(LIBDIR)/libfl.a
154         $(RANLIB) $(DESTDIR)$(LIBDIR)/libfl.a
155
156 $(DESTDIR)$(LIBDIR):
157         mkdir $@
158
159 install.man: flex.1 flexdoc.1
160         install -c -m 644 flex.1 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
161         install -c -m 644 flexdoc.1 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
162
163 install.cat: flex.1 flexdoc.1
164         nroff -h -man flex.1 > $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
165         nroff -h -man flexdoc.1 > $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
166         chmod 644 $(DESTDIR)$(MANDIR)/flex.$(MANEXT)
167         chmod 644 $(DESTDIR)$(MANDIR)/flexdoc.$(MANEXT)
168
169 clean :
170         rm -f core errs flex *.o parse.c *.lint parse.h flex.man tags \
171                 $(FLEXLIB)
172
173 tags :
174         ctags $(FLEX_C_SOURCES)
175
176 vms :   flex.man
177         $(MAKE) $(MFLAGS) distrib
178
179 test : flex
180         ./flex $(FLEX_FLAGS) $(COMPRESSION) scan.l | diff scan.c -
181
182 bigtest :
183         rm -f scan.c ; $(MAKE) COMPRESSION="-C" test
184         rm -f scan.c ; $(MAKE) COMPRESSION="-Ce" test
185         rm -f scan.c ; $(MAKE) COMPRESSION="-Cm" test
186         rm -f scan.c ; $(MAKE) COMPRESSION="-Cfe" test
187         rm -f scan.c ; $(MAKE) COMPRESSION="-CFe" test
188         rm -f scan.c ; $(MAKE) COMPRESSION="-Cf" test
189         rm -f scan.c ; $(MAKE) COMPRESSION="-CF" test
190         rm -f scan.c ; $(MAKE)