Makefile revision 1.25
1#	$NetBSD: Makefile,v 1.25 2002/10/01 08:56:40 jdolecek Exp $
2#	@(#)Makefile	8.6 (Berkeley) 5/8/95
3
4.include <bsd.own.mk>
5
6PROG=	mount
7MAN=	mount.8
8SRCS=	mount.c vfslist.c
9# We do NOT install the getmntopts.3 man page.
10# getmntopts.c in this directory is used by different mount programs which
11# use .PATH directives to get it.
12
13SRCS+= getmntopts.c fattr.c checkname.c
14CPPFLAGS+= -I${.CURDIR} -DMOUNT_NOMAIN
15
16.if defined(RESCUEDIR)
17CPPFLAGS+= -D_PATH_RESCUE=\"${RESCUEDIR}\"
18.endif
19
20# Note: mount_portal is excluded by purpose, mainly because it contains
21# more stuff and hence cannot be made to export only mount_FOO() symbol
22MOUNT_PROGS=	mount_ados mount_cd9660 mount_ext2fs mount_fdesc mount_ffs \
23		mount_filecore mount_kernfs mount_lfs mount_msdos mount_nfs \
24		mount_ntfs mount_null mount_overlay mount_procfs mount_umap \
25		mount_union
26
27# include individual source files and manpages to build process
28.for p in ${MOUNT_PROGS}
29.PATH: ${NETBSDSRCDIR}/sbin/${p}
30SRCS+=	${p}.c
31MAN+=	${p}.8
32LINKS+=	${BINDIR}/${PROG} ${BINDIR}/${p}
33.endfor
34
35# make mount_ufs alias for mount_ffs (this needs also support in checkname.c)
36LINKS+= ${BINDIR}/mount_ffs ${BINDIR}/mount_ufs
37MLINKS+= mount_ffs.8 mount_ufs.8
38
39CLEANFILES+=	checkname.c
40
41DPADD+=${LIBUTIL}
42LDADD+=-lutil
43
44# generate checkname.c - code which runs appropriate mount_FOO() routine
45# according to program name
46checkname.c: ${.CURDIR}/Makefile
47	@if true; then \
48	  echo "/* File generated by make - DO NOT EDIT */";	\
49	  echo "#include <sys/types.h>";			\
50	  echo "#include <stdlib.h>";				\
51	  echo "#include <string.h>";				\
52	  echo "#include <mntopts.h>";				\
53	  for p in ${MOUNT_PROGS}; do 				\
54		echo "int $$p __P((int argc, char **argv));";	\
55	  done;							\
56	  echo "void checkname(int, char **);";			\
57	  echo;							\
58	  echo "void checkname(int argc, char **argv) {"; 	\
59	  echo "if (strcmp(getprogname(), \"mount\") == 0) return;";	\
60	  for p in ${MOUNT_PROGS}; do				\
61		echo "if (strcmp(getprogname(), \"$$p\") == 0)";	\
62		echo " exit($$p(argc, argv));";			\
63	  done;		\
64	  echo "if (strcmp(getprogname(), \"mount_ufs\") == 0)";	\
65	  echo " exit(mount_ffs(argc, argv));";			\
66	  echo "}";	\
67	fi > ${.TARGET}
68
69.include <bsd.prog.mk>
70