summaryrefslogtreecommitdiff
path: root/sbin/mount/Makefile
blob: d886fd01b27858436545d595ff0cdddf49db5622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#	$NetBSD: Makefile,v 1.20 2001/02/20 23:24:47 cgd Exp $
#	@(#)Makefile	8.6 (Berkeley) 5/8/95

PROG=	mount
MAN=	mount.8
SRCS=	mount.c vfslist.c
# We do NOT install the getmntopts.3 man page.
# getmntopts.c in this directory isn't used by mount anymore, but it
# is used by other mount programs which use .PATH directives to use
# the version here.

SRCS+= getmntopts.c fattr.c checkname.c
CPPFLAGS+= -I${.CURDIR} -DMOUNT_NOMAIN

# Note: mount_portal is excluded by purpose, mainly because it contains
# more stuff and hence cannot be made to export only mount_FOO() symbol
MOUNT_PROGS=	mount_ados mount_cd9660 mount_ext2fs mount_fdesc mount_ffs \
		mount_filecore mount_kernfs mount_lfs mount_msdos mount_nfs \
		mount_ntfs mount_null mount_overlay mount_procfs mount_umap \
		mount_union
	
# include individual source files and manpages to build process
.for p in ${MOUNT_PROGS}
.PATH: ${.CURDIR}/../${p}
SRCS+=	${p}.c
MAN+=	${p}.8
LINKS+=	${BINDIR}/${PROG} ${BINDIR}/${p}
.endfor

# make mount_ufs alias for mount_ffs (this needs also support in checkname.c)
LINKS+= ${BINDIR}/mount_ffs ${BINDIR}/mount_ufs
MLINKS+= mount_ffs.8 mount_ufs.8

CLEANFILES+=	checkname.c

# generate checkname.c - code which runs appropriate mount_FOO() routine
# according to program name
checkname.c: ${.CURDIR}/Makefile
	@if true; then \
	  echo "/* File generated by make - DO NOT EDIT */";	\
	  echo "#include <sys/types.h>";			\
	  echo "#include <stdlib.h>";				\
	  echo "#include <string.h>";				\
	  echo "#include <mntopts.h>";				\
	  for p in ${MOUNT_PROGS}; do 				\
		echo "int $$p __P((int argc, char **argv));";	\
	  done;							\
	  echo "void checkname(int, char **);";			\
	  echo;							\
	  echo "void checkname(int argc, char **argv) {"; 	\
	  echo "if (strcmp(getprogname(), \"mount\") == 0) return;";	\
	  for p in ${MOUNT_PROGS}; do				\
		echo "if (strcmp(getprogname(), \"$$p\") == 0)";	\
		echo " exit($$p(argc, argv));";			\
	  done;		\
	  echo "if (strcmp(getprogname(), \"mount_ufs\") == 0)";	\
	  echo " exit(mount_ffs(argc, argv));";			\
	  echo "}";	\
	fi > ${.TARGET}

.include <bsd.prog.mk>