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