blob: 9ceaaad48af170014df8446d93ce9035bef10d9a [file] [log] [blame]
Brian Kernighan87b94932012-12-22 10:35:39 -05001# /****************************************************************
2# Copyright (C) Lucent Technologies 1997
3# All Rights Reserved
Arnold D. Robbins795a06b2019-07-28 05:51:52 -06004#
Brian Kernighan87b94932012-12-22 10:35:39 -05005# 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.
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060014#
Brian Kernighan87b94932012-12-22 10:35:39 -050015# 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
enh-google7b245a02020-02-28 03:18:29 -080025CFLAGS = -fsanitize=address -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls
Brian Kernighan87b94932012-12-22 10:35:39 -050026CFLAGS = -g
Brian Kernighan87b94932012-12-22 10:35:39 -050027CFLAGS =
Brian Kernighan0f4e1ba2018-08-24 09:09:59 -040028CFLAGS = -O2
Brian Kernighan87b94932012-12-22 10:35:39 -050029
Brian Kernighan0f4e1ba2018-08-24 09:09:59 -040030# compiler options
Arnold D. Robbins32093f52018-08-22 20:40:26 +030031#CC = gcc -Wall -g -Wwrite-strings
Arnold D. Robbins32093f52018-08-22 20:40:26 +030032#CC = gcc -O4 -Wall -pedantic -fno-strict-aliasing
33#CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov
Arnold D. Robbins961eec12019-10-24 09:42:51 -040034HOSTCC = gcc -g -Wall -pedantic -Wcast-qual
Arnold D. Robbins55edb1b2019-03-12 21:54:57 +020035CC = $(HOSTCC) # change this is cross-compiling.
Brian Kernighan87b94932012-12-22 10:35:39 -050036
Arnold D. Robbins07f04382020-07-30 17:12:45 +030037# By fiat, to make our lives easier, yacc is now defined to be bison.
38# If you want something else, you're on your own.
zoulasc94e4c042020-02-18 14:20:27 -050039YACC = bison -d
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
Arnold D. Robbins07f04382020-07-30 17:12:45 +030043SOURCE = awk.h awkgram.tab.c awkgram.tab.h proto.h awkgram.y lex.c b.c main.c \
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060044 maketab.c parse.c lib.c run.c tran.c proctab.c
Brian Kernighan87b94932012-12-22 10:35:39 -050045
46LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060047 lib.c run.c tran.c
Brian Kernighan87b94932012-12-22 10:35:39 -050048
Arnold D. Robbins07f04382020-07-30 17:12:45 +030049SHIP = README LICENSE FIXES $(SOURCE) awkgram.tab.[ch].bak makefile \
Brian Kernighan87b94932012-12-22 10:35:39 -050050 awk.1
51
Arnold D. Robbins07f04382020-07-30 17:12:45 +030052a.out: awkgram.tab.o $(OFILES)
53 $(CC) $(CFLAGS) awkgram.tab.o $(OFILES) $(ALLOC) -lm
Brian Kernighan87b94932012-12-22 10:35:39 -050054
Arnold D. Robbins07f04382020-07-30 17:12:45 +030055$(OFILES): awk.h awkgram.tab.h proto.h
Brian Kernighan87b94932012-12-22 10:35:39 -050056
Arnold D. Robbins07f04382020-07-30 17:12:45 +030057awkgram.tab.c awkgram.tab.h: awk.h proto.h awkgram.y
Brian Kernighan87b94932012-12-22 10:35:39 -050058 $(YACC) $(YFLAGS) awkgram.y
Brian Kernighan87b94932012-12-22 10:35:39 -050059
60proctab.c: maketab
Arnold D. Robbins07f04382020-07-30 17:12:45 +030061 ./maketab awkgram.tab.h >proctab.c
Brian Kernighan87b94932012-12-22 10:35:39 -050062
Arnold D. Robbins07f04382020-07-30 17:12:45 +030063maketab: awkgram.tab.h maketab.c
nee-sanc83d9432019-03-12 22:52:17 +030064 $(HOSTCC) $(CFLAGS) maketab.c -o maketab
Brian Kernighan87b94932012-12-22 10:35:39 -050065
66bundle:
Arnold D. Robbins07f04382020-07-30 17:12:45 +030067 @cp awkgram.tab.h awkgram.tab.h.bak
68 @cp awkgram.tab.c awkgram.tab.c.bak
Brian Kernighan87b94932012-12-22 10:35:39 -050069 @bundle $(SHIP)
70
71tar:
Arnold D. Robbins07f04382020-07-30 17:12:45 +030072 @cp awkgram.tab.h awkgram.tab.h.bak
73 @cp awkgram.tab.c awkgram.tab.c.bak
Brian Kernighan87b94932012-12-22 10:35:39 -050074 @bundle $(SHIP) >awk.shar
75 @tar cf awk.tar $(SHIP)
76 gzip awk.tar
77 ls -l awk.tar.gz
78 @zip awk.zip $(SHIP)
79 ls -l awk.zip
80
81gitadd:
Brian Kernighan3ed9e242018-08-15 10:45:03 -040082 git add README LICENSE FIXES \
Brian Kernighan87b94932012-12-22 10:35:39 -050083 awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
84 lib.c run.c tran.c \
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -060085 makefile awk.1 testdir
Brian Kernighan87b94932012-12-22 10:35:39 -050086
87gitpush:
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060088 # only do this once:
Brian Kernighan3ed9e242018-08-15 10:45:03 -040089 # git remote add origin https://github.com/onetrueawk/awk.git
Brian Kernighan87b94932012-12-22 10:35:39 -050090 git push -u origin master
91
92names:
93 @echo $(LISTING)
94
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -060095test check:
96 ./REGRESS
97
98clean: testclean
Brian Kernighan87b94932012-12-22 10:35:39 -050099 rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda # proctab.c
Brian Kernighan3ed9e242018-08-15 10:45:03 -0400100
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -0600101cleaner: testclean
Arnold D. Robbins07f04382020-07-30 17:12:45 +0300102 rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda proctab.c awkgram.tab.*
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -0600103
104# This is a bit of a band-aid until we can invest some more time
105# in the test suite.
106testclean:
Arnold D. Robbins3b42cfa2020-10-13 20:52:43 +0300107 cd testdir; rm -fr arnold-fixes beebe devnull echo foo* \
Arnold D. Robbinscebda362019-07-26 12:57:48 +0300108 glop glop1 glop2 lilly.diff tempbig tempsmall time
Arnold D. Robbins8b92a4a2019-10-24 09:44:00 -0400109
110# For the habits of GNU maintainers:
Arnold D. Robbins07f04382020-07-30 17:12:45 +0300111distclean: cleaner