]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - Makefile.inc1
Don't build pccard for now until I can resolve the linker interaction
[FreeBSD/FreeBSD.git] / Makefile.inc1
1 #
2 # $FreeBSD$
3 #
4 # Make command line options:
5 #       -DMAKE_KERBEROS4 to build KerberosIV
6 #       -DMAKE_KERBEROS5 to build Kerberos5
7 #       -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
8 #       -DNOCLEAN do not clean at all
9 #       -DNOCRYPT will prevent building of crypt versions
10 #       -DNOPROFILE do not build profiled libraries
11 #       -DNOSECURE do not go into secure subdir
12 #       -DNOGAMES do not go into games subdir
13 #       -DNOSHARE do not go into share subdir
14 #       -DNOINFO do not make or install info files
15 #       -DNOLIBC_R do not build libc_r.
16 #       -DNO_FORTRAN do not build g77 and related libraries.
17 #       -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
18 #       -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel
19 #       -DNO_PORTSUPDATE do not update ports in ${MAKE} update
20 #       -DNO_DOCUPDATE do not update doc in ${MAKE} update
21 #       LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
22
23 #
24 # The intended user-driven targets are:
25 # buildworld  - rebuild *everything*, including glue to help do upgrades
26 # installworld- install everything built by "buildworld"
27 # update      - convenient way to update your source tree (eg: sup/cvs)
28 # most        - build user commands, no libraries or include files
29 # installmost - install user commands, no libraries or include files
30 #
31 # Standard targets (not defined here) are documented in the makefiles in
32 # /usr/share/mk.  These include:
33 #               obj depend all install clean cleandepend cleanobj
34
35 # Put initial settings here.
36 SUBDIR=
37
38 # We must do share/info early so that installation of info `dir'
39 # entries works correctly.  Do it first since it is less likely to
40 # grow dependencies on include and lib than vice versa.
41 .if exists(${.CURDIR}/share/info)
42 SUBDIR+= share/info
43 .endif
44
45 # We must do include and lib early so that the perl *.ph generation
46 # works correctly as it uses the header files installed by this.
47 .if exists(${.CURDIR}/include)
48 SUBDIR+= include
49 .endif
50 .if exists(${.CURDIR}/lib)
51 SUBDIR+= lib
52 .endif
53
54 .if exists(${.CURDIR}/bin)
55 SUBDIR+= bin
56 .endif
57 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
58 SUBDIR+= games
59 .endif
60 .if exists(${.CURDIR}/gnu)
61 SUBDIR+= gnu
62 .endif
63 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
64     !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
65 SUBDIR+= kerberosIV
66 .endif
67 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
68     !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
69 SUBDIR+= kerberos5
70 .endif
71 .if exists(${.CURDIR}/libexec)
72 SUBDIR+= libexec
73 .endif
74 .if exists(${.CURDIR}/sbin)
75 SUBDIR+= sbin
76 .endif
77 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
78 SUBDIR+= share
79 .endif
80 .if exists(${.CURDIR}/sys)
81 SUBDIR+= sys
82 .endif
83 .if exists(${.CURDIR}/usr.bin)
84 SUBDIR+= usr.bin
85 .endif
86 .if exists(${.CURDIR}/usr.sbin)
87 SUBDIR+= usr.sbin
88 .endif
89 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
90 SUBDIR+= secure
91 .endif
92
93 # etc must be last for "distribute" to work
94 .if exists(${.CURDIR}/etc)
95 SUBDIR+= etc
96 .endif
97
98 # These are last, since it is nice to at least get the base system
99 # rebuilt before you do them.
100 .if defined(LOCAL_DIRS)
101 .for _DIR in ${LOCAL_DIRS}
102 .if exists(${.CURDIR}/${_DIR}) & exists(${.CURDIR}/${_DIR}/Makefile)
103 SUBDIR+= ${_DIR}
104 .endif
105 .endfor
106 .endif
107
108 .if defined(NOCLEANDIR)
109 CLEANDIR=       clean cleandepend
110 .else
111 CLEANDIR=       cleandir
112 .endif
113
114 SUP?=           cvsup
115 SUPFLAGS?=      -g -L 2 -P -
116 .if defined(SUPHOST)
117 SUPFLAGS+=      -h ${SUPHOST}
118 .endif
119
120 MAKEOBJDIRPREFIX?=      /usr/obj
121 TARGET_ARCH?=   ${MACHINE_ARCH}
122 BUILD_ARCH!=    sysctl -n hw.machine_arch
123 .if ${BUILD_ARCH} == ${MACHINE_ARCH}
124 OBJTREE=        ${MAKEOBJDIRPREFIX}
125 .else
126 OBJTREE=        ${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
127 .endif
128 WORLDTMP=       ${OBJTREE}${.CURDIR}/${BUILD_ARCH}
129 # /usr/games added for fortune which depend on strfile
130 STRICTTMPPATH=  ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
131 TMPPATH=        ${STRICTTMPPATH}:${PATH}
132
133 TMPDIR?=        /tmp
134 TMPPID!=        echo $$$$
135 INSTALLTMP=     ${TMPDIR}/install.${TMPPID}
136
137 #
138 # Building a world goes through the following stages
139 #
140 # bootstrap-tool stage [BMAKE]
141 #       This stage is responsible for creating programs that
142 #       are needed for backward compatibility reasons. They
143 #       are not built as cross-tools.
144 # build-tool stage [TMAKE]
145 #       This stage is responsible for creating the object
146 #       tree and building any tools that are needed during
147 #       the build process.
148 # cross-tool stage [XMAKE]
149 #       This stage is responsible for creating any tools that
150 #       are needed for cross-builds. A cross-compiler is one
151 #       of them.
152 # world stage [WMAKE]
153 #       This stage actually builds the world.
154 # install stage (optional) [IMAKE]
155 #       This stage installs a previously built world.
156 #
157
158 # Common environment for bootstrap related stages
159 BOOTSTRAPENV=   MAKEOBJDIRPREFIX=${WORLDTMP} \
160                 DESTDIR=${WORLDTMP} \
161                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
162                 MACHINE_ARCH=${BUILD_ARCH} \
163                 TOOLS_PREFIX=${WORLDTMP} \
164                 PATH=${TMPPATH}
165
166 # Common environment for world related stages
167 CROSSENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
168                 COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
169                 LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
170                 OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
171                 PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.6.0
172
173 # bootstrap-tool stage
174 BMAKEENV=       ${BOOTSTRAPENV}
175 BMAKE=          ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOMAN -DNOINFO -DNOHTML
176
177 # build-tool stage
178 TMAKEENV=       MAKEOBJDIRPREFIX=${OBJTREE} \
179                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
180                 PATH=${TMPPATH}
181 TMAKE=          ${TMAKEENV} ${MAKE} -f Makefile.inc1
182
183 # cross-tool stage
184 XMAKEENV=       ${BOOTSTRAPENV} \
185                 TARGET_ARCH=${MACHINE_ARCH}
186 XMAKE=          ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNOMAN -DNOINFO -DNOHTML \
187                 -DNO_FORTRAN -DNO_GDB
188
189 # world stage
190 WMAKEENV=       ${CROSSENV} \
191                 DESTDIR=${WORLDTMP} \
192                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
193                 PATH=${TMPPATH}
194 WMAKE=          ${WMAKEENV} ${MAKE} -f Makefile.inc1
195
196 # install stage
197 IMAKEENV=       ${CROSSENV} \
198                 PATH=${STRICTTMPPATH}:${INSTALLTMP}
199 IMAKE=          ${IMAKEENV} ${MAKE} -f Makefile.inc1
200
201 USRDIRS=        usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
202                 usr/libexec/${OBJFORMAT} usr/sbin usr/share/misc
203
204 .if ${MACHINE_ARCH} == "i386" && ${MACHINE} == "pc98"
205 USRDIRS+=       usr/libexec/aout
206 .endif
207
208 INCDIRS=        arpa g++/std objc protocols readline rpc rpcsvc openssl \
209                 security ss
210
211 #
212 # buildworld
213 #
214 # Attempt to rebuild the entire system, with reasonable chance of
215 # success, regardless of how old your existing system is.
216 #
217 buildworld:
218 .if !defined(NOSECURE) && !defined(NO_OPENSSL) && exists(${.CURDIR}/secure) && \
219         (!defined(USA_RESIDENT) || (${USA_RESIDENT} != NO && \
220         ${USA_RESIDENT} != YES))
221         @echo
222         @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
223         @echo ">>> You must define the value of USA_RESIDENT as 'YES' or"
224         @echo ">>> 'NO' as appropriate, in the environment or /etc/make.conf"
225         @echo ">>> before building can proceed."
226         @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
227         @/usr/bin/false
228 .endif
229
230         @echo
231         @echo "--------------------------------------------------------------"
232         @echo ">>> Rebuilding the temporary build tree"
233         @echo "--------------------------------------------------------------"
234 .if !defined(NOCLEAN)
235         rm -rf ${WORLDTMP}
236 .else
237         for dir in bin games include lib sbin; do \
238                 rm -rf ${WORLDTMP}/usr/$$dir; \
239         done
240         rm -f ${WORLDTMP}/sys
241         # XXX - Work-around for broken cc/cc_tools/Makefile.
242         # This is beyond dirty...
243         rm -f ${OBJTREE}${.CURDIR}/gnu/usr.bin/cc/cc_tools/.depend
244 .endif
245 .for _dir in ${USRDIRS}
246         mkdir -p ${WORLDTMP}/${_dir}
247 .endfor
248 .for _dir in ${INCDIRS}
249         mkdir -p ${WORLDTMP}/usr/include/${_dir}
250 .endfor
251         ln -sf ${.CURDIR}/sys ${WORLDTMP}/sys
252         @echo
253         @echo "--------------------------------------------------------------"
254         @echo ">>> stage 1: bootstrap tools"
255         @echo "--------------------------------------------------------------"
256         cd ${.CURDIR}; ${BMAKE} bootstrap-tools
257 .if !defined(NOCLEAN)
258         @echo
259         @echo "--------------------------------------------------------------"
260         @echo ">>> stage 2: cleaning up the object tree"
261         @echo "--------------------------------------------------------------"
262         cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
263 .endif
264         @echo
265         @echo "--------------------------------------------------------------"
266         @echo ">>> stage 2: rebuilding the object tree"
267         @echo "--------------------------------------------------------------"
268         cd ${.CURDIR}; ${TMAKE} par-obj
269         @echo
270         @echo "--------------------------------------------------------------"
271         @echo ">>> stage 2: build tools"
272         @echo "--------------------------------------------------------------"
273         cd ${.CURDIR}; ${TMAKE} build-tools
274         @echo
275         @echo "--------------------------------------------------------------"
276         @echo ">>> stage 3: cross tools"
277         @echo "--------------------------------------------------------------"
278         cd ${.CURDIR}; ${XMAKE} cross-tools
279         @echo
280         @echo "--------------------------------------------------------------"
281         @echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
282         @echo "--------------------------------------------------------------"
283         cd ${.CURDIR}; ${WMAKE} SHARED=symlinks includes
284         @echo
285         @echo "--------------------------------------------------------------"
286         @echo ">>> stage 4: building libraries"
287         @echo "--------------------------------------------------------------"
288         cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
289         @echo
290         @echo "--------------------------------------------------------------"
291         @echo ">>> stage 4: make dependencies"
292         @echo "--------------------------------------------------------------"
293         cd ${.CURDIR}; ${WMAKE} par-depend
294         @echo
295         @echo "--------------------------------------------------------------"
296         @echo ">>> stage 4: building everything.."
297         @echo "--------------------------------------------------------------"
298         cd ${.CURDIR}; ${WMAKE} all
299
300 everything:
301         @echo "--------------------------------------------------------------"
302         @echo ">>> Building everything.."
303         @echo "--------------------------------------------------------------"
304         cd ${.CURDIR}; ${WMAKE} all
305
306 #
307 # installworld
308 #
309 # Installs everything compiled by a 'buildworld'.
310 #
311 installworld:
312         mkdir -p ${INSTALLTMP}
313         for prog in [ awk cat chflags chown date echo egrep find grep \
314             install ln make makewhatis mtree mv perl rm sed sh sysctl \
315             test true uname wc zic; do \
316                 cp `which $$prog` ${INSTALLTMP}; \
317         done
318         cd ${.CURDIR}; ${IMAKE} reinstall
319         rm -rf ${INSTALLTMP}
320
321 #
322 # reinstall
323 #
324 # If you have a build server, you can NFS mount the source and obj directories
325 # and do a 'make reinstall' on the *client* to install new binaries from the
326 # most recent server build.
327 #
328 reinstall:
329         @echo "--------------------------------------------------------------"
330         @echo ">>> Making hierarchy"
331         @echo "--------------------------------------------------------------"
332         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 hierarchy
333         @echo
334         @echo "--------------------------------------------------------------"
335         @echo ">>> Installing everything.."
336         @echo "--------------------------------------------------------------"
337         cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
338 .if !defined(NOMAN)
339         @echo
340         @echo "--------------------------------------------------------------"
341         @echo ">>> Rebuilding man page indices"
342         @echo "--------------------------------------------------------------"
343         cd ${.CURDIR}/share/man; ${MAKE} makedb
344 .endif
345
346 #
347 # buildkernel and installkernel
348 #
349 # Which kernels to build and/or install is specified by setting
350 # KERNEL. If not defined a GENERIC kernel is built/installed.
351 # Only the existing (depending MACHINE) config files are used
352 # for building kernels and only the first of these is designated
353 # as the one being installed.
354 #
355 # Note that we have to use MACHINE instead of MACHINE_ARCH when
356 # we're in kernel-land. Since only MACHINE_ARCH is (expected) to
357 # be set to cross-build, we have to make sure MACHINE is set
358 # properly.
359
360 KERNEL?=        GENERIC
361
362 # The only exotic MACHINE_ARCH/MACHINE combination valid at this
363 # time is i386/pc98. In all other cases set MACHINE equal to
364 # MACHINE_ARCH.
365 .if ${MACHINE_ARCH} != "i386" || ${MACHINE} != "pc98"
366 MACHINE=        ${MACHINE_ARCH}
367 .endif
368
369 KRNLSRCDIR=     ${.CURDIR}/sys
370 KRNLCONFDIR=    ${KRNLSRCDIR}/${MACHINE}/conf
371 KRNLOBJDIR=     ${OBJTREE}${KRNLSRCDIR}
372
373 .if !defined(NOCLEAN)
374 CONFIGARGS+=    -r
375 .endif
376
377 BUILDKERNELS=
378 INSTALLKERNEL=
379 .for _kernel in ${KERNEL}
380 .if exists(${KRNLCONFDIR}/${_kernel})
381 BUILDKERNELS+=  ${_kernel}
382 .if empty(INSTALLKERNEL)
383 INSTALLKERNEL= ${_kernel}
384 .endif
385 .endif
386 .endfor
387
388 #
389 # buildkernel
390 #
391 # Builds all kernels defined by BUILDKERNELS.
392 #
393 buildkernel:
394         @echo
395         @echo "--------------------------------------------------------------"
396         @echo ">>> Rebuilding kernel(s)"
397         @echo "--------------------------------------------------------------"
398 .for _kernel in ${BUILDKERNELS}
399         @echo "===> ${_kernel}"
400         mkdir -p ${KRNLOBJDIR}
401 .if !defined(NO_KERNELCONFIG)
402         cd ${KRNLCONFDIR}; \
403                 PATH=${TMPPATH} \
404                     config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
405 .endif
406         cd ${KRNLOBJDIR}/${_kernel}; \
407                 MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx \
408                     ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/Makefile
409 .if !defined(NO_KERNELDEPEND)
410         cd ${KRNLOBJDIR}/${_kernel}; \
411                 ${WMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=kernel depend
412 .endif
413         cd ${KRNLOBJDIR}/${_kernel}; \
414                 ${WMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=kernel all
415 .endfor
416
417 #
418 # installkernel
419 #
420 # Install the kernel defined by INSTALLKERNEL
421 #
422 installkernel:
423         cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
424                 ${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=kernel install
425
426 #
427 # update
428 #
429 # Update the source tree, by running sup and/or running cvs to update to the
430 # latest copy.
431 #
432 update:
433 .if defined(SUP_UPDATE)
434         @echo "--------------------------------------------------------------"
435         @echo ">>> Running ${SUP}"
436         @echo "--------------------------------------------------------------"
437 .if defined(SUPFILE)
438         @${SUP} ${SUPFLAGS} ${SUPFILE}
439 .endif
440 .if defined(SUPFILE1)
441         @${SUP} ${SUPFLAGS} ${SUPFILE1}
442 .endif
443 .if defined(SUPFILE2)
444         @${SUP} ${SUPFLAGS} ${SUPFILE2}
445 .endif
446 .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
447         @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
448 .endif
449 .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
450         @${SUP} ${SUPFLAGS} ${DOCSUPFILE}
451 .endif
452 .endif
453 .if defined(CVS_UPDATE)
454         @echo "--------------------------------------------------------------"
455         @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
456         @echo "--------------------------------------------------------------"
457         cd ${.CURDIR}; cvs -q update -A -P -d
458 .endif
459
460 #
461 # most
462 #
463 # Build most of the user binaries on the existing system libs and includes.
464 #
465 most:
466         @echo "--------------------------------------------------------------"
467         @echo ">>> Building programs only"
468         @echo "--------------------------------------------------------------"
469         cd ${.CURDIR}/bin;              ${MAKE} all
470         cd ${.CURDIR}/sbin;             ${MAKE} all
471         cd ${.CURDIR}/libexec;          ${MAKE} all
472         cd ${.CURDIR}/usr.bin;          ${MAKE} all
473         cd ${.CURDIR}/usr.sbin;         ${MAKE} all
474         cd ${.CURDIR}/gnu/libexec;      ${MAKE} all
475         cd ${.CURDIR}/gnu/usr.bin;      ${MAKE} all
476         cd ${.CURDIR}/gnu/usr.sbin;     ${MAKE} all
477
478 #
479 # installmost
480 #
481 # Install the binaries built by the 'most' target.  This does not include
482 # libraries or include files.
483 #
484 installmost:
485         @echo "--------------------------------------------------------------"
486         @echo ">>> Installing programs only"
487         @echo "--------------------------------------------------------------"
488         cd ${.CURDIR}/bin;              ${MAKE} install
489         cd ${.CURDIR}/sbin;             ${MAKE} install
490         cd ${.CURDIR}/libexec;          ${MAKE} install
491         cd ${.CURDIR}/usr.bin;          ${MAKE} install
492         cd ${.CURDIR}/usr.sbin;         ${MAKE} install
493         cd ${.CURDIR}/gnu/libexec;      ${MAKE} install
494         cd ${.CURDIR}/gnu/usr.bin;      ${MAKE} install
495         cd ${.CURDIR}/gnu/usr.sbin;     ${MAKE} install
496
497 #
498 # ------------------------------------------------------------------------
499 #
500 # From here onwards are utility targets used by the 'make world' and
501 # related targets.  If your 'world' breaks, you may like to try to fix
502 # the problem and manually run the following targets to attempt to
503 # complete the build.  Beware, this is *not* guaranteed to work, you
504 # need to have a pretty good grip on the current state of the system
505 # to attempt to manually finish it.  If in doubt, 'make world' again.
506 #
507
508 #
509 # bootstrap-tools: Build tools needed for compatibility
510 #
511 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
512 _strfile=       games/fortune/strfile
513 .endif
514
515 bootstrap-tools:
516 .for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.sbin/config \
517     gnu/usr.bin/gperf gnu/usr.bin/texinfo
518         cd ${.CURDIR}/${_tool}; \
519                 ${MAKE} obj; \
520                 ${MAKE} depend; \
521                 ${MAKE} all; \
522                 ${MAKE} install
523 .endfor
524
525 #
526 # build-tools: Build special purpose build tools
527 #
528 .if exists(${.CURDIR}/games) && !defined(NOGAMES)
529 _games= games/adventure games/hack games/phantasia
530 .endif
531
532 .if exists(${.CURDIR}/share) && !defined(NOSHARE)
533 _share= share/syscons/scrnmaps
534 .endif
535
536 .if !defined(NO_FORTRAN)
537 _fortran= gnu/usr.bin/cc/f771
538 .endif
539
540 .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
541     !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
542 _libroken4= kerberosIV/lib/libroken
543 .endif
544
545 .if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
546     !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
547 _libkrb5= kerberos5/lib/libroken kerberos5/lib/libasn1 kerberos5/lib/libhdb \
548         kerberos5/lib/libsl
549 .endif
550
551 .if !defined(NOPERL)
552 _perl=  gnu/usr.bin/perl
553 .endif
554
555 build-tools:
556 .for _tool in bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
557     ${_libroken4} ${_libkrb5} lib/libncurses ${_share} ${_perl}
558         cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
559 .endfor
560
561 #
562 # cross-tools: Build cross-building tools
563 #
564 # WARNING: Because the bootstrap tools are expected to run on the
565 # build-machine, MACHINE_ARCH is *always* set to BUILD_ARCH when this
566 # target is being made. TARGET_ARCH is *always* set to reflect the
567 # target-machine (which you can set by specifying MACHINE_ARCH on
568 # make's command-line, get it?).
569 # The reason is simple: we build these tools not to be run on the
570 # architecture we're cross-building, but on the architecture we're
571 # currently building on (ie the host-machine) and we expect these
572 # tools to produce output for the architecture we're trying to
573 # cross-build.
574 #
575 .if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
576 _elf2exe=       usr.sbin/elf2exe
577 .endif
578
579 .if ${TARGET_ARCH} == "i386" && ${MACHINE_ARCH} != "i386"
580 _btxld= usr.sbin/btxld
581 .endif
582
583 # XXX - MACHINE should actually be TARGET. But we don't set that...
584 .if ${TARGET_ARCH} == "i386" && ${MACHINE} == "pc98"
585 _aout_tools=    usr.bin/size usr.bin/strip gnu/usr.bin/as gnu/usr.bin/ld
586 .endif
587
588 cross-tools:
589 .for _tool in ${_aout_tools} ${_btxld} ${_elf2exe} usr.bin/genassym \
590     usr.bin/gensetdefs gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
591         cd ${.CURDIR}/${_tool}; \
592                 ${MAKE} obj; \
593                 ${MAKE} depend; \
594                 ${MAKE} all; \
595                 ${MAKE} install
596 .endfor
597
598 #
599 # hierarchy - ensure that all the needed directories are present
600 #
601 hierarchy:
602         cd ${.CURDIR}/etc;              ${MAKE} distrib-dirs
603
604 #
605 # includes - possibly generate and install the include files.
606 #
607 includes:
608         cd ${.CURDIR}/include;                  ${MAKE} -B all install
609         cd ${.CURDIR}/gnu/include;              ${MAKE} install
610         cd ${.CURDIR}/gnu/lib/libmp;            ${MAKE} beforeinstall
611         cd ${.CURDIR}/gnu/lib/libobjc;          ${MAKE} beforeinstall
612         cd ${.CURDIR}/gnu/lib/libreadline/readline;     ${MAKE} beforeinstall
613         cd ${.CURDIR}/gnu/lib/libregex;         ${MAKE} beforeinstall
614         cd ${.CURDIR}/gnu/lib/libstdc++;        ${MAKE} beforeinstall
615         cd ${.CURDIR}/gnu/lib/libdialog;        ${MAKE} beforeinstall
616         cd ${.CURDIR}/gnu/lib/libgmp;           ${MAKE} beforeinstall
617         cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus;   ${MAKE} beforeinstall
618 .if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
619 .if exists(${.CURDIR}/secure/lib/libcrypto)
620         cd ${.CURDIR}/secure/lib/libcrypto;     ${MAKE} beforeinstall
621 .endif
622 .if exists(${.CURDIR}/secure/lib/libssl)
623         cd ${.CURDIR}/secure/lib/libssl;        ${MAKE} beforeinstall
624 .endif
625 .endif
626 .if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
627     defined(MAKE_KERBEROS4)
628         cd ${.CURDIR}/kerberosIV/lib/libacl;    ${MAKE} beforeinstall
629         cd ${.CURDIR}/kerberosIV/lib/libkadm;   ${MAKE} beforeinstall
630         cd ${.CURDIR}/kerberosIV/lib/libkafs;   ${MAKE} beforeinstall
631         cd ${.CURDIR}/kerberosIV/lib/libkdb;    ${MAKE} beforeinstall
632         cd ${.CURDIR}/kerberosIV/lib/libkrb;    ${MAKE} beforeinstall
633         cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
634 .else
635         cd ${.CURDIR}/lib/libtelnet;            ${MAKE} beforeinstall
636 .endif
637 .if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
638     defined(MAKE_KERBEROS5)
639         cd ${.CURDIR}/kerberos5/lib/libasn1;            ${MAKE} beforeinstall
640         cd ${.CURDIR}/kerberos5/lib/libhdb;             ${MAKE} beforeinstall
641         cd ${.CURDIR}/kerberos5/lib/libkadm5clnt;       ${MAKE} beforeinstall
642         cd ${.CURDIR}/kerberos5/lib/libkadm5srv;        ${MAKE} beforeinstall
643         cd ${.CURDIR}/kerberos5/lib/libkafs5;           ${MAKE} beforeinstall
644         cd ${.CURDIR}/kerberos5/lib/libkrb5;            ${MAKE} beforeinstall
645         cd ${.CURDIR}/kerberos5/lib/libsl;              ${MAKE} beforeinstall
646 .endif
647 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
648         cd ${.CURDIR}/lib/csu/${MACHINE_ARCH};  ${MAKE} beforeinstall
649 .endif
650         cd ${.CURDIR}/lib/libalias;             ${MAKE} beforeinstall
651         cd ${.CURDIR}/lib/libatm;               ${MAKE} beforeinstall
652         cd ${.CURDIR}/lib/libdevstat;           ${MAKE} beforeinstall
653         cd ${.CURDIR}/lib/libc;                 ${MAKE} beforeinstall
654         cd ${.CURDIR}/lib/libcalendar;          ${MAKE} beforeinstall
655         cd ${.CURDIR}/lib/libcam;               ${MAKE} beforeinstall
656         cd ${.CURDIR}/lib/libdisk;              ${MAKE} beforeinstall
657         cd ${.CURDIR}/lib/libedit;              ${MAKE} beforeinstall
658         cd ${.CURDIR}/lib/libftpio;             ${MAKE} beforeinstall
659         cd ${.CURDIR}/lib/libkvm;               ${MAKE} beforeinstall
660         cd ${.CURDIR}/lib/libmd;                ${MAKE} beforeinstall
661 .if !defined(WANT_CSRG_LIBM)
662         cd ${.CURDIR}/lib/msun;                 ${MAKE} beforeinstall
663 .endif
664         cd ${.CURDIR}/lib/libncp;               ${MAKE} beforeinstall
665         cd ${.CURDIR}/lib/libncurses;           ${MAKE} beforeinstall
666         cd ${.CURDIR}/lib/libnetgraph;          ${MAKE} beforeinstall
667         cd ${.CURDIR}/lib/libopie;              ${MAKE} beforeinstall
668         cd ${.CURDIR}/lib/libpam/libpam;        ${MAKE} beforeinstall
669         cd ${.CURDIR}/lib/libpcap;              ${MAKE} beforeinstall
670         cd ${.CURDIR}/lib/libradius;            ${MAKE} beforeinstall
671         cd ${.CURDIR}/lib/librpcsvc;            ${MAKE} beforeinstall
672         cd ${.CURDIR}/lib/libskey;              ${MAKE} beforeinstall
673         cd ${.CURDIR}/lib/libstand;             ${MAKE} beforeinstall
674         cd ${.CURDIR}/lib/libtacplus;           ${MAKE} beforeinstall
675         cd ${.CURDIR}/lib/libcom_err;           ${MAKE} beforeinstall
676         cd ${.CURDIR}/lib/libss;                ${MAKE} -B hdrs beforeinstall
677         cd ${.CURDIR}/lib/libutil;              ${MAKE} beforeinstall
678         cd ${.CURDIR}/lib/libvgl;               ${MAKE} beforeinstall
679         cd ${.CURDIR}/lib/libwrap;              ${MAKE} beforeinstall
680         cd ${.CURDIR}/lib/libz;                 ${MAKE} beforeinstall
681         cd ${.CURDIR}/usr.bin/lex;              ${MAKE} beforeinstall
682
683 #
684 # libraries - build all libraries, and install them under ${DESTDIR}.
685 #
686 # The following dependencies exist between the libraries:
687 #
688 # lib*: csu
689 # libatm: libmd
690 # libcrypt: libmd
691 # libdialog: libncurses
692 # libedit: libncurses
693 # libg++: libm
694 # libkrb: libcrypt
695 # libopie: libmd
696 # libpam: libcom_err libcrypt libcrypto libgcc_pic libkrb libopie libradius \
697 #         libskey libtacplus libutil libz libssh
698 # libradius: libmd
699 # libreadline: libncurses
700 # libskey: libcrypt libmd
701 # libss: libcom_err
702 # libstc++: libm
703 # libtacplus: libmd
704 #
705 # Across directories this comes down to (rougly):
706 #
707 # gnu/lib: lib/libm lib/libncurses
708 # kerberosIV/lib kerberos5/lib: lib/libcrypt
709 # lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb gnu/lib/libgcc \
710 #             secure/lib/libssh lib/libz
711 # secure/lib: lib/libmd
712 #
713 .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
714 _csu=   lib/csu/${MACHINE_ARCH}.pcc
715 .elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
716 _csu=   lib/csu/i386-elf
717 .else
718 _csu=   lib/csu/${MACHINE_ARCH}
719 .endif
720
721 .if !defined(NOSECURE) && !defined(NOCRYPT)
722 _secure_lib=    secure/lib
723 .endif
724
725 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
726 _kerberosIV_lib=        kerberosIV/lib
727 .endif
728
729 .if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
730 _kerberos5_lib= kerberos5/lib
731 .endif
732
733 .if defined(WANT_CSRG_LIBM)
734 _libm=  lib/libm
735 .else
736 _libm=  lib/msun
737 .endif
738
739 .if ${MACHINE_ARCH} == "i386"
740 _libkeycap=     usr.sbin/pcvt/keycap
741 .endif
742
743 libraries:
744 .for _lib in ${_csu} lib/libmd lib/libcrypt ${_secure_lib} ${_kerberosIV_lib} \
745     ${_kerberos5_lib} gnu/lib/libgcc lib/libcom_err ${_libm} lib/libncurses \
746     lib/libopie lib/libradius lib/libskey lib/libtacplus lib/libutil \
747     lib/libz lib gnu/lib \
748     ${_libperl} usr.bin/lex/lib ${_libkeycap}
749 .if exists(${.CURDIR}/${_lib})
750         cd ${.CURDIR}/${_lib}; \
751                 ${MAKE} depend; \
752                 ${MAKE} all; \
753                 ${MAKE} install
754 .endif
755 .endfor
756
757 .for __target in clean cleandepend cleandir depend obj
758 .for entry in ${SUBDIR}
759 ${entry}.${__target}__D: .PHONY
760         @if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
761                 ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
762                 edir=${entry}.${MACHINE_ARCH}; \
763                 cd ${.CURDIR}/$${edir}; \
764         else \
765                 ${ECHODIR} "===> ${DIRPRFX}${entry}"; \
766                 edir=${entry}; \
767                 cd ${.CURDIR}/$${edir}; \
768         fi; \
769         ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
770 .endfor
771 par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
772 .endfor
773
774 .include <bsd.subdir.mk>