Copyright updates:
[exim.git] / src / Makefile
1 # Top-level makefile for Exim; handles creating a build directory with
2 # appropriate links, and then creating and running the main makefile in that
3 # directory.
4
5 # Copyright (c) The Exim Maintainers 2022
6 # Copyright (c) University of Cambridge, 1995 - 2018
7 # See the file NOTICE for conditions of use and distribution.
8
9 # IRIX make uses the shell that is in the SHELL variable, which often defaults
10 # to csh, so put this in to make it use the Bourne shell. In systems where
11 # /bin/sh is not a Bourne-compatible shell, this line will have to be edited,
12 # or "make" must be called with a different SHELL= setting.
13
14 SHELL=/bin/sh
15 RM_COMMAND=/bin/rm
16
17 # The buildname defaults to "<os-type>-<arch-type>". It can be
18 # overridden by the "build" parameter when invoking make (e.g. make
19 # build=xxx) This does not provide an override for the OS type and
20 # architecture type used during the build process; they still have to be
21 # used for the OS-specific files. To override them, you can set the
22 # shell variables OSTYPE and ARCHTYPE when running make.
23 #
24 # EXIM_BUILD_SUFFIX gets appended to the buildname.  (This enables
25 # parallel builds on a file system shared among different Linux distros
26 # (same os-type, same arch-type). The ../test/runtest script honours the
27 # EXIM_BUILD_SUFFIX when searching the Exim binary.)
28
29 buildname=$${build:-`$(SHELL) scripts/os-type`-`$(SHELL) scripts/arch-type`}$${EXIM_BUILD_SUFFIX:+.$$EXIM_BUILD_SUFFIX}
30
31 # The default target checks for the existence of Local/Makefile, that the main
32 # makefile is built and up-to-date, and then it runs it.
33 # If Local/Makefile-<buildname> exists, it is read too.
34
35 all: Local/Makefile configure
36         @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS)
37
38 # This pair for the convenience of of the Debian maintainers
39 exim: Local/Makefile configure
40         @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS) exim
41 utils: Local/Makefile configure
42         @cd build-$(buildname); $(MAKE) SHELL=$(SHELL) $(MFLAGS) utils
43
44 Local/Makefile:
45         @echo ""
46         @echo "*** Please create Local/Makefile by copying src/EDITME and making"
47         @echo "*** appropriate changes for your site."
48         @echo ""
49         @test ! -d Local && mkdir Local
50         @false
51
52 # This is separated off so that "make build-directory" can be obeyed on
53 # its own if necessary.
54
55 build-directory:
56         @builddir=build-$(buildname); \
57         case "$$builddir" in *UnKnown*) exit 1;; esac; \
58         $(SHELL) -c "test -d $$builddir -a -r $$builddir/version.c || \
59           (mkdir $$builddir; cd $$builddir; $(SHELL) ../scripts/MakeLinks)";
60
61 checks:
62         $(SHELL) scripts/source_checks
63
64 # The "configure" target ensures that the build directory exists, then arranges
65 # to build the main makefile from inside the build directory, by calling the
66 # Configure-Makefile script. This does its own dependency checking because of
67 # the optional files.
68
69 configure: checks build-directory
70         @cd build-$(buildname); \
71           build=$(build) $(SHELL) ../scripts/Configure-Makefile
72
73 # The "makefile" target forces a rebuild of the makefile (as opposed to
74 # "configure", which doesn't force it).
75
76 makefile: build-directory
77         @cd build-$(buildname); $(RM_COMMAND) -f Makefile; \
78           build=$(build) $(SHELL) ../scripts/Configure-Makefile
79
80 # The installation commands are kept in a separate script, which expects
81 # to be run from inside the build directory.
82
83 install:        all
84                 @cd build-$(buildname); \
85                 build=$(build) $(SHELL) ../scripts/exim_install $(INSTALL_ARG)
86
87 # Tidy-up targets
88
89 clean:; @echo ""; echo '*** "make clean" just removes all .o and .a files'
90         @echo '*** Use "make makefile" to force a rebuild of the makefile'
91         @echo ""
92         cd build-$(buildname); \
93         $(RM_COMMAND) -f *.o lookups/*.o lookups/*.a auths/*.o auths/*.a \
94         routers/*.o routers/*.a transports/*.o transports/*.a \
95         pdkim/*.o pdkim/*.a
96
97 clean_exim:; cd build-$(buildname); \
98          $(RM_COMMAND) -f *.o lookups/*.o lookups/*.a auths/*.o auths/*.a \
99         routers/*.o routers/*.a transports/*.o transports/*.a lookups/*.so
100
101 distclean:; $(RM_COMMAND) -rf build-* cscope*
102
103 cscope.files: FRC
104         echo "-q" > $@
105         echo "-p3" >> $@
106         -bd=build-$(buildname); [ -d $$bd ] && echo -e "$$bd/config.h\n$$bd/Makefile" >> $@
107         find src Local OS exim_monitor -name "*.[cshyl]" -print \
108                     -o -name "os.[ch]*" -print \
109                     -o -name "*akefile*" -print \
110                     -o -name config.h.defaults -print \
111                     -o -name EDITME -print >> $@
112
113 FRC:
114
115 # End of top-level makefile