summaryrefslogtreecommitdiffstats
path: root/mount/Makefile.standalone
blob: 2cedcd235c06d97e7617c1b68e0d5e09bf9efa0f (plain) (blame)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# ifeq (../MCONFIG,$(wildcard ../MCONFIG))
# include ../MCONFIG
# endif

# For now: a standalone version

CC = gcc
CFLAGS = -O2

#WARNFLAGS = -Wall -Wstrict-prototypes
# We really want
WARNFLAGS = -Wall -Wstrict-prototypes -Wmissing-prototypes
# but at the moment that yields
#<linux/socket.h>:72: warning: no previous prototype for `cmsg_nxthdr'

# you need rpcgen and libc-4.2 or rpclib to compile in the NFS support
# pregenerated files are included.
# Make sure nfsmount_clnt.c is newer than nfsmount.x to avoid gcc complaints.
DEFINES = -DHAVE_NFS

RPCSVCDIR = rpcsvc
RPC_CFLAGS = -Wno-unused 
RPCGEN = rpcgen

INSTALL = install
INSTALL_SUID = $(INSTALL) -m 4755 -o root
INSTALL_PROG = $(INSTALL) -m 755
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_DIR = mkdir -p
INSTALL_MAN = $(INSTALL_DATA)

MANDIR = /usr/man
## for suid progs (mount, umount)
BINDIR = /bin
## for nosuid progs (swapon)
SBINDIR = /sbin

# End of configuration section.

COMPILE = $(CC) -c $(WARNFLAGS) $(CFLAGS) $(DEFINES)
LINK = $(CC) $(LDFLAGS)

SUID_PROGS = mount umount
NOSUID_PROGS = swapon losetup
PROGS = $(SUID_PROGS) $(NOSUID_PROGS)
MAN5 = fstab.5 nfs.5
MAN8 = mount.8 swapoff.8 swapon.8 umount.8 losetup.8

# comment these out if you are not compiling in NFS support
NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o
# uncomment this if you don't have libc-4.2 but do have the rpclib
GEN_FILES = nfsmount.x nfsmount.h nfsmount_xdr.c nfsmount_clnt.c

# comment these out if you are not compiling in loop support
LO_OBJS=lomount.o

all: $(PROGS)

install: $(PROGS)
	$(INSTALL_DIR) $(BINDIR) $(SBINDIR)
	$(INSTALL_SUID) -s $(SUID_PROGS) $(BINDIR)
	$(INSTALL_PROG) -s $(NOSUID_PROGS) $(SBINDIR)
	(cd $(SBINDIR); ln -sf swapon swapoff)
	$(INSTALL_DIR) $(MANDIR)/man5 $(MANDIR)/man8
	$(INSTALL_MAN) $(MAN5) $(MANDIR)/man5
	$(INSTALL_MAN) $(MAN8) $(MANDIR)/man8

%.o: %.c
	$(COMPILE) $<

mount: mount.o fstab.o sundries.o realpath.o version.o $(NFS_OBJS) $(LO_OBJS)
	$(LINK) $^ -o $@

umount: umount.o fstab.o sundries.o realpath.o version.o $(LO_OBJS)
	$(LINK) $^ -o $@

swapon:	swapon.o version.o
	$(LINK) $^ -o $@

losetup: losetup.o
	$(LINK) $^ -o $@

mount.o umount.o nfsmount.o losetup.o fstab.o sundries.o: sundries.h

mount.o umount.o fstab.o sundries.o: fstab.h

mount.o umount.o losetup.o: lomount.h loop.h

swapon.o: swap.h swapargs.h

sundries.o nfsmount.o nfsmount_xdr.o nfsmount_clnt.o: nfsmount.h

umount.o: mount_constants.h

nfsmount_clnt.o: nfsmount_clnt.c
	$(COMPILE) $(RPC_CFLAGS) nfsmount_clnt.c

nfsmount_xdr.o: nfsmount_xdr.c
	$(COMPILE) $(RPC_CFLAGS) nfsmount_xdr.c

nfsmount.h nfsmount_xdr.c nfsmount_clnt.c: nfsmount.x
	rm -f nfsmount.h nfsmount_xdr.c nfsmount_clnt.c
	$(RPCGEN) -h -o nfsmount.h nfsmount.x
	$(RPCGEN) -c -o nfsmount_xdr.c nfsmount.x
	$(RPCGEN) -l -o nfsmount_clnt.c nfsmount.x

nfsmount.x:
	cp $(RPCSVCDIR)/nfsmount.x .

nfsmount.o: nfs_mountversion.h nfs_mount3.h

NFSMOUNTH=/usr/include/linux/nfs_mount.h
SWAPH=/usr/include/linux/swap.h
LOOPH=/usr/include/linux/loop.h

nfs_mountversion.h:
	rm -f nfs_mountversion.h
	if [ -f $(NFSMOUNTH) ]; then \
		grep NFS_MOUNT_VERSION $(NFSMOUNTH) \
			| sed -e 's/NFS/KERNEL_NFS/'; \
	else \
		echo '#define KERNEL_NFS_MOUNT_VERSION 0'; \
	fi > nfs_mountversion.h

swap.h:
	rm -f swap.h
	if [ -f $(SWAPH) ]; then cp $(SWAPH) .; else touch swap.h; fi

swapargs.h:
	sh swap.configure

loop.h:
	rm -f loop.h
	if [ -f $(LOOPH) ]; then cp $(LOOPH) .; else touch loop.h; fi

clean:
	rm -f a.out core *~ *.o swapargs.h $(PROGS) swapoff
	rm -f swap.h loop.h nfs_mountversion.h

clobber distclean realclean: clean
	rm -f $(GEN_FILES)