#	$NetBSD: Makefile,v 1.42 2018/06/10 17:55:11 christos Exp $
#	@(#)Makefile	8.1 (Berkeley) 5/31/93
#
# C Shell with process control; VM/UNIX VAX Makefile
# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
#
# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile.

.include <bsd.own.mk>
WARNS=6

PROG=	csh
DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
# - Editor history not always aligned with shell history,
#   should implement internally
# - Does not handle escaped prompts.
# - Does not do completion
.ifndef SMALLPROG
DFLAGS+=-DEDIT
.endif
CPPFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
SRCS=	alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
	func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
	sem.c set.c str.c time.c
.PATH:	${NETBSDSRCDIR}/usr.bin/printf

MLINKS=	csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
	csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
	csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
	csh.1 stop.1 csh.1 source.1

DPSRCS+=	errnum.h const.h
CLEANFILES+=	errnum.h const.h

errnum.h: err.c
	${_MKTARGET_CREATE}
	rm -f ${.TARGET}
	(\
	echo '/* Do not edit this file, make creates it. */' ;\
	echo '#ifndef _h_sh_errnum' ;\
	echo '#define _h_sh_errnum' ;\
	egrep 'ERR_' ${.ALLSRC} | egrep '^#define' ;\
	echo '#endif /* _h_sh_errnum */' ;\
	) > ${.TARGET}

const.c: errnum.h
const.h: const.c
	${_MKTARGET_CREATE}
	rm -f ${.TARGET}
	echo '/* Do not edit this file, make creates it. */' > ${.TARGET}
	${CC} -E ${CPPFLAGS} ${.ALLSRC} | egrep 'Char STR' | \
	    ${TOOL_SED} -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \
	    sort >> ${.TARGET}

SUBDIR.roff+=USD.doc

COPTS.err.c = -Wno-format-nonliteral
COPTS.printf.c = -Wno-format-nonliteral
COPTS.proc.c = -Wno-format-nonliteral

.if !empty(DFLAGS:M*EDIT)
LDADD+=-ledit -lterminfo -lutil
DPADD+=${LIBEDIT} ${LIBUTIL}
.else
LDADD+=-lutil
DPADD+=${LIBUTIL}
.endif

.include <bsd.prog.mk>
.include <bsd.subdir.mk>
