Subject: YP makefile
To: None <tech-misc@netbsd.org>
From: Anthony Mallet <anthony.mallet@ficus.yi.org>
List: tech-misc
Date: 12/23/2000 18:22:28
Hi,

I made the following patch to the Makefile.yp in /var/yp.
Basically, it does not consider there is only one amd.home map but takes a
list of maps defined in AMDMAPS (map names are relative to AMDDIR).

I think the default Makefile.yp should handle several amd maps, don't you?

Maybe this is not the "right" way to do this but it works at least for me
so if someone wants to reuse it...

--- Makefile.yp.orig	Sun Oct 29 17:19:50 2000
+++ Makefile.yp	Sat Dec 23 18:19:22 2000
@@ -21,6 +21,7 @@
 YPDBDIR=	/var/yp
 DIR=		/etc
 AMDDIR=		/etc/amd
+AMDMAPS=	amd.home
 DOMAIN=		"`/usr/bin/basename ${.CURDIR}`"
 
 AWK=		/usr/bin/awk
@@ -46,7 +47,7 @@
 # We have a rule for ypservers, but we don't build it by default, since
 # it seldom changes (only when slaves are added/deleted).
 
-all: passwd aliases amd.home ethers group hosts netgroup networks rpc services protocols netid
+all: passwd aliases ${AMDMAPS} ethers group hosts netgroup networks rpc services protocols netid
 
 
 passwd.time: ${DIR}/master.passwd
@@ -116,8 +117,8 @@
 		${ECHO} "couldn't find ${.ALLSRC}"; \
 	fi
 
-
-amd.home.time: ${AMDDIR}/amd.home
+.for MAP in ${AMDMAPS}
+${MAP}.time: ${AMDDIR}/${MAP}
 	-@if [ -f ${.ALLSRC} ]; then \
 		${SED} -e "s/#.*$$//" -e "/^$$/d" ${.ALLSRC} | \
 		${AWK} '{ \
@@ -133,18 +134,19 @@
 				else \
 				    printf("%s ", $$i); \
 			}' | \
-		${SORT} | ${MAKEDBM} - amd.home; \
+		${SORT} | ${MAKEDBM} - ${MAP}; \
 		${TOUCH} ${.TARGET}; \
-		${ECHO} "updated amd.home"; \
+		${ECHO} "updated ${.ALLSRC}"; \
 		if [ ! ${NOPUSH} ]; then \
-			${YPPUSH} -d ${DOMAIN} amd.home; \
-			${ECHO} "pushed amd.home"; \
+			${YPPUSH} -d ${DOMAIN} ${MAP}; \
+			${ECHO} "pushed ${.ALLSRC}"; \
 		else \
 			: ; \
 		fi \
 	else \
 		${ECHO} "couldn't find ${.ALLSRC}"; \
 	fi
+.endfor
 
 
 ethers.time: ${DIR}/ethers
@@ -347,7 +349,9 @@
 group: group.time
 hosts: hosts.time
 aliases: aliases.time
-amd.home: amd.home.time
+.for MAP in ${AMDMAPS}
+${MAP}: ${MAP}.time
+.endfor
 ethers: ethers.time
 netgroup: netgroup.time
 networks: networks.time
@@ -361,7 +365,9 @@
 ${DIR}/group:
 ${DIR}/hosts:
 ${DIR}/mail/aliases:
-${AMDDIR}/amd.home:
+.for MAP in ${AMDMAPS}
+${AMDDIR}/${MAP}:
+.endfor
 ${DIR}/ethers:
 ${DIR}/master.passwd:
 ${DIR}/netgroup: