blob: 95aee3e065dfe255bfd55026bdfa8e7f9947fadb [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-google73af0972020-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
Brian Kernighan0f4e1ba2018-08-24 09:09:59 -040037# yacc options. pick one; this varies a lot by system.
Brian Kernighan87b94932012-12-22 10:35:39 -050038#YFLAGS = -d -S
Brian Kernighane8c28002018-10-25 13:28:54 -040039YACC = bison -d -y
40#YACC = yacc -d
Adam Sampson837b8da2018-08-27 20:27:34 +010041# -S uses sprintf in yacc parser instead of sprint
Brian Kernighan87b94932012-12-22 10:35:39 -050042
43OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o
44
45SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060046 maketab.c parse.c lib.c run.c tran.c proctab.c
Brian Kernighan87b94932012-12-22 10:35:39 -050047
48LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060049 lib.c run.c tran.c
Brian Kernighan87b94932012-12-22 10:35:39 -050050
51SHIP = README LICENSE FIXES $(SOURCE) ytab[ch].bak makefile \
52 awk.1
53
54a.out: ytab.o $(OFILES)
55 $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm
56
57$(OFILES): awk.h ytab.h proto.h
58
Christoph Junghanse4bb3bc2018-12-30 09:04:34 -070059#Clear dependency for parallel build: (make -j)
60#YACC generated y.tab.c and y.tab.h at the same time
61#this needs to be a static pattern rules otherwise multiple target
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060062#are mapped onto multiple executions of yacc, which overwrite
Christoph Junghanse4bb3bc2018-12-30 09:04:34 -070063#each others outputs.
64y%.c y%.h: awk.h proto.h awkgram.y
Brian Kernighan87b94932012-12-22 10:35:39 -050065 $(YACC) $(YFLAGS) awkgram.y
Christoph Junghanse4bb3bc2018-12-30 09:04:34 -070066 mv y.$*.c y$*.c
67 mv y.$*.h y$*.h
Adam Sampson9a4aa892018-08-27 20:28:29 +010068
69ytab.h: ytab.c
Brian Kernighan87b94932012-12-22 10:35:39 -050070
71proctab.c: maketab
Elliott Hughescc165f42019-01-29 17:20:00 -080072 ./maketab ytab.h >proctab.c
Brian Kernighan87b94932012-12-22 10:35:39 -050073
74maketab: ytab.h maketab.c
nee-sanc83d9432019-03-12 22:52:17 +030075 $(HOSTCC) $(CFLAGS) maketab.c -o maketab
Brian Kernighan87b94932012-12-22 10:35:39 -050076
77bundle:
78 @cp ytab.h ytabh.bak
79 @cp ytab.c ytabc.bak
80 @bundle $(SHIP)
81
82tar:
83 @cp ytab.h ytabh.bak
84 @cp ytab.c ytabc.bak
85 @bundle $(SHIP) >awk.shar
86 @tar cf awk.tar $(SHIP)
87 gzip awk.tar
88 ls -l awk.tar.gz
89 @zip awk.zip $(SHIP)
90 ls -l awk.zip
91
92gitadd:
Brian Kernighan3ed9e242018-08-15 10:45:03 -040093 git add README LICENSE FIXES \
Brian Kernighan87b94932012-12-22 10:35:39 -050094 awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
95 lib.c run.c tran.c \
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -060096 makefile awk.1 testdir
Brian Kernighan87b94932012-12-22 10:35:39 -050097
98gitpush:
Arnold D. Robbins795a06b2019-07-28 05:51:52 -060099 # only do this once:
Brian Kernighan3ed9e242018-08-15 10:45:03 -0400100 # git remote add origin https://github.com/onetrueawk/awk.git
Brian Kernighan87b94932012-12-22 10:35:39 -0500101 git push -u origin master
102
103names:
104 @echo $(LISTING)
105
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -0600106test check:
107 ./REGRESS
108
109clean: testclean
Brian Kernighan87b94932012-12-22 10:35:39 -0500110 rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda # proctab.c
Brian Kernighan3ed9e242018-08-15 10:45:03 -0400111
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -0600112cleaner: testclean
Brian Kernighan3ed9e242018-08-15 10:45:03 -0400113 rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda proctab.c ytab*
Arnold D. Robbinsab911ab2019-06-24 01:10:24 -0600114
115# This is a bit of a band-aid until we can invest some more time
116# in the test suite.
117testclean:
Arnold D. Robbinscebda362019-07-26 12:57:48 +0300118 cd testdir; rm -fr arnold-fixes beebe echo foo* \
119 glop glop1 glop2 lilly.diff tempbig tempsmall time
Arnold D. Robbins8b92a4a2019-10-24 09:44:00 -0400120
121# For the habits of GNU maintainers:
122distclean: clean