blob: a4f1b8ae87561c45ee446ef8c285cc883f6573e4 [file] [log] [blame]
Brian Kernighan87b94932012-12-22 10:35:39 -05001# /****************************************************************
2# Copyright (C) Lucent Technologies 1997
3# All Rights Reserved
4#
5# Permission to use, copy, modify, and distribute this software and
6# its documentation for any purpose and without fee is hereby
7# granted, provided that the above copyright notice appear in all
8# copies and that both that the copyright notice and this
9# permission notice and warranty disclaimer appear in supporting
10# documentation, and that the name Lucent Technologies or any of
11# its entities not be used in advertising or publicity pertaining
12# to distribution of the software without specific, written prior
13# permission.
14#
15# LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
17# IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
18# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
22# THIS SOFTWARE.
23# ****************************************************************/
24
25CFLAGS = -g
Brian Kernighan87b94932012-12-22 10:35:39 -050026CFLAGS =
Brian Kernighan0f4e1ba2018-08-24 09:09:59 -040027CFLAGS = -O2
Brian Kernighan87b94932012-12-22 10:35:39 -050028
Brian Kernighan0f4e1ba2018-08-24 09:09:59 -040029# compiler options
Arnold D. Robbins32093f52018-08-22 20:40:26 +030030#CC = gcc -Wall -g -Wwrite-strings
Arnold D. Robbins32093f52018-08-22 20:40:26 +030031#CC = gcc -O4 -Wall -pedantic -fno-strict-aliasing
32#CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov
Brian Kernighan0f4e1ba2018-08-24 09:09:59 -040033CC = gcc -g -Wall -pedantic
Brian Kernighan87b94932012-12-22 10:35:39 -050034
Brian Kernighan0f4e1ba2018-08-24 09:09:59 -040035# yacc options. pick one; this varies a lot by system.
Brian Kernighan87b94932012-12-22 10:35:39 -050036#YFLAGS = -d -S
Brian Kernighane8c28002018-10-25 13:28:54 -040037YACC = bison -d -y
38#YACC = yacc -d
Adam Sampson837b8da2018-08-27 20:27:34 +010039# -S uses sprintf in yacc parser instead of sprint
Brian Kernighan87b94932012-12-22 10:35:39 -050040
41OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o
42
43SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \
44 maketab.c parse.c lib.c run.c tran.c proctab.c
45
46LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
47 lib.c run.c tran.c
48
49SHIP = README LICENSE FIXES $(SOURCE) ytab[ch].bak makefile \
50 awk.1
51
52a.out: ytab.o $(OFILES)
53 $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm
54
55$(OFILES): awk.h ytab.h proto.h
56
Christoph Junghanse4bb3bc2018-12-30 09:04:34 -070057#Clear dependency for parallel build: (make -j)
58#YACC generated y.tab.c and y.tab.h at the same time
59#this needs to be a static pattern rules otherwise multiple target
60#are mapped onto multiple executions of yacc, which overwrite
61#each others outputs.
62y%.c y%.h: awk.h proto.h awkgram.y
Brian Kernighan87b94932012-12-22 10:35:39 -050063 $(YACC) $(YFLAGS) awkgram.y
Christoph Junghanse4bb3bc2018-12-30 09:04:34 -070064 mv y.$*.c y$*.c
65 mv y.$*.h y$*.h
Adam Sampson9a4aa892018-08-27 20:28:29 +010066
67ytab.h: ytab.c
Brian Kernighan87b94932012-12-22 10:35:39 -050068
69proctab.c: maketab
Elliott Hughescc165f42019-01-29 17:20:00 -080070 ./maketab ytab.h >proctab.c
Brian Kernighan87b94932012-12-22 10:35:39 -050071
72maketab: ytab.h maketab.c
73 $(CC) $(CFLAGS) maketab.c -o maketab
74
75bundle:
76 @cp ytab.h ytabh.bak
77 @cp ytab.c ytabc.bak
78 @bundle $(SHIP)
79
80tar:
81 @cp ytab.h ytabh.bak
82 @cp ytab.c ytabc.bak
83 @bundle $(SHIP) >awk.shar
84 @tar cf awk.tar $(SHIP)
85 gzip awk.tar
86 ls -l awk.tar.gz
87 @zip awk.zip $(SHIP)
88 ls -l awk.zip
89
90gitadd:
Brian Kernighan3ed9e242018-08-15 10:45:03 -040091 git add README LICENSE FIXES \
Brian Kernighan87b94932012-12-22 10:35:39 -050092 awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
93 lib.c run.c tran.c \
Brian Kernighanba7569c2018-08-16 09:41:13 -040094 makefile awk.1 awktest.tar
Brian Kernighan87b94932012-12-22 10:35:39 -050095
96gitpush:
Brian Kernighan3ed9e242018-08-15 10:45:03 -040097 # only do this once:
98 # git remote add origin https://github.com/onetrueawk/awk.git
Brian Kernighan87b94932012-12-22 10:35:39 -050099 git push -u origin master
100
101names:
102 @echo $(LISTING)
103
104clean:
105 rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda # proctab.c
Brian Kernighan3ed9e242018-08-15 10:45:03 -0400106
107cleaner:
108 rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda proctab.c ytab*