Fix how we initialise the oplocks parameter.
[samba.git] / source4 / rules.mk
1 # Dependencies command
2 DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \
3     $(CFLAGS) $(CPPFLAGS) $< -o $@
4 # Dependencies for host objects
5 HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \
6     $(HOSTCC_FLAGS) $(CPPFLAGS) $< -o $@
7 # Dependencies for precompiled headers
8 PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \
9     $(CFLAGS) $(CPPFLAGS) $< -o $@
10
11 # Run a static analysis checker
12 CHECK = $(CC_CHECKER) $(CFLAGS) $(PICFLAG) $(CPPLAGS) -c $< -o $@
13
14 # Run the configured compiler
15 COMPILE = $(CC) $(CFLAGS) $(PICFLAG) \
16                   $(CPPFLAGS) \
17                   -c $< -o $@
18
19 # Run the compiler for the build host
20 HCOMPILE = $(HOSTCC) $(HOSTCC_FLAGS) $(CPPFLAGS) -c $< -o $@
21
22 # Precompile headers
23 PCHCOMPILE = @$(CC) -Ilib/replace \
24     $(CFLAGS) $(PICFLAG) $(CPPFLAGS) -c $< -o $@
25
26 # Partial linking
27 PARTLINK = @$(PROG_LD) -r
28
29 include/config.h:
30         @echo "include/config.h not present"
31         @echo "You need to rerun ./autogen.sh and ./configure"
32         @/bin/false
33
34 $(srcdir)/version.h: $(srcdir)/VERSION
35         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
36
37 regen_version::
38         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
39
40 clean_pch::
41         @echo "Removing precompiled headers"
42         @-rm -f include/includes.h.gch
43
44 pch:: clean_pch include/includes.h.gch
45
46 clean:: clean_pch
47         @echo Removing objects
48         @-find . -name '*.o' -exec rm -f '{}' \;
49         @echo Removing hostcc objects
50         @-find . -name '*.ho' -exec rm -f '{}' \;
51         @echo Removing binaries
52         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
53         @echo Removing libraries
54         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
55         @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
56         @echo Removing modules
57         @-rm -f bin/modules/*/*.$(SHLIBEXT)
58         @-rm -f bin/*_init_module.c
59         @echo Removing dummy targets
60         @-rm -f bin/.*_*
61         @echo Removing generated files
62         @-rm -f bin/*_init_module.c
63         @-rm -rf librpc/gen_* 
64         @echo Removing proto headers
65         @-rm -f $(PROTO_HEADERS)
66
67 distclean:: clean
68         -rm -f include/config.h include/config_tmp.h include/build.h
69         -rm -f data.mk
70         -rm -f config.status
71         -rm -f config.log config.cache
72         -rm -f config.pm config.mk
73         -rm -f $(PC_FILES)
74
75 removebackup::
76         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
77
78 realdistclean:: distclean removebackup
79         -rm -f include/config_tmp.h.in
80         -rm -f version.h
81         -rm -f configure
82         -rm -f $(MANPAGES)
83
84 check:: test
85
86 unused_macros:
87         $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
88
89 # Create a static library
90 %.a:
91         @echo Linking $@
92         @rm -f $@
93         @mkdir -p $(@D)
94         @$(STLD) $(STLD_FLAGS) $@ $^
95
96 ###############################################################################
97 # File types
98 ###############################################################################
99
100 .SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .$(SHLIBEXT) .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd
101
102 .c.d:
103         @echo "Generating dependencies for $<"
104         @$(DEPENDS)
105
106 .c.hd:
107         @echo "Generating host-compiler dependencies for $<"
108         @$(HDEPENDS)
109
110 include/includes.d: include/includes.h
111         @echo "Generating dependencies for $<"
112         @$(PCHDEPENDS)
113
114 .c.o:
115         @if test -n "$(CC_CHECKER)"; then \
116                 echo "Checking  $< with '$(CC_CHECKER)'"; \
117                 $(CHECK) ; \
118         fi
119         @echo "Compiling $<"
120         @-mkdir -p `dirname $@`
121         @$(COMPILE) && exit 0 ; \
122                 echo "The following command failed:" 1>&2;\
123                 $(COMPILE) >/dev/null 2>&1
124
125
126 #               echo "$(COMPILE)" 1>&2;\
127
128 .c.ho:
129         @echo "Compiling $< with host compiler"
130         @-mkdir -p `dirname $@`
131         @$(HCOMPILE) && exit 0;\
132                 echo "The following command failed:" 1>&2;\
133                 echo "$(HCOMPILE)" 1>&2;\
134                 $(HCOMPILE) >/dev/null 2>&1
135
136 .h.h.gch:
137         @echo "Precompiling $<"
138         @$(PCHCOMPILE)
139
140 .y.c:
141         @echo "Building $< with $(YACC)"
142         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
143
144 .l.c:
145         @echo "Building $< with $(LEX)"
146         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
147
148 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
149
150 .1.xml.1:
151         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
152
153 .3.xml.3:
154         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
155
156 .5.xml.5:
157         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
158
159 .7.xml.7:
160         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
161
162 .8.xml.8:
163         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
164
165 dist:: idl_full manpages configure distclean 
166
167 configure: 
168         ./autogen.sh
169
170 showflags::
171         @echo 'Samba will be compiled with flags:'
172         @echo '  CPP        = $(CPP)'
173         @echo '  CPPFLAGS   = $(CPPFLAGS)'
174         @echo '  CC         = $(CC)'
175         @echo '  CFLAGS     = $(CFLAGS)'
176         @echo '  PICFLAG    = $(PICFLAG)'
177         @echo '  BNLD       = $(BNLD)'
178         @echo '  BNLD_FLAGS = $(BNLD_FLAGS)'
179         @echo '  STLD       = $(STLD)'
180         @echo '  STLD_FLAGS = $(STLD_FLAGS)'
181         @echo '  SHLD       = $(SHLD)'
182         @echo '  SHLD_FLAGS = $(SHLD_FLAGS)'
183         @echo '  MDLD       = $(MDLD)'
184         @echo '  MDLD_FLAGS = $(MDLD_FLAGS)'
185         @echo '  SHLIBEXT   = $(SHLIBEXT)'
186
187 etags:
188         etags `find $(srcdir) -name "*.[ch]"`
189
190 ctags:
191         ctags `find $(srcdir) -name "*.[ch]"`