#*
#*  sudo version 1.1 allows users to execute commands as root
#*  Copyright (C) 1991  The Root Group, Inc.
#*
#*  This program is free software; you can redistribute it and/or modify
#*  it under the terms of the GNU General Public License as published by
#*  the Free Software Foundation; either version 1, or (at your option)
#*  any later version.
#*
#*  This program is distributed in the hope that it will be useful,
#*  but WITHOUT ANY WARRANTY; without even the implied warranty of
#*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#*  GNU General Public License for more details.
#*
#*  You should have received a copy of the GNU General Public License
#*  along with this program; if not, write to the Free Software
#*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#*
#*  If you make modifications to the source, we would be happy to have
#*  them to include in future releases.  Feel free to send them to:
#*      Jeff Nieusma                       nieusma@rootgroup.com
#*      3959 Arbol CT                      (303) 447-8093
#*      Boulder, CO 80301-1752             
#*
#
#   This is the Makefile for the main level of sudo
#
#
#          The following macros can be defined when compiling
#
#          FQDN                   - if you have fully qualified hostnames
#                                   in your SUDOERS files
#
#          SYSLOG                 - if you want to use syslog instead
#                                   of a log file
#                                   ( This is a nice feature.  You can
#                                     collect all your sudo logs at a
#                                     single host)
#
#          NO_ROOT_SUDO           - sudo will exit if called by root
# 
#          MULTIMAX               - define if installing on Encore Multimax
#                                   Also change the LIBS macro to "LIBS=-ll"
#
#          SEND_MAIL_WHEN_NOT_OK  - if you want a message sent to ALERTMAIL
#                                   when the user is in the SUDOERS but
#                                   does not have permission to execute
#                                   the command entered
#                                   ( This can be used at paranoid sites )
#
#          SEND_MAIL_WHEN_NO_USER - if you want a message sent to ALERTMAIL
#                                   when the user is not in the SUDOERS file
#                                   ( This is generally the case )
#
#          TIMEDIR                  the directory where the timestamp 
#                                   files are kept.
#
#          TIMEOUT                  the number of minutes that can elapse
#                                   before sudo will ask for a passwd again
#
#          TRIES_FOR_PASSWORD       the number of times sudo will let you
#                                   guess are you password before screaming
#
#          INCORRECT_PASSWORD       the message that is displayed if you 
#                                   incorrectly enter your password
#
#          MAILSUBJECT              the subject of the mail sent to ALERTMAIL
#
#          ALERTMAIL                the recipient of mail from sudo
#
#          SUDOERS                  the location of the sudoers file
#
#          TMPSUDOERS               the location of the lock file for visudo
#
#          EDITOR                   the location of the editor
#
#          LOGFILE                  log file location IF NOT USING SYSLOG
#
#          SYSLOG                   if this variable is defined, sudo will log
#                                   using the 4.3 BSD style syslog facility
#
#       Macro:                   Default:
#          Syslog_ident             "sudo"
#          Syslog_options           LOG_PID
#          Syslog_facility          LOG_LOCAL2
#          Syslog_priority_OK       LOG_NOTICE
#          Syslog_priority_NO       LOG_ALERT
#

   DEFINES = -DSYSLOG -DSEND_MAIL_WHEN_NO_USER -DSyslog_options=0
      OBJS = find_path.o logging.o sudo.o check.o parse.o lex.yy.o y.tab.o
      SRCS = find_path.c logging.c sudo.c check.c parse.c
  INCLUDES = sudo.h
   SUDODIR = /usr/local/bin
 VISUDODIR = /usr/local/etc
SUDOERSDIR = /etc
MANSECTION = 8
    MANDIR = /usr/local/man/man${MANSECTION}
      PROG = sudo
   CCFLAGS = 
      LIBS = -ly -ll
    SUNOS4 = -Bstatic


.SUFFIXES:	.o .c

.c.o:	${SRCS}
	cc ${CCFLAGS} -c ${DEFINES} $<

all		:	${PROG} visudo

all-sunos4	:	sudo-sunos4 visudo

${PROG}		:	${OBJS} 
	cc -o $@ *.o ${LIBS}

sudo-sunos4	:	${OBJS}
	cc -o sudo *.o ${SUNOS4} ${LIBS}

y.tab.o	y.tab.h	:	parse.yacc ${INCLUDES}
	yacc -d parse.yacc
	cc $(CCFLAGS) -c y.tab.c

lex.yy.o	:	parse.lex y.tab.h ${INCLUDES}
	lex parse.lex
	cc $(CCFLAGS) -c lex.yy.c

logging.o sudo.o check.o parse.o : ${INCLUDES}

visudo		:
	(cd visudoers && make ${MFLAGS} $@)

install-all	: install-binaries install-sudoers install-man

install-all-sunos4: install-binaries-sunos4 install-sudoers

install-sudoers:
	install -o root -g staff -m 0400 -c sudoers ${SUDOERSDIR}/sudoers

install-binaries:	all
	install -o root -g staff -m 4111 -s -c sudo ${SUDODIR}/sudo
	install -o root -g staff -m 0111 -s -c visudoers/visudo ${VISUDODIR}/visudo

install-binaries-sunos4:	sudo-sunos4 visudo
	install -o root -g staff -m 4111 -s -c sudo ${SUDODIR}/sudo
	install -o root -g staff -m 0111 -s -c visudoers/visudo ${VISUDODIR}/visudo

install-man:
	install -o root -g staff -m 0644 -c sudo.8 ${MANDIR}/sudo.${MANSECTION}

tags		:
	ctags ${SRCS} ${INCLUDES}

clean		:
	-rm -f lex.yy.* y.tab.* *.o sudo
	(cd visudoers && make ${MFLAGS} $@);
