]> git.decadent.org.uk Git - nfs-utils.git/blob - rules.mk
Fix format.
[nfs-utils.git] / rules.mk
1 #
2 # General make rules
3 #
4 .DEFAULT:       all
5 .PHONY:         $(ALLTARGETS)
6
7 include $(TOP)config.mk
8
9 ##################################################################
10 # Subdirectory handling
11 ##################################################################
12 ifneq ($(SUBDIRS),)
13 $(ALLTARGETS)::
14         @set -e; for d in $(SUBDIRS); do \
15                 echo "Making $@ in $$d"; \
16                 $(MAKE) --no-print-directory TOP=../$(TOP) -C $$d $@; \
17         done
18 endif
19
20 ##################################################################
21 # Building an RPC daemon
22 ##################################################################
23 ifneq ($(PROGRAM),)
24 TARGET  = $(PROGRAM)
25
26 $(PROGRAM): $(OBJS) $(LIBDEPS)
27         $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
28
29 install:: $(PROGRAM)
30         -$(MKDIR) $(SBINDIR)
31         $(INSTALLBIN) $(PROGRAM) $(SBINDIR)/$(PREFIX)$k$(PROGRAM)
32 endif
33
34 ##################################################################
35 # Building a tool
36 ##################################################################
37 ifneq ($(TOOL),)
38 TARGET  = $(TOOL)
39
40 $(TOOL): $(OBJS) $(LIBDEPS)
41         $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
42 endif
43
44 ##################################################################
45 # Building a library
46 ##################################################################
47 ifneq ($(LIBNAME),)
48 TARGET  = $(LIBNAME)
49
50 $(LIBNAME): $(OBJS)
51         $(AR) cr $@ $^
52         $(RANLIB) $@
53 endif
54
55 ##################################################################
56 # Generic target rules
57 ##################################################################
58 ifneq ($(TARGET),)
59 all:: $(TARGET)
60         @echo "Building $(TARGET) done."
61
62 install:: $(TARGET)
63
64 distclean::
65         rm -f $(TARGET)
66 endif
67
68 ##################################################################
69 # Cleaning rules
70 ##################################################################
71 clean distclean::
72         rm -f *.o *~ \#* a.out core
73
74 distclean::
75         rm -f LOG X Y Z x y z .depend
76
77 ##################################################################
78 # Manpage installation
79 # Isn't GNU make a wonderful thing?
80 ##################################################################
81 ifneq ($(MAN1)$(MAN5)$(MAN8)$(MAN9),)
82 MANINIT = ext=$(MAN$sEXT); dir=$(MAN$sDIR); pgs="$(MAN$s)";
83 MANLOOP = $(MANINIT) for man in $$pgs; do eval $$cmd; done
84 MDCMD   = $(MKDIR) \$$dir
85 MICMD   = $(RM) \$$dir/\$$man.\$$ext; \
86           echo $(INSTALLMAN) \$$man.man \$$dir/\$$man.\$$ext; \
87           $(INSTALLMAN) \$$man.man \$$dir/\$$man.\$$ext
88 LNCMD   = $(RM) \$$dir/$(PREFIX)\$$man.\$$ext; \
89           echo $(LN_S) \$$man.\$$ext \$$dir/$(PREFIX)\$$man.\$$ext; \
90           $(LN_S) \$$man.\$$ext \$$dir/$(PREFIX)\$$man.\$$ext
91 PSCMD   = echo \"$(MAN2PS) \$$man.man > $(TOP)postscript/\$$man.ps\"; \
92           $(MAN2PS) \$$man.man > $(TOP)postscript/\$$man.ps
93
94 installman::
95         @$(foreach s, 1 5 8 9, cmd="$(MDCMD)" $(MANLOOP);)
96         @$(foreach s, 1 5 8 9, cmd="$(MICMD)" $(MANLOOP);)
97 ifneq ($(PREFIX),)
98         @$(foreach s, 1 5 8 9, cmd="$(LNCMD)" $(MANLOOP);)
99 endif
100
101 postscript::
102         @$(foreach s, 1 5 8 9, cmd="$(PSCMD)" $(MANLOOP);)
103 else
104 postscript installman::
105         @: No manpages...
106 endif
107
108 ##################################################################
109 # Indenting
110 ##################################################################
111 ifneq ($(SRCS),)
112 indent:
113         $(INDENT) $(SRCS)
114 endif
115         
116 ##################################################################
117 # Handling of dependencies
118 ##################################################################
119 ifneq ($(OBJS),)
120 depend dep::
121         $(CC) $(CFLAGS) -M $(OBJS:.o=.c) > .depend
122 endif
123
124 ifeq (.depend,$(wildcard .depend))
125 include .depend
126 endif