1# 2# Copyright (c) 2016,2018 Daichi GOTO 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modifigation, are permitted provided that the following conditions are 7# met: 8# 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# 27 28.include "../../../mk/ttt.os.mk" 29.include "../../../mk/ttt.cmd.mk" 30.include "../../../mk/ttt.dirs.mk" 31.include "../../../mk/ttt.perm.mk" 32 33AWKSRC= ${.CURDIR}/../../contrib/one-true-awk 34.PATH: ${AWKSRC} 35 36OUT= ongs_awk 37ALIAS= owk 38 39SRC= awkgram.c awkgram.h ytab.h maketab proctab.c 40OBJS= b.o lex.o lib.o main.o parse.o run.o tran.o \ 41 awkgram.o proctab.o 42 43CFLAGS= -I. \ 44 -I${AWKSRC} \ 45 -lm \ 46 -O2 \ 47 -pipe \ 48 -DHAS_ISBLANK \ 49 -DFOPEN_MAX=64 \ 50 -g 51.if ${COMPILER_TYPE} == "clang" 52CFLAGS+= -std=gnu99 \ 53 -Wsystem-headers \ 54 -Werror \ 55 -Wno-pointer-sign \ 56 -Wno-empty-body \ 57 -Wno-string-plus-int \ 58 -Wno-unused-const-variable \ 59 -Wno-tautological-compare \ 60 -Wno-unused-value \ 61 -Wno-parentheses-equality \ 62 -Wno-unused-function \ 63 -Wno-enum-conversion \ 64 -Wno-switch \ 65 -Wno-switch-enum \ 66 -Wno-knr-promoted-parameter \ 67 -Wno-parentheses \ 68 -Qunused-arguments 69.endif 70.if ${OS} == "Linux" 71CFLAGS+= -Wno-typedef-redefinition \ 72 -Wno-gnu-designator \ 73 -Wno-builtin-requires-header 74.elif ${OS} == "Darwin" 75CFLAGS+= -Wno-nullability-completeness \ 76 -Wno-macro-redefined \ 77 -Wno-typedef-redefinition 78.endif 79 80# XXX 81# The following option has been removed to build with FreeBSD 10.*. 82# I should undo it once FreeBSD 10.* support is finished. 83# 84# -fstack-protector-strong \ 85# -Wno-unused-local-typedef \ 86 87FUNCS= b lex lib main parse run tran 88 89build: 90 ${YACC} -d -o awkgram.c ${AWKSRC}/awkgram.y 91 ${LN} -sf awkgram.h ytab.h 92 ${CC} ${CFLAGS} ${AWKSRC}/maketab.c -o maketab 93 ./maketab > proctab.c 94 ${CC} ${CFLAGS} -c awkgram.c -o awkgram.o 95 ${CC} ${CFLAGS} -c proctab.c -o proctab.o 96.for i in ${FUNCS} 97 ${CC} ${CFLAGS} -I${AWKSRC} -c ${AWKSRC}/${i}.c -o ${i}.o 98.endfor 99.if exists(${BINDIR}/${OUT}) 100 ${RM} -f ${BINDIR}/${OUT} 101.endif 102 ${CC} ${CFLAGS} -o ${BINDIR}/${OUT} \ 103 awkgram.o b.o lex.o lib.o main.o parse.o proctab.o \ 104 run.o tran.o \ 105 ${SRCDIR}/lib/libttt/ssvstr2str.o \ 106 ${SRCDIR}/lib/libttt/str2ssvstr.o \ 107 -lm 108 ${CHMOD} ${BINPERM} ${BINDIR}/${OUT} 109.if ${OS} != "Darwin" 110 ${OBJCOPY} -S ${BINDIR}/${OUT} 111.endif 112.for i in ${ALIAS} 113 ${TEST} -L ${BINDIR}/${i} && ${RM} ${BINDIR}/${i} || ${TRUE} 114 cd ${BINDIR}; ${LN} -s ${OUT} ${i} 115.endfor 116.if ${OS} == "Darwin" 117 ${RM} -rf maketab.dSYM 118.endif 119 120clean: 121 ${RM} -f ${BINDIR}/${OUT} ${SRC} ${OBJS} 122.for i in ${ALIAS} 123 ${RM} -f ${BINDIR}/${i} 124.endfor 125