#
# 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/usr/local/selinux/include -DUSE_PAM
LIBFLAGS += -ldl -lpam -lpam_misc -lsecure
# End PAM Flags

# Begin SHADOW flags
#CFLAGS += -Wall -I/usr/local/selinux/include -D_GNU_SOURCE
#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/usr/local/selinux/lib
LIBS += /usr/local/selinux/lib/libsecure.a

PROGS = newrole
DESTDIR = /usr/local/selinux/bin
MANDIR = /usr/local/selinux/man

all:  $(PROGS)

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

install : all
	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 ]; then \
		rm -f /etc/pam.d/newrole; \
		sed "/pam_rootok.so/d" /etc/pam.d/su > /etc/pam.d/newrole; \
	fi;

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

