Use mkinclude (makes the Makefile a bit shorter), use double-colon for phony makefile...
[samba.git] / source4 / rules.mk
1 include/config.h:
2         @echo "include/config.h not present"
3         @echo "You need to rerun ./autogen.sh and ./configure"
4         @/bin/false
5
6 $(srcdir)/version.h: $(srcdir)/VERSION
7         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
8
9 regen_version::
10         @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
11
12 clean_pch::
13         @echo "Removing precompiled headers"
14         @-rm -f include/includes.h.gch
15
16 pch:: clean_pch include/includes.h.gch
17
18 clean:: clean_pch
19         @echo Removing objects
20         @-find . -name '*.o' -exec rm -f '{}' \;
21         @echo Removing hostcc objects
22         @-find . -name '*.ho' -exec rm -f '{}' \;
23         @echo Removing binaries
24         @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
25         @echo Removing libraries
26         @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
27         @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT)
28         @echo Removing modules
29         @-rm -f bin/modules/*/*.$(SHLIBEXT)
30         @-rm -f bin/*_init_module.c
31         @echo Removing dummy targets
32         @-rm -f bin/.*_*
33         @echo Removing generated files
34         @-rm -f bin/*_init_module.c
35         @-rm -rf librpc/gen_* 
36         @echo Removing proto headers
37         @-rm -f $(PROTO_HEADERS)
38
39 distclean:: clean
40         -rm -f include/config.h include/config_tmp.h include/build.h
41         -rm -f Makefile 
42         -rm -f config.status
43         -rm -f config.log config.cache
44         -rm -f config.pm config.mk
45         -rm -f $(PC_FILES)
46
47 removebackup::
48         -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
49
50 realdistclean:: distclean removebackup
51         -rm -f include/config_tmp.h.in
52         -rm -f version.h
53         -rm -f configure
54         -rm -f $(MANPAGES)
55
56 check:: test
57
58 unused_macros:
59         $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
60
61 ###############################################################################
62 # File types
63 ###############################################################################
64
65 .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
66
67 .c.d:
68         @echo "Generating dependencies for $<"
69         @$(DEPENDS)
70
71 .c.hd:
72         @echo "Generating host-compiler dependencies for $<"
73         @$(HDEPENDS)
74
75 include/includes.d: include/includes.h
76         @echo "Generating dependencies for $<"
77         @$(PCHDEPENDS)
78
79 .c.o:
80         @if test -n "$(CC_CHECKER)"; then \
81                 echo "Checking  $< with '$(CC_CHECKER)'"; \
82                 $(CHECK) ; \
83         fi
84         @echo "Compiling $<"
85         @-mkdir -p `dirname $@`
86         @$(COMPILE) && exit 0 ; \
87                 echo "The following command failed:" 1>&2;\
88                 echo "$(COMPILE)" 1>&2;\
89                 $(COMPILE) >/dev/null 2>&1
90
91 .c.ho:
92         @echo "Compiling $< with host compiler"
93         @-mkdir -p `dirname $@`
94         @$(HCOMPILE) && exit 0;\
95                 echo "The following command failed:" 1>&2;\
96                 echo "$(HCOMPILE)" 1>&2;\
97                 $(HCOMPILE) >/dev/null 2>&1
98
99 .h.h.gch:
100         @echo "Precompiling $<"
101         @$(PCHCOMPILE)
102
103 .y.c:
104         @echo "Building $< with $(YACC)"
105         @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
106
107 .l.c:
108         @echo "Building $< with $(LEX)"
109         @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
110
111 DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
112
113 .1.xml.1:
114         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
115
116 .3.xml.3:
117         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
118
119 .5.xml.5:
120         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
121
122 .7.xml.7:
123         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
124
125 .8.xml.8:
126         $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
127
128 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
129                    include/includes.d
130
131 dist:: idl_full manpages configure distclean 
132
133 configure: 
134         ./autogen.sh