#
# Makefile for newrole.
#
# newrole can be configured to use PAM or the shadow passwd file for
# authentication.  If you want to use PAM, uncomment the lines
# marked "PAM flags" and comment the lines marked "SHADOW flags",
# below.  If you want to use the shadow passwd file, do the opposite.
#
# Uncomment the "Debugging flags" for debugging.
# Uncomment the "Release flags" for release builds.
# Uncomment one, but not both, of the "Debugging" and the "Release" flags.
#

# Begin PAM flags
CFLAGS += -Wall -I../../include -I../../kernel/include -DUSE_PAM
LIBFLAGS += -ldl -lpam -lpam_misc -lsecure
# End PAM Flags

# Begin SHADOW flags
# CFLAGS += -Wall -I../../include -I../../kernel/include
# LIBFLAGS += -lcrypt -lsecure
# End SHADOW flags

# Begin Debugging flags
# CFLAGS += -DCANTSPELLGDB -g
# End Debugging flags

# Begin Release flags
CFLAGS += -O3
# End Release flags

LDFLAGS += -L../../libsecure
LIBS += ../../libsecure/libsecure.a

PROGS = newrole
DESTDIR = /usr/flask/bin
MANDIR = /usr/flask/man

all:  $(PROGS)

newrole : newrole.c $(LIBS)
	$(CC) $(LDFLAGS) $(CFLAGS) -o newrole newrole.c $(LIBFLAGS)

install : newrole.c
	install -m 555 -o root -g root $(PROGS) $(DESTDIR)
	install -m 644 -o root -g root newrole.1 $(MANDIR)/man1/

	if [ -d /etc/pam.d ] && [ ! -e /etc/pam.d/newrole ]; then \
	    ln -s /etc/pam.d/su /etc/pam.d/newrole; 		  \
	fi; 

clean:
	rm -f $(PROGS) *.o

