# Modify install rules to disable file ownership changes
# Disable stripping binaries
# Derived from an OE patch for at-3.1.8

--- at-3.1.10.2.orig/Makefile.in	2005-08-29 01:08:28.000000000 -0700
+++ at-3.1.10.2/Makefile.in	2010-07-21 17:06:01.000000000 -0700
@@ -40,6 +40,10 @@
 LIBS		= @LIBS@
 LIBOBJS		= @LIBOBJS@
 INSTALL		= @INSTALL@
+ifeq ($(IROOT),)
+INSTALLOWN = -g root -o root
+DAEMONOWN  = -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME)
+endif
 PAMLIB          = @PAMLIB@
 
 CLONES		= atq atrm 
@@ -88,35 +92,38 @@
 	$(CC) -c $(CFLAGS) $(DEFS) $*.c
 
 install: all
-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(etcdir)
-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(bindir)
-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(sbindir)
-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(docdir)
-	$(INSTALL) -g root -o root -m 755 -d $(IROOT)$(atdocdir)
-	$(INSTALL) -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME) -m 755 -d $(IROOT)$(ATSPOOL_DIR) $(IROOT)$(ATJOB_DIR)
+	$(INSTALL) $(INSTALLOWN) -m 755 -d $(IROOT)$(etcdir)
+	$(INSTALL) $(INSTALLOWN) -m 755 -d $(IROOT)$(bindir)
+	$(INSTALL) $(INSTALLOWN) -m 755 -d $(IROOT)$(sbindir)
+	$(INSTALL) $(INSTALLOWN) -m 755 -d $(IROOT)$(docdir)
+	$(INSTALL) $(INSTALLOWN) -m 755 -d $(IROOT)$(atdocdir)
+	$(INSTALL) $(INSTALLOWN) -m 755 -d $(IROOT)$(ATJOB_DIR)
+	$(INSTALL) $(DAEMONOWN) -m 755 -d $(IROOT)$(ATSPOOL_DIR)
 	chmod 1770 $(IROOT)$(ATSPOOL_DIR) $(IROOT)$(ATJOB_DIR)
 	touch $(IROOT)$(LFILE)
 	chmod 600 $(IROOT)$(LFILE)
+ifeq ($(IROOT),)
 	chown $(DAEMON_USERNAME):$(DAEMON_GROUPNAME) $(IROOT)$(LFILE)
-	test -f $(IROOT)$(etcdir)/at.allow || test -f $(IROOT)$(etcdir)/at.deny || $(INSTALL) -o root -g $(DAEMON_GROUPNAME) -m 640 at.deny $(IROOT)$(etcdir)/
-	$(INSTALL) -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME) -m 6755 -s at $(IROOT)$(bindir)
+endif
+	test -f $(IROOT)$(etcdir)/at.allow || test -f $(IROOT)$(etcdir)/at.deny || $(INSTALL) $(INSTALLOWN) -m 600 at.deny $(IROOT)$(etcdir)/
+	$(INSTALL) $(INSTALLOWN) -m 4755 at $(IROOT)$(bindir)
 	$(LN_S) -f at $(IROOT)$(bindir)/atq
 	$(LN_S) -f at $(IROOT)$(bindir)/atrm
-	$(INSTALL) -g root -o root -m 755 batch $(IROOT)$(bindir)
-	$(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man1dir)
-	$(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man5dir)
-	$(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man8dir)
-	$(INSTALL) -g root -o root -m 755 -s atd $(IROOT)$(sbindir)
-	$(INSTALL) -g root -o root -m 755 atrun $(IROOT)$(sbindir)
-	$(INSTALL) -g root -o root -m 644 at.1 $(IROOT)$(man1dir)/
+	$(INSTALL) $(INSTALLOWN) -m 755 batch $(IROOT)$(bindir)
+	$(INSTALL) -d $(INSTALLOWN) -m 755 $(IROOT)$(man1dir)
+	$(INSTALL) -d $(INSTALLOWN) -m 755 $(IROOT)$(man5dir)
+	$(INSTALL) -d $(INSTALLOWN) -m 755 $(IROOT)$(man8dir)
+	$(INSTALL) $(INSTALLOWN) -m 755 atd $(IROOT)$(sbindir)
+	$(INSTALL) $(INSTALLOWN) -m 755 atrun $(IROOT)$(sbindir)
+	$(INSTALL) $(INSTALLOWN) -m 644 at.1 $(IROOT)$(man1dir)/
 	cd $(IROOT)$(man1dir) && $(LN_S) -f at.1 atq.1 && $(LN_S) -f at.1 batch.1 && $(LN_S) -f at.1 atrm.1
-	$(INSTALL) -g root -o root -m 644 atd.8 $(IROOT)$(man8dir)/
+	$(INSTALL) $(INSTALLOWN) -m 644 atd.8 $(IROOT)$(man8dir)/
 	sed "s,\$${exec_prefix},$(exec_prefix),g" <atrun.8>tmpman
-	$(INSTALL) -g root -o root -m 644 tmpman $(IROOT)$(man8dir)/atrun.8
+	$(INSTALL) $(INSTALLOWN) -m 644 tmpman $(IROOT)$(man8dir)/atrun.8
 	rm -f tmpman
-	$(INSTALL) -g root -o root -m 644 at_allow.5 $(IROOT)$(man5dir)/
+	$(INSTALL) $(INSTALLOWN) -m 644 at_allow.5 $(IROOT)$(man5dir)/
 	cd $(IROOT)$(man5dir) && $(LN_S) -f at_allow.5 at_deny.5 
-	$(INSTALL) -g root -o root -m 644 $(DOCS) $(IROOT)$(atdocdir)
+	$(INSTALL) $(INSTALLOWN) -m 644 $(DOCS) $(IROOT)$(atdocdir)
 	rm -f $(IROOT)$(mandir)/cat1/at.1* $(IROOT)$(mandir)/cat1/batch.1* \
 		$(IROOT)$(mandir)/cat1/atq.1*
 	rm -f $(IROOT)$(mandir)/cat1/atd.8*
