rmuser(8): Use getopts for commandline options
[dragonfly.git] / Makefile
CommitLineData
984263bc
MD
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#
e79a303f
AL
6# buildworld - Rebuild *everything* but the kernel, including glue to
7# help do upgrades.
f71956f7
AL
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.
984263bc 11# installworld - Install everything built by "buildworld".
f71956f7
AL
12# installworld-force - Install everything built by "buildworld";
13# special case for old systems.
984263bc 14# world - buildworld + installworld.
fc7aca3e 15# buildkernel - Rebuild the kernel and the kernel-modules from scratch
f71956f7
AL
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.
92c9dfec 22# realquickkernel - Like quickkernel, but skips depend too.
984263bc
MD
23# installkernel - Install the kernel and the kernel-modules.
24# reinstallkernel - Reinstall the kernel and the kernel-modules.
25# kernel - buildkernel + installkernel.
e79a303f
AL
26# preupgrade - Do certain upgrades (typically the addition of new
27# users and groups used by installed utilities) before
f71956f7 28# the installworld.
8db5e54f 29# upgrade - Upgrade the files in /etc and also setup the rest
f71956f7 30# of the system for DragonFly. ex. two compilers.
e79a303f
AL
31# rescue - Build and install the statically linked rescue tools.
32# initrd - Build the rescue tools and create the initrd image.
984263bc
MD
33# most - Build user commands, no libraries or include files.
34# installmost - Install user commands, no libraries or include files.
f71956f7 35# backupworld - Copy /bin /sbin /usr/bin /usr/sbin /usr/lib
2decc9b9 36# /usr/libexec to manual backup dir.
f71956f7
AL
37# restoreworld - Install binaries from manual backup dir to world.
38# restoreworld-auto - Install binaries from auto-backup dir to world;
2decc9b9
JM
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.
984263bc 42#
114580ac 43# This makefile is simple by design. The DragonFly make automatically reads
f71956f7 44# /usr/share/mk/sys.mk unless the -m argument is specified on the
984263bc
MD
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#
f71956f7 50# Most of the user-driven targets (as listed above) are implemented in
e79a303f 51# Makefile.inc1.
984263bc
MD
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'
dd7331fe
SW
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).
30d6fede
SW
66# 5. `make installworld'
67# 6. `make upgrade'
68# 7. `reboot'
e79a303f 69# 8. `make initrd' (after making sure that the new world works well).
984263bc 70#
b2b3ffcd 71# If TARGET_ARCH=arch (e.g. x86_64) is specified you can
984263bc
MD
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#
f71956f7 76# For more information, see the build(7) manual page.
984263bc 77#
f71956f7 78
92c9dfec 79TGTS= all all-man buildkernel quickkernel realquickkernel nativekernel \
fc7aca3e 80 buildworld crossworld quickworld realquickworld checkdpadd clean \
5cccfb7b 81 cleandepend cleandir depend everything \
984263bc 82 hierarchy install installcheck installkernel \
f71956f7
AL
83 reinstallkernel installmost installworld installworld-force \
84 libraries lint maninstall \
28d76656 85 manlint mk most obj objlink regress rerelease tags \
e79a303f 86 backupworld restoreworld restoreworld-auto \
2decc9b9 87 backup-clean backup-auto-clean \
fd4528de 88 _obj _includes _libraries _depend _worldtmp \
9f8ba22c 89 _bootstrap-tools _build-tools _cross-tools
18cdb849 90TGTS+= mandiff # XXX temporary target
984263bc
MD
91
92BITGTS= files includes
93BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
94
95.ORDER: buildworld installworld
828e58f9
SS
96.ORDER: buildworld buildkernel
97.ORDER: buildworld nativekernel
98.ORDER: buildworld quickkernel
92c9dfec 99.ORDER: buildworld realquickkernel
828e58f9
SS
100.ORDER: buildkernel installkernel
101.ORDER: buildkernel reinstallkernel
102.ORDER: quickworld installworld
828e58f9
SS
103.ORDER: quickworld buildkernel
104.ORDER: quickworld nativekernel
105.ORDER: quickworld quickkernel
92c9dfec 106.ORDER: quickworld realquickkernel
828e58f9
SS
107.ORDER: quickkernel installkernel
108.ORDER: quickkernel reinstallkernel
92c9dfec
SW
109.ORDER: realquickkernel installkernel
110.ORDER: realquickkernel reinstallkernel
984263bc 111
ee48961f 112PATH= /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/pkg/bin
984263bc
MD
113MAKE= 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#
8db5e54f 118${TGTS} ${BITGTS}:
984263bc
MD
119 @cd ${.CURDIR}; \
120 ${MAKE} ${.TARGET}
121
122# Set a reasonable default
123.MAIN: all
124
125STARTTIME!= 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#
8db5e54f 132world:
984263bc 133 @echo "--------------------------------------------------------------"
24c1eacf 134 @echo ">>> make world started on ${STARTTIME}"
984263bc
MD
135 @echo "--------------------------------------------------------------"
136.if target(pre-world)
137 @echo
138 @echo "--------------------------------------------------------------"
24c1eacf 139 @echo ">>> starting pre-world target"
984263bc
MD
140 @echo "--------------------------------------------------------------"
141 @cd ${.CURDIR}; ${MAKE} pre-world
24c1eacf
JM
142 @echo "--------------------------------------------------------------"
143 @echo ">>> pre-world target complete"
144 @echo "--------------------------------------------------------------"
984263bc
MD
145.endif
146 @cd ${.CURDIR}; ${MAKE} buildworld
147 @cd ${.CURDIR}; ${MAKE} -B installworld
148.if target(post-world)
149 @echo
150 @echo "--------------------------------------------------------------"
24c1eacf 151 @echo ">>> starting post-world target"
984263bc
MD
152 @echo "--------------------------------------------------------------"
153 @cd ${.CURDIR}; ${MAKE} post-world
24c1eacf
JM
154 @echo "--------------------------------------------------------------"
155 @echo ">>> post-world target complete"
156 @echo "--------------------------------------------------------------"
984263bc
MD
157.endif
158 @echo
159 @echo "--------------------------------------------------------------"
24c1eacf 160 @printf ">>> make world completed on `LC_ALL=C date`\n (started ${STARTTIME})\n"
984263bc
MD
161 @echo "--------------------------------------------------------------"
162
163#
164# kernel
165#
166# Short hand for `make buildkernel installkernel'
167#
168kernel: buildkernel installkernel
169
984263bc
MD
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#
175test:
176.if defined(notdef)
177.undef notdef
3da8e88f
JM
178.if defined(notdef) && ${notdef:tu}
179.endif
3da8e88f 180.endif
984263bc
MD
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#
187make:
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#
30d8ccf3
SW
196# Handle the upgrade of /etc, post-installworld updating of static files
197# and removing obsolete files.
984263bc
MD
198#
199
f35282e3 200preupgrade:
ab64cf06 201 @cd ${.CURDIR}/etc; make -m ${.CURDIR}/share/mk preupgrade
f35282e3 202
30d8ccf3 203upgrade:
ab64cf06 204 @cd ${.CURDIR}/etc; make -m ${.CURDIR}/share/mk upgrade_etc
30d8ccf3 205.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
e79a303f 206 @cd ${.CURDIR}/share/man; make makedb
30d8ccf3 207.endif
e79a303f
AL
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#
222rescue initrd: .PHONY
223 (cd ${.CURDIR}/initrd; make ${.TARGET})