Merge branch 'vendor/DIFFUTILS'
[dragonfly.git] / Makefile
1 #
2 # $FreeBSD: src/Makefile,v 1.234.2.19 2003/04/16 09:59:40 ru Exp $
3 #
4 # The user-driven targets are:
5 #
6 # buildworld          - Rebuild *everything* but the kernel, including glue to
7 #                       help do upgrades.
8 # quickworld          - Skip bootstrap, build and cross-build tool steps.
9 # realquickworld      - Skip above steps, plus depend.
10 # crossworld          - Just do the bootstrap, build, and cross-build steps.
11 # installworld        - Install everything built by "buildworld".
12 # installworld-force  - Install everything built by "buildworld";
13 #                       special case for old systems.
14 # world               - buildworld + installworld.
15 # buildkernel         - Rebuild the kernel and the kernel-modules from scratch
16 #                       using build/bootstrap/cross tools from the last
17 #                       buildworld.
18 # nativekernel        - Rebuild the kernel and the kernel-modules from scratch
19 #                       using native tools.
20 # quickkernel         - Rebuild the kernel quickly (build or native), and do
21 #                       not clean out the obj modules.
22 # realquickkernel     - Like quickkernel, but skips depend too.
23 # installkernel       - Install the kernel and the kernel-modules.
24 # reinstallkernel     - Reinstall the kernel and the kernel-modules.
25 # kernel              - buildkernel + installkernel.
26 # preupgrade          - Do certain upgrades (typically the addition of new
27 #                       users and groups used by installed utilities) before
28 #                       the installworld.
29 # upgrade             - Upgrade the files in /etc and also setup the rest
30 #                       of the system for DragonFly. ex. two compilers.
31 # rescue              - Build and install the statically linked rescue tools.
32 # initrd              - Build the rescue tools and create the initrd image.
33 # most                - Build user commands, no libraries or include files.
34 # installmost         - Install user commands, no libraries or include files.
35 # backupworld         - Copy /bin /sbin /usr/bin /usr/sbin /usr/lib
36 #                       /usr/libexec to manual backup dir.
37 # restoreworld        - Install binaries from manual backup dir to world.
38 # restoreworld-auto   - Install binaries from auto-backup dir to world;
39 #                       installworld target makes backup to auto-backup dir.
40 # backup-auto-clean   - Delete backup from auto-backup dir.
41 # backup-clean        - Delete backup from manual backup dir.
42 #
43 # This makefile is simple by design. The DragonFly make automatically reads
44 # /usr/share/mk/sys.mk unless the -m argument is specified on the
45 # command line. By keeping this makefile simple, it doesn't matter too
46 # much how different the installed mk files are from those in the source
47 # tree. This makefile executes a child make process, forcing it to use
48 # the mk files from the source tree which are supposed to DTRT.
49 #
50 # Most of the user-driven targets (as listed above) are implemented in
51 # Makefile.inc1.
52 #
53 # For individuals wanting to build from the sources currently on their
54 # system, the simple instructions are:
55 #
56 # 1.  `cd /usr/src'  (or to the directory containing your source tree).
57 # 2.  `make world'
58 #
59 # For individuals wanting to upgrade their sources (even if only a
60 # delta of a few days):
61 #
62 # 1.  `cd /usr/src'       (or to the directory containing your source tree).
63 # 2.  `make buildworld'
64 # 3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'   (default is X86_64_GENERIC).
65 # 4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is X86_64_GENERIC).
66 # 5.  `make installworld'
67 # 6.  `make upgrade'
68 # 7.  `reboot'
69 # 8.  `make initrd'       (after making sure that the new world works well).
70 #
71 # If TARGET_ARCH=arch (e.g. x86_64) is specified you can
72 # cross build world for other architectures using the buildworld target,
73 # and once the world is built you can cross build a kernel using the
74 # buildkernel target.
75 #
76 # For more information, see the build(7) manual page.
77 #
78
79 TGTS=   all all-man buildkernel quickkernel realquickkernel nativekernel \
80         buildworld crossworld quickworld realquickworld checkdpadd clean \
81         cleandepend cleandir depend everything \
82         hierarchy install installcheck installkernel \
83         reinstallkernel installmost installworld installworld-force \
84         libraries lint maninstall \
85         manlint mk most obj objlink regress rerelease tags \
86         backupworld restoreworld restoreworld-auto \
87         backup-clean backup-auto-clean \
88         _obj _includes _libraries _depend _worldtmp \
89         _bootstrap-tools _build-tools _cross-tools
90 TGTS+=  mandiff # XXX temporary target
91
92 BITGTS= files includes
93 BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
94
95 .ORDER: buildworld installworld
96 .ORDER: buildworld buildkernel
97 .ORDER: buildworld nativekernel
98 .ORDER: buildworld quickkernel
99 .ORDER: buildworld realquickkernel
100 .ORDER: buildkernel installkernel
101 .ORDER: buildkernel reinstallkernel
102 .ORDER: quickworld installworld
103 .ORDER: quickworld buildkernel
104 .ORDER: quickworld nativekernel
105 .ORDER: quickworld quickkernel
106 .ORDER: quickworld realquickkernel
107 .ORDER: quickkernel installkernel
108 .ORDER: quickkernel reinstallkernel
109 .ORDER: realquickkernel installkernel
110 .ORDER: realquickkernel reinstallkernel
111
112 PATH=   /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/pkg/bin
113 MAKE=   PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
114
115 #
116 # Handle the user-driven targets, using the source relative mk files.
117 #
118 ${TGTS} ${BITGTS}:
119         @cd ${.CURDIR}; \
120                 ${MAKE} ${.TARGET}
121
122 # Set a reasonable default
123 .MAIN:  all
124
125 STARTTIME!= LC_ALL=C date
126 #
127 # world
128 #
129 # Attempt to rebuild and reinstall *everything*, with reasonable chance of
130 # success, regardless of how old your existing system is.
131 #
132 world:
133         @echo "--------------------------------------------------------------"
134         @echo ">>> make world started on ${STARTTIME}"
135         @echo "--------------------------------------------------------------"
136 .if target(pre-world)
137         @echo
138         @echo "--------------------------------------------------------------"
139         @echo ">>> starting pre-world target"
140         @echo "--------------------------------------------------------------"
141         @cd ${.CURDIR}; ${MAKE} pre-world
142         @echo "--------------------------------------------------------------"
143         @echo ">>> pre-world target complete"
144         @echo "--------------------------------------------------------------"
145 .endif
146         @cd ${.CURDIR}; ${MAKE} buildworld
147         @cd ${.CURDIR}; ${MAKE} -B installworld
148 .if target(post-world)
149         @echo
150         @echo "--------------------------------------------------------------"
151         @echo ">>> starting post-world target"
152         @echo "--------------------------------------------------------------"
153         @cd ${.CURDIR}; ${MAKE} post-world
154         @echo "--------------------------------------------------------------"
155         @echo ">>> post-world target complete"
156         @echo "--------------------------------------------------------------"
157 .endif
158         @echo
159         @echo "--------------------------------------------------------------"
160         @printf ">>> make world completed on `LC_ALL=C date`\n                        (started ${STARTTIME})\n"
161         @echo "--------------------------------------------------------------"
162
163 #
164 # kernel
165 #
166 # Short hand for `make buildkernel installkernel'
167 #
168 kernel: buildkernel installkernel
169
170 #
171 # A simple test target used as part of the test to see if make supports
172 # the -m argument.  Also test that make will only evaluate a conditional
173 # as far as is necessary to determine its value.
174 #
175 test:
176 .if defined(notdef)
177 .undef notdef
178 .if defined(notdef) && ${notdef:tu}
179 .endif
180 .endif
181
182 #
183 # Upgrade the installed make to the current version using the installed
184 # headers, libraries and build tools. This is required on installed versions
185 # prior to 2.2.5 in which the installed make doesn't support the -m argument.
186 #
187 make:
188         @echo
189         @echo "--------------------------------------------------------------"
190         @echo " Upgrading the installed make"
191         @echo "--------------------------------------------------------------"
192         @cd ${.CURDIR}/usr.bin/make; \
193                 make obj && make depend && make all && make install
194
195 #
196 # Handle the upgrade of /etc, post-installworld updating of static files
197 # and removing obsolete files.
198 #
199
200 preupgrade:
201         @cd ${.CURDIR}/etc; make -m ${.CURDIR}/share/mk preupgrade
202
203 upgrade:
204         @cd ${.CURDIR}/etc; make -m ${.CURDIR}/share/mk upgrade_etc
205 .if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
206         @cd ${.CURDIR}/share/man; make makedb
207 .endif
208         @echo "--------------------------------------------------------------"
209         @echo "Now you can reboot into the new system!  If the new system works as"
210         @echo "expected, consider updating the rescue tools and initrd image with:"
211         @echo "    # cd ${.CURDIR}; make initrd"
212         @echo "NOTE: Do this only after verifying the new system works as expected!"
213         @echo ""
214         @echo "You also need to upgrade the 3rd-party packages with:"
215         @echo "    # pkg update; pkg [-f] upgrade"
216         @echo "--------------------------------------------------------------"
217
218 #
219 # Build and install the statically linked rescue tools, and create the
220 # initrd image.
221 #
222 rescue initrd: .PHONY
223         (cd ${.CURDIR}/initrd; make ${.TARGET})