summaryrefslogtreecommitdiffstats
path: root/mount/Makefile
blob: 52c4cff6d67e06c8481b0c39eb752eb17592dce8 (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
include ../make_include
include ../MCONFIG

DEFINES = -DHAVE_NFS

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

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

SUID_PROGS = mount umount
NOSUID_PROGS = swapon losetup
MAN5 = fstab.5 nfs.5
MAN8 = mount.8 swapoff.8 swapon.8 umount.8 losetup.8

ifeq "$(HAVE_PIVOT_ROOT)" "yes"
NOSUID_PROGS := $(NOSUID_PROGS) pivot_root
MAN8 := $(MAN8) pivot_root.8
endif

PROGS = $(SUID_PROGS) $(NOSUID_PROGS)

MAYBE = pivot_root swapoff

LO_OBJS = lomount.o $(LIB)/xstrncpy.o
NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o
GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c

all: $(PROGS)

install: $(PROGS)
	$(INSTALLDIR) $(BINDIR) $(SBINDIR)
	$(INSTALLSUID) $(SUID_PROGS) $(BINDIR)
	$(INSTALLBIN) $(NOSUID_PROGS) $(SBINDIR)
	(cd $(SBINDIR); ln -sf swapon swapoff)
	$(INSTALLDIR) $(MAN5DIR) $(MAN8DIR)
	$(INSTALLMAN) $(MAN5) $(MAN5DIR)
	$(INSTALLMAN) $(MAN8) $(MAN8DIR)

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

mount: mount.o fstab.o sundries.o realpath.o mntent.o version.o \
       mount_guess_fstype.o mount_by_label.o getusername.o \
       $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS)
	$(LINK) $^ -o $@

umount: umount.o fstab.o sundries.o realpath.o mntent.o getusername.o \
	version.o $(LIB)/env.o $(LO_OBJS)
	$(LINK) $^ -o $@

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

main_losetup.o: lomount.c
	$(COMPILE) -DMAIN lomount.c -o $@

losetup: main_losetup.o $(LIB)/xstrncpy.o
	$(LINK) $^ -o $@

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

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

mount.o fstab.o mntent.o: mntent.h

mount.o mount_guess_fstype.o: mount_guess_fstype.h

mount.o: $(LIB)/setproctitle.h

mount.o umount.o getusername.o: getusername.h

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

swapon.o: swap_constants.h swapargs.h

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

umount.o: mount_constants.h

mount.o mount_by_label.o mount_guess_fstype.o: linux_fs.h

sundries.o realpath.o: realpath.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

ifeq "$(HAVE_GOOD_RPC)" "yes"
nfsmount.h: nfsmount.x
	rm -f nfsmount.h
	$(RPCGEN) -h -o nfsmount.h nfsmount.x

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

nfsmount_clnt.c: nfsmount.x
	rm -f nfsmount_clnt.c
	$(RPCGEN) -l -o nfsmount_clnt.c nfsmount.x
else
nfsmount.h:
	cp $(RPCSVCDIR)/nfsmount.h .

nfsmount_xdr.c:
	cp $(RPCSVCDIR)/nfsmount_xdr.c .

nfsmount_clnt.c:
	cp $(RPCSVCDIR)/nfsmount_clnt.c .
endif

nfsmount.o: nfs_mount4.h

swapargs.h:
	sh swap.configure

loop.h:
	sh mk_loop_h

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

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