Makefile.inc1 132 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907
  1. #
  2. #
  3. # Make command line options:
  4. # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
  5. # -DNO_CLEAN do not clean at all
  6. # -DDB_FROM_SRC use the user/group databases in src/etc instead of
  7. # the system database when installing.
  8. # -DNO_SHARE do not go into share subdir
  9. # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,OBJ}
  10. # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel
  11. # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel
  12. # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel
  13. # -DNO_ROOT install without using root privilege
  14. # -DWITHOUT_CTF do not run the DTrace CTF conversion tools on built objects
  15. # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
  16. # LOCAL_ITOOLS="list of tools" to add additional tools to the ITOOLS list
  17. # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target
  18. # LOCAL_MTREE="list of mtree files" to process to allow local directories
  19. # to be created before files are installed
  20. # LOCAL_LEGACY_DIRS="list of dirs" to add additional dirs to the legacy
  21. # target
  22. # LOCAL_BSTOOL_DIRS="list of dirs" to add additional dirs to the
  23. # bootstrap-tools target
  24. # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools
  25. # target
  26. # LOCAL_XTOOL_DIRS="list of dirs" to add additional dirs to the
  27. # cross-tools target
  28. # METALOG="path to metadata log" to write permission and ownership
  29. # when NO_ROOT is set. (default: ${DESTDIR}/${DISTDIR}/METALOG,
  30. # check /etc/make.conf for DISTDIR)
  31. # TARGET="machine" to crossbuild world for a different machine type
  32. # TARGET_ARCH= may be required when a TARGET supports multiple endians
  33. # BUILDENV_SHELL= shell to launch for the buildenv target (def:${SHELL})
  34. # WORLD_FLAGS= additional flags to pass to make(1) during buildworld
  35. # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel
  36. # SUBDIR_OVERRIDE="list of dirs" to build rather than everything.
  37. # All libraries and includes, and some build tools will still build.
  38. #
  39. # The intended user-driven targets are:
  40. # buildworld - rebuild *everything*, including glue to help do upgrades
  41. # installworld- install everything built by "buildworld"
  42. # checkworld - run test suite on installed world
  43. # doxygen - build API documentation of the kernel
  44. #
  45. # Standard targets (not defined here) are documented in the makefiles in
  46. # /usr/share/mk. These include:
  47. # obj depend all install clean cleandepend cleanobj
  48. .if !defined(TARGET) || !defined(TARGET_ARCH)
  49. .error Both TARGET and TARGET_ARCH must be defined.
  50. .endif
  51. .if make(showconfig) || make(test-system-*)
  52. _MKSHOWCONFIG= t
  53. .endif
  54. SRCDIR?= ${.CURDIR}
  55. LOCALBASE?= /usr/local
  56. TIME_ENV ?= time env
  57. .include "share/mk/src.tools.mk"
  58. # Cross toolchain changes must be in effect before bsd.compiler.mk
  59. # so that gets the right CC, and pass CROSS_TOOLCHAIN to submakes.
  60. .if defined(CROSS_TOOLCHAIN)
  61. .if exists(${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk)
  62. .include "${LOCALBASE}/share/toolchains/${CROSS_TOOLCHAIN}.mk"
  63. .elif exists(${CROSS_TOOLCHAIN})
  64. .include "${CROSS_TOOLCHAIN}"
  65. .else
  66. .error CROSS_TOOLCHAIN ${CROSS_TOOLCHAIN} not found
  67. .endif
  68. CROSSENV+=CROSS_TOOLCHAIN="${CROSS_TOOLCHAIN}"
  69. .elif defined(UNIVERSE_TOOLCHAIN)
  70. UNIVERSE_TOOLCHAIN_PATH?=${HOST_OBJTOP}/tmp/usr/bin
  71. XCC?="${UNIVERSE_TOOLCHAIN_PATH}/cc"
  72. XCXX?="${UNIVERSE_TOOLCHAIN_PATH}/c++"
  73. XCPP?="${UNIVERSE_TOOLCHAIN_PATH}/cpp"
  74. XLD?="${UNIVERSE_TOOLCHAIN_PATH}/ld"
  75. .endif
  76. .if defined(CROSS_TOOLCHAIN_PREFIX)
  77. CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
  78. .endif
  79. XCOMPILERS= CC CXX CPP
  80. .for COMPILER in ${XCOMPILERS}
  81. .if defined(CROSS_COMPILER_PREFIX)
  82. X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
  83. .else
  84. X${COMPILER}?= ${${COMPILER}}
  85. .endif
  86. .endfor
  87. # If a full path to an external cross compiler is given, don't build
  88. # a cross compiler.
  89. .if ${XCC:N${CCACHE_BIN}:M/*}
  90. MK_CLANG_BOOTSTRAP= no
  91. # Make sure sub-makes see the option as disabled so the hack in bsd.sys.mk to
  92. # work around incompatible headers in Clang's resource directory is enabled.
  93. .MAKEOVERRIDES+= MK_CLANG_BOOTSTRAP
  94. .endif
  95. # Pull in compiler metadata from buildworld/toolchain if possible to avoid
  96. # running CC from bsd.compiler.mk.
  97. .if make(installworld) || make(install) || make(distributeworld) || \
  98. make(stageworld)
  99. .-include "${OBJTOP}/toolchain-metadata.mk"
  100. .if !defined(_LOADED_TOOLCHAIN_METADATA)
  101. .error A build is required first. You may have the wrong MAKEOBJDIRPREFIX set.
  102. .endif
  103. .endif
  104. # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. Pull it from the
  105. # tree to be friendlier to foreign OS builds. It's safe to do so unconditionally
  106. # here since we will always have the right make, unlike in src/Makefile
  107. # Don't include bsd.linker.mk yet until XBINUTILS is handled (after src.opts.mk)
  108. _NO_INCLUDE_LINKERMK= t
  109. # We also want the X_COMPILER* variables if we are using an external toolchain.
  110. _WANT_TOOLCHAIN_CROSS_VARS= t
  111. .include "share/mk/bsd.compiler.mk"
  112. .undef _NO_INCLUDE_LINKERMK
  113. .undef _WANT_TOOLCHAIN_CROSS_VARS
  114. # src.opts.mk depends on COMPILER_FEATURES
  115. .include "share/mk/src.opts.mk"
  116. .if ${TARGET} == ${MACHINE}
  117. TARGET_CPUTYPE?=${CPUTYPE}
  118. .else
  119. TARGET_CPUTYPE?=
  120. .endif
  121. .if !empty(TARGET_CPUTYPE)
  122. _TARGET_CPUTYPE=${TARGET_CPUTYPE}
  123. .else
  124. _TARGET_CPUTYPE=dummy
  125. .endif
  126. .if ${TARGET} == "arm"
  127. .if ${TARGET_CPUTYPE:M*soft*} == ""
  128. TARGET_TRIPLE_ABI= gnueabihf
  129. .else
  130. TARGET_TRIPLE_ABI= gnueabi
  131. .endif
  132. .endif
  133. MACHINE_TRIPLE_ABI?= unknown
  134. MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/}-${MACHINE_TRIPLE_ABI}-freebsd${OS_REVISION}
  135. TARGET_TRIPLE_ABI?= unknown
  136. TARGET_TRIPLE?= ${TARGET_ARCH:S/amd64/x86_64/}-${TARGET_TRIPLE_ABI}-freebsd${OS_REVISION}
  137. KNOWN_ARCHES?= aarch64/arm64 \
  138. amd64 \
  139. armv7/arm \
  140. i386 \
  141. powerpc \
  142. powerpc64/powerpc \
  143. powerpc64le/powerpc \
  144. powerpcspe/powerpc \
  145. riscv64/riscv
  146. .if ${TARGET} == ${TARGET_ARCH}
  147. _t= ${TARGET}
  148. .else
  149. _t= ${TARGET_ARCH}/${TARGET}
  150. .endif
  151. .for _t in ${_t}
  152. .if empty(KNOWN_ARCHES:M${_t})
  153. .error Unknown target ${TARGET_ARCH}:${TARGET}.
  154. .endif
  155. .endfor
  156. .if ${TARGET_ARCH} == "amd64"
  157. LIBCOMPAT_INCLUDE_DIRS+= i386
  158. .elif ${TARGET_ARCH} == "aarch64"
  159. LIBCOMPAT_INCLUDE_DIRS+= arm
  160. .endif
  161. .if !defined(_MKSHOWCONFIG)
  162. .if ((defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == "gcc") || \
  163. (!defined(X_COMPILER_TYPE) && ${COMPILER_TYPE} == "gcc"))
  164. .if ${TARGET} == "arm"
  165. _GCC_BROKEN="https://reviews.freebsd.org/D36754"
  166. .endif
  167. .if ${TARGET_ARCH} == "powerpc"
  168. _GCC_BROKEN=Missing atomic builtins in libc++.
  169. .endif
  170. .if ${TARGET_ARCH:Mpowerpc64*}
  171. _GCC_BROKEN=libsys.so.7.full has a LOAD segment with RWX permissions.
  172. .endif
  173. .if ${TARGET} == "riscv"
  174. _GCC_BROKEN=boot code linker script issues.
  175. .endif
  176. .if defined(_GCC_BROKEN)
  177. .warning Target ${TARGET} is broken with GCC: ${_GCC_BROKEN}
  178. .if defined(TRY_GCC_BROKEN)
  179. .warning Trying build anyway.
  180. .else
  181. .error Avoiding broken build. Define TRY_GCC_BROKEN to try anyway.
  182. .endif
  183. .endif
  184. .endif
  185. .endif
  186. .if ${.MAKE.OS} != "FreeBSD"
  187. CROSSBUILD_HOST=${.MAKE.OS}
  188. .if ${.MAKE.OS} != "Linux" && ${.MAKE.OS} != "Darwin"
  189. .warning Unsupported crossbuild system: ${.MAKE.OS}. Build will probably fail!
  190. .endif
  191. # We need to force NO_ROOT/DB_FROM_SRC builds when building on other operating
  192. # systems since the BSD.foo.dist specs contain users and groups that do not
  193. # exist by default on a Linux/MacOS system.
  194. NO_ROOT:= 1
  195. DB_FROM_SRC:= 1
  196. .export NO_ROOT
  197. .endif
  198. # If all targets are disabled for system llvm then don't expect it to work
  199. # for cross-builds.
  200. .if !defined(TOOLS_PREFIX) && ${MK_LLVM_TARGET_ALL} == "no" && \
  201. ${MACHINE} != ${TARGET} && ${MACHINE_ARCH} != ${TARGET_ARCH} && \
  202. !make(showconfig)
  203. MK_SYSTEM_COMPILER= no
  204. MK_SYSTEM_LINKER= no
  205. .endif
  206. # Handle external binutils.
  207. .if defined(CROSS_TOOLCHAIN_PREFIX)
  208. CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
  209. .endif
  210. XBINUTILS= AS AR ELFCTL LD NM OBJCOPY RANLIB SIZE STRINGS STRIPBIN
  211. .for BINUTIL in ${XBINUTILS}
  212. .if defined(CROSS_BINUTILS_PREFIX) && \
  213. exists(${CROSS_BINUTILS_PREFIX}/${${BINUTIL}})
  214. X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX:C,/*$,,}/${${BINUTIL}}
  215. .else
  216. X${BINUTIL}?= ${${BINUTIL}}
  217. .endif
  218. .endfor
  219. # If a full path to an external linker is given, don't build lld.
  220. .if ${XLD:M/*}
  221. MK_LLD_BOOTSTRAP= no
  222. .endif
  223. # We also want the X_LINKER* variables if we are using an external toolchain.
  224. _WANT_TOOLCHAIN_CROSS_VARS= t
  225. .include "share/mk/bsd.linker.mk"
  226. .undef _WANT_TOOLCHAIN_CROSS_VARS
  227. # Begin WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
  228. # WITH_SYSTEM_COMPILER - Pull in needed values and make a decision.
  229. # Check if there is a local compiler that can satisfy as an external compiler.
  230. # Which compiler is expected to be used?
  231. .if ${MK_CLANG_BOOTSTRAP} == "yes"
  232. WANT_COMPILER_TYPE= clang
  233. .else
  234. WANT_COMPILER_TYPE=
  235. .endif
  236. .if !defined(WANT_COMPILER_FREEBSD_VERSION) && !make(showconfig) && \
  237. !make(test-system-linker)
  238. .if ${WANT_COMPILER_TYPE} == "clang"
  239. WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
  240. WANT_COMPILER_FREEBSD_VERSION!= \
  241. awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
  242. ${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
  243. WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
  244. WANT_COMPILER_VERSION!= \
  245. awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
  246. ${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
  247. .endif
  248. .export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
  249. .endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
  250. # It needs to be the same revision as we would build for the bootstrap.
  251. # If the expected vs CC is different then we can't skip.
  252. # GCC cannot be used for cross-arch yet. For clang we pass -target later if
  253. # TARGET_ARCH!=MACHINE_ARCH.
  254. .if ${MK_SYSTEM_COMPILER} == "yes" && \
  255. defined(WANT_COMPILER_FREEBSD_VERSION) && \
  256. ${MK_CLANG_BOOTSTRAP} == "yes" && \
  257. !make(xdev*) && \
  258. ${X_COMPILER_TYPE} == ${WANT_COMPILER_TYPE} && \
  259. (${X_COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
  260. ${X_COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
  261. ${X_COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
  262. # Everything matches, disable the bootstrap compiler.
  263. MK_CLANG_BOOTSTRAP= no
  264. USING_SYSTEM_COMPILER= yes
  265. .endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
  266. # WITH_SYSTEM_LD - Pull in needed values and make a decision.
  267. # Check if there is a local linker that can satisfy as an external linker.
  268. # Which linker is expected to be used?
  269. .if ${MK_LLD_BOOTSTRAP} == "yes"
  270. WANT_LINKER_TYPE= lld
  271. .else
  272. WANT_LINKER_TYPE=
  273. .endif
  274. .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
  275. !make(test-system-compiler)
  276. .if ${WANT_LINKER_TYPE} == "lld"
  277. WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
  278. WANT_LINKER_FREEBSD_VERSION!= \
  279. awk '$$2 == "LLD_FREEBSD_VERSION" {print $$3}' \
  280. ${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
  281. WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
  282. WANT_LINKER_VERSION!= \
  283. awk '$$2 == "LLD_VERSION_STRING" {gsub("\"", "", $$3); split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
  284. ${SRCDIR}/${WANT_LINKER_VERSION_FILE} || echo unknown
  285. .else
  286. WANT_LINKER_FREEBSD_VERSION_FILE=
  287. WANT_LINKER_FREEBSD_VERSION=
  288. .endif
  289. .export WANT_LINKER_FREEBSD_VERSION WANT_LINKER_VERSION
  290. .endif # !defined(WANT_LINKER_FREEBSD_VERSION)
  291. .if ${MK_SYSTEM_LINKER} == "yes" && \
  292. defined(WANT_LINKER_FREEBSD_VERSION) && \
  293. (${MK_LLD_BOOTSTRAP} == "yes") && \
  294. !make(xdev*) && \
  295. ${X_LINKER_TYPE} == ${WANT_LINKER_TYPE} && \
  296. ${X_LINKER_VERSION} == ${WANT_LINKER_VERSION} && \
  297. ${X_LINKER_FREEBSD_VERSION} == ${WANT_LINKER_FREEBSD_VERSION}
  298. # Everything matches, disable the bootstrap linker.
  299. MK_LLD_BOOTSTRAP= no
  300. USING_SYSTEM_LINKER= yes
  301. .endif # ${WANT_LINKER_TYPE} == ${LINKER_TYPE}
  302. # WITH_SYSTEM_COMPILER / WITH_SYSTEM_LINKER - Handle defaults and debug.
  303. USING_SYSTEM_COMPILER?= no
  304. USING_SYSTEM_LINKER?= no
  305. TEST_SYSTEM_COMPILER_VARS= \
  306. USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
  307. MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP \
  308. WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
  309. WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
  310. CC COMPILER_TYPE COMPILER_FEATURES COMPILER_VERSION \
  311. COMPILER_FREEBSD_VERSION \
  312. XCC X_COMPILER_TYPE X_COMPILER_FEATURES X_COMPILER_VERSION \
  313. X_COMPILER_FREEBSD_VERSION
  314. TEST_SYSTEM_LINKER_VARS= \
  315. USING_SYSTEM_LINKER MK_SYSTEM_LINKER \
  316. MK_LLD_BOOTSTRAP \
  317. WANT_LINKER_TYPE WANT_LINKER_VERSION WANT_LINKER_VERSION_FILE \
  318. WANT_LINKER_FREEBSD_VERSION WANT_LINKER_FREEBSD_VERSION_FILE \
  319. LD LINKER_TYPE LINKER_FEATURES LINKER_VERSION \
  320. LINKER_FREEBSD_VERSION \
  321. XLD X_LINKER_TYPE X_LINKER_FEATURES X_LINKER_VERSION \
  322. X_LINKER_FREEBSD_VERSION
  323. .for _t in compiler linker
  324. test-system-${_t}: .PHONY
  325. .for v in ${TEST_SYSTEM_${_t:tu}_VARS}
  326. ${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
  327. .endfor
  328. .endfor
  329. .if (make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
  330. make(toolchain) || make(_cross-tools))
  331. .if ${USING_SYSTEM_COMPILER} == "yes"
  332. .info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
  333. .elif ${MK_CLANG_BOOTSTRAP} == "yes"
  334. .info SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
  335. .endif
  336. .if ${USING_SYSTEM_LINKER} == "yes"
  337. .info SYSTEM_LINKER: Determined that LD=${LD} matches the source tree. Not bootstrapping a cross-linker.
  338. .elif ${MK_LLD_BOOTSTRAP} == "yes"
  339. .info SYSTEM_LINKER: libclang will be built for bootstrapping a cross-linker.
  340. .endif
  341. .endif
  342. # End WITH_SYSTEM_COMPILER / WITH_SYSTEM_LD
  343. # Store some compiler metadata for use in installworld where we don't
  344. # want to invoke CC at all.
  345. _TOOLCHAIN_METADATA_VARS= COMPILER_VERSION \
  346. COMPILER_TYPE \
  347. COMPILER_FEATURES \
  348. COMPILER_FREEBSD_VERSION \
  349. COMPILER_RESOURCE_DIR \
  350. LINKER_VERSION \
  351. LINKER_FEATURES \
  352. LINKER_TYPE \
  353. LINKER_FREEBSD_VERSION
  354. toolchain-metadata.mk: .PHONY .META
  355. @: > ${.TARGET}
  356. @echo ".info Using cached toolchain metadata from build at $$(hostname) on $$(date)" \
  357. > ${.TARGET}
  358. @echo "_LOADED_TOOLCHAIN_METADATA=t" >> ${.TARGET}
  359. .for v in ${_TOOLCHAIN_METADATA_VARS}
  360. @echo "${v}=${${v}}" >> ${.TARGET}
  361. @echo "X_${v}=${X_${v}}" >> ${.TARGET}
  362. .endfor
  363. @echo ".export ${_TOOLCHAIN_METADATA_VARS}" >> ${.TARGET}
  364. @echo ".export ${_TOOLCHAIN_METADATA_VARS:C,^,X_,}" >> ${.TARGET}
  365. # We must do lib/ and libexec/ before bin/ in case of a mid-install error to
  366. # keep the users system reasonably usable. For static->dynamic root upgrades,
  367. # we don't want to install a dynamic binary without rtld and the needed
  368. # libraries. More commonly, for dynamic root, we don't want to install a
  369. # binary that requires a newer library version that hasn't been installed yet.
  370. # This ordering is not a guarantee though. The only guarantee of a working
  371. # system here would require fine-grained ordering of all components based
  372. # on their dependencies.
  373. .if !empty(SUBDIR_OVERRIDE)
  374. SUBDIR= ${SUBDIR_OVERRIDE}
  375. .else
  376. SUBDIR= lib libexec
  377. # Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR
  378. # of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and
  379. # LOCAL_LIB_DIRS=foo/lib to behave as expected.
  380. .for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|}
  381. _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*}
  382. .endfor
  383. .for _DIR in ${LOCAL_LIB_DIRS}
  384. .if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
  385. SUBDIR+= ${_DIR}
  386. .endif
  387. .endfor
  388. .if !defined(NO_ROOT) && (make(installworld) || make(install))
  389. # Ensure libraries are installed before progressing.
  390. SUBDIR+=.WAIT
  391. .endif
  392. SUBDIR+=bin
  393. .if ${MK_CDDL} != "no"
  394. SUBDIR+=cddl
  395. .endif
  396. SUBDIR+=gnu include
  397. .if ${MK_KERBEROS} != "no"
  398. SUBDIR+=kerberos5
  399. .endif
  400. .if ${MK_RESCUE} != "no"
  401. SUBDIR+=rescue
  402. .endif
  403. SUBDIR+=sbin
  404. .if ${MK_CRYPT} != "no"
  405. SUBDIR+=secure
  406. .endif
  407. .if !defined(NO_SHARE)
  408. SUBDIR+=share
  409. .endif
  410. .if ${MK_BOOT} != "no"
  411. SUBDIR+=stand
  412. .endif
  413. SUBDIR+=sys usr.bin usr.sbin
  414. .if ${MK_TESTS} != "no"
  415. SUBDIR+= tests
  416. .endif
  417. # Local directories are built in parallel with the base system directories.
  418. # Users may insert a .WAIT directive at the beginning or elsewhere within
  419. # the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed.
  420. .for _DIR in ${LOCAL_DIRS}
  421. .if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile)
  422. SUBDIR+= ${_DIR}
  423. .endif
  424. .endfor
  425. # We must do etc/ last as it hooks into building the man whatis file
  426. # by calling 'makedb' in share/man. This is only relevant for
  427. # install/distribute so they build the whatis file after every manpage is
  428. # installed.
  429. .if make(installworld) || make(install)
  430. SUBDIR+=.WAIT
  431. .endif
  432. SUBDIR+=etc
  433. .endif # !empty(SUBDIR_OVERRIDE)
  434. .if defined(NOCLEAN)
  435. .warning The src.conf WITHOUT_CLEAN option can now be used instead of NOCLEAN.
  436. MK_CLEAN:= no
  437. .endif
  438. .if defined(NO_CLEAN)
  439. .info The src.conf WITHOUT_CLEAN option can now be used instead of NO_CLEAN.
  440. MK_CLEAN:= no
  441. .endif
  442. .if defined(NO_CLEANDIR)
  443. CLEANDIR= clean cleandepend
  444. .else
  445. CLEANDIR= cleandir
  446. .endif
  447. .if defined(WORLDFAST)
  448. MK_CLEAN:= no
  449. NO_OBJWALK= t
  450. .endif
  451. .if ${MK_META_MODE} == "yes"
  452. # If filemon is used then we can rely on the build being incremental-safe.
  453. # The .meta files will also track the build command and rebuild should
  454. # it change.
  455. .if empty(.MAKE.MODE:Mnofilemon)
  456. MK_CLEAN:= no
  457. .endif
  458. .endif
  459. .if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
  460. NO_OBJWALK= t
  461. NO_KERNELOBJ= t
  462. .endif
  463. .if !defined(NO_OBJWALK)
  464. _obj= obj
  465. .endif
  466. LOCAL_TOOL_DIRS?=
  467. PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
  468. .if empty(SHELL:M*csh*)
  469. BUILDENV_SHELL?=${SHELL}
  470. .else
  471. BUILDENV_SHELL?=/bin/sh
  472. .endif
  473. .if !defined(_MKSHOWCONFIG)
  474. .if !defined(VCS_REVISION) || empty(VCS_REVISION)
  475. .if !defined(SVNVERSION_CMD) || empty(SVNVERSION_CMD)
  476. . for _D in ${PATH:S,:, ,g}
  477. . if exists(${_D}/svnversion)
  478. SVNVERSION_CMD?=${_D}/svnversion
  479. . endif
  480. . if exists(${_D}/svnliteversion)
  481. SVNVERSION_CMD?=${_D}/svnliteversion
  482. . endif
  483. . endfor
  484. .endif
  485. .if defined(SVNVERSION_CMD) && !empty(SVNVERSION_CMD)
  486. _VCS_REVISION?= $$(eval ${SVNVERSION_CMD} ${SRCDIR})
  487. . if !empty(_VCS_REVISION)
  488. VCS_REVISION= $$(echo r${_VCS_REVISION})
  489. .export VCS_REVISION
  490. . endif
  491. .endif
  492. .endif
  493. .if !defined(GIT_CMD) || empty(GIT_CMD)
  494. . for _P in /usr/bin /usr/local/bin
  495. . if exists(${_P}/git)
  496. GIT_CMD= ${_P}/git
  497. . endif
  498. . endfor
  499. .export GIT_CMD
  500. .endif
  501. .if !defined(OSRELDATE)
  502. .if exists(/usr/include/osreldate.h)
  503. OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
  504. /usr/include/osreldate.h
  505. .else
  506. OSRELDATE= 0
  507. .endif
  508. .export OSRELDATE
  509. .endif
  510. # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION.
  511. .for _V in BRANCH REVISION TYPE
  512. .if !defined(_${_V})
  513. _${_V}!= eval $$(awk '/^${_V}=/{print}' ${SRCTOP}/sys/conf/newvers.sh); echo $$${_V}
  514. .export _${_V}
  515. .endif
  516. .endfor
  517. .if !defined(SRCRELDATE)
  518. SRCRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
  519. ${SRCDIR}/sys/sys/param.h
  520. .export SRCRELDATE
  521. .endif
  522. .if !defined(VERSION)
  523. VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDATE}
  524. .export VERSION
  525. .endif
  526. MAJOR_REVISION= ${_REVISION:R}
  527. _PKG_REVISION= ${_REVISION}
  528. _STRTIMENOW= %Y%m%d%H%M%S
  529. _TIMENOW= ${_STRTIMENOW:gmtime}
  530. BRANCH_EXT=
  531. .if ${_BRANCH:MCURRENT*} || ${_BRANCH:MSTABLE*} || ${_BRANCH:MPRERELEASE*}
  532. _PKG_REVISION:= ${MAJOR_REVISION}
  533. BRANCH_EXT= ${MAJOR_REVISION}.snap
  534. EXTRA_REVISION= .snap${_TIMENOW}
  535. .elif ${_BRANCH:MALPHA*}
  536. BRANCH_EXT= alpha
  537. EXTRA_REVISION= .${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}
  538. .elif ${_BRANCH:MBETA*}
  539. BRANCH_EXT= beta
  540. EXTRA_REVISION= .${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW}
  541. .elif ${_BRANCH:MRC*}
  542. BRANCH_EXT= rc
  543. EXTRA_REVISION= .rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW}
  544. .elif ${_BRANCH:M*-p*}
  545. EXTRA_REVISION= p${_BRANCH:C/.*-p([0-9]+$)/\1/}
  546. .endif
  547. .if !defined(PKG_VERSION)
  548. PKG_VERSION:= ${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
  549. .endif
  550. .endif # !defined(PKG_VERSION)
  551. .if !defined(PKG_TIMESTAMP)
  552. TIMEEPOCHNOW= %s
  553. SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime}
  554. .else
  555. SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP}
  556. .endif
  557. PKG_NAME_PREFIX?= FreeBSD
  558. PKG_MAINTAINER?= re@FreeBSD.org
  559. PKG_WWW?= https://www.FreeBSD.org
  560. .export PKG_NAME_PREFIX
  561. .export PKG_MAINTAINER
  562. .export PKG_WWW
  563. .if !defined(_MKSHOWCONFIG)
  564. _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \
  565. -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE
  566. .if ${_CPUTYPE} != ${_TARGET_CPUTYPE}
  567. .error CPUTYPE global should be set with ?=.
  568. .endif
  569. .endif
  570. .if make(buildworld)
  571. BUILD_ARCH!= uname -p
  572. # On some Linux systems uname -p returns "unknown" so skip this check there.
  573. # This check only exists to tell people to use TARGET_ARCH instead of
  574. # MACHINE_ARCH so skipping it when crossbuilding on non-FreeBSD should be fine.
  575. .if ${MACHINE_ARCH} != ${BUILD_ARCH} && ${.MAKE.OS} == "FreeBSD"
  576. .error To cross-build, set TARGET_ARCH.
  577. .endif
  578. .endif
  579. WORLDTMP?= ${OBJTOP}/tmp
  580. BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin:${WORLDTMP}/legacy/usr/libexec
  581. XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
  582. # When building we want to find the cross tools before the host tools in ${BPATH}.
  583. # We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
  584. # toolchain files (clang, lld, etc.) during make universe/tinderbox
  585. STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
  586. # We should not be using tools from /usr/bin accidentally since this could cause
  587. # the build to break on other systems that don't have that tool. For now we
  588. # still allow using the old behaviour (inheriting $PATH) if
  589. # BUILD_WITH_STRICT_TMPPATH is set to 0 but this will eventually be removed.
  590. # Currently strict $PATH can cause build failures. Once the remaining issues
  591. # have been resolved it will be turned on by default.
  592. BUILD_WITH_STRICT_TMPPATH?=0
  593. .if defined(CROSSBUILD_HOST)
  594. # When building on non-FreeBSD we can't rely on the tools in /usr/bin being compatible
  595. # with what FreeBSD expects. Therefore we only use tools from STRICTTMPPATH
  596. # during the world build stage. We build most tools during the bootstrap-tools
  597. # phase but symlink host tools that are known to work instead of building them
  598. BUILD_WITH_STRICT_TMPPATH:=1
  599. .endif
  600. .if ${BUILD_WITH_STRICT_TMPPATH} != 0
  601. TMPPATH= ${STRICTTMPPATH}
  602. .else
  603. TMPPATH= ${STRICTTMPPATH}:${PATH}
  604. .endif
  605. #
  606. # Avoid running mktemp(1) unless actually needed.
  607. # It may not be functional, e.g., due to new ABI
  608. # when in the middle of installing over this system.
  609. #
  610. .if make(distributeworld) || make(installworld) || make(stageworld)
  611. .if ${BUILD_WITH_STRICT_TMPPATH} != 0
  612. MKTEMP=${WORLDTMP}/legacy/usr/bin/mktemp
  613. .if !exists(${MKTEMP})
  614. .error mktemp binary doesn't exist in expected location: ${MKTEMP}
  615. .endif
  616. .else
  617. MKTEMP=mktemp
  618. .endif
  619. INSTALLTMP!= ${MKTEMP} -d -u -t install
  620. .if ${.MAKE.OS} == "FreeBSD"
  621. # When building on FreeBSD we always copy the host tools instead of linking
  622. # into INSTALLTMP to avoid issues with incompatible libraries (see r364030).
  623. # Note: we could create links if we don't intend to update the current machine.
  624. INSTALLTMP_COPY_HOST_TOOL=cp
  625. .else
  626. # However, this is not necessary on Linux/macOS. Additionally, copying the host
  627. # tools to another directory with cp results in AMFI Launch Constraint
  628. # Violations on macOS Ventura as part of its System Integrity Protection.
  629. INSTALLTMP_COPY_HOST_TOOL=ln -s
  630. .endif
  631. .endif
  632. .if make(stagekernel) || make(distributekernel)
  633. TAGS+= kernel
  634. PACKAGE= kernel
  635. .endif
  636. #
  637. # Building a world goes through the following stages
  638. #
  639. # 1. legacy stage [BMAKE]
  640. # This stage is responsible for creating compatibility
  641. # shims that are needed by the bootstrap-tools,
  642. # build-tools and cross-tools stages. These are generally
  643. # APIs that tools from one of those three stages need to
  644. # build that aren't present on the host.
  645. # 1. bootstrap-tools stage [BMAKE]
  646. # This stage is responsible for creating programs that
  647. # are needed for backward compatibility reasons. They
  648. # are not built as cross-tools.
  649. # 2. build-tools stage [TMAKE]
  650. # This stage is responsible for creating the object
  651. # tree and building any tools that are needed during
  652. # the build process. Some programs are listed during
  653. # this phase because they build binaries to generate
  654. # files needed to build these programs. This stage also
  655. # builds the 'build-tools' target rather than 'all'.
  656. # 3. cross-tools stage [XMAKE]
  657. # This stage is responsible for creating any tools that
  658. # are needed for building the system. A cross-compiler is one
  659. # of them. This differs from build tools in two ways:
  660. # 1. the 'all' target is built rather than 'build-tools'
  661. # 2. these tools are installed into TMPPATH for stage 4.
  662. # 4. world stage [WMAKE]
  663. # This stage actually builds the world.
  664. # 5. install stage (optional) [IMAKE]
  665. # This stage installs a previously built world.
  666. #
  667. BOOTSTRAPPING?= 0
  668. # Keep these in sync
  669. MINIMUM_SUPPORTED_OSREL?= 1104001
  670. MINIMUM_SUPPORTED_REL?= 11.4
  671. # Common environment for world related stages
  672. CROSSENV+= \
  673. MACHINE_ARCH=${TARGET_ARCH} \
  674. MACHINE=${TARGET} \
  675. CPUTYPE=${TARGET_CPUTYPE}
  676. .if ${MK_META_MODE} != "no"
  677. # Don't rebuild build-tools targets during normal build.
  678. CROSSENV+= BUILD_TOOLS_META=.NOMETA
  679. .endif
  680. .if defined(TARGET_CFLAGS)
  681. CROSSENV+= ${TARGET_CFLAGS}
  682. .endif
  683. .if (${TARGET} != ${MACHINE} && !defined(WITH_LOCAL_MODULES)) || \
  684. defined(WITHOUT_LOCAL_MODULES)
  685. CROSSENV+= LOCAL_MODULES=
  686. .endif
  687. BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
  688. # bootstrap-tools stage
  689. BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
  690. TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
  691. PATH=${BPATH:Q}:${PATH:Q} \
  692. WORLDTMP=${WORLDTMP} \
  693. MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
  694. # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
  695. BSARGS= DESTDIR= \
  696. OBJTOP='${WORLDTMP}/obj-tools' \
  697. OBJROOT='$${OBJTOP}/' \
  698. UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
  699. MAKEOBJDIRPREFIX= \
  700. BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
  701. BWPHASE=${.TARGET:C,^_,,} \
  702. -DNO_CPU_CFLAGS \
  703. -DNO_LINT \
  704. -DNO_PIC \
  705. -DNO_SHARED \
  706. MK_ASAN=no \
  707. MK_CTF=no \
  708. MK_CLANG_EXTRAS=no \
  709. MK_CLANG_FORMAT=no \
  710. MK_CLANG_FULL=no \
  711. MK_HTML=no \
  712. MK_MAN=no \
  713. MK_PROFILE=no \
  714. MK_RETPOLINE=no \
  715. MK_SSP=no \
  716. MK_TESTS=no \
  717. MK_UBSAN=no \
  718. MK_WERROR=no \
  719. MK_INCLUDES=yes \
  720. MK_MAN_UTILS=yes
  721. BMAKE= \
  722. ${TIME_ENV} ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  723. ${BSARGS}
  724. .if empty(.MAKEOVERRIDES:MMK_LLVM_TARGET_ALL)
  725. BMAKE+= MK_LLVM_TARGET_ALL=no
  726. .endif
  727. # build-tools stage
  728. TMAKE= \
  729. ${TIME_ENV} ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  730. TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
  731. DESTDIR= \
  732. BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
  733. BWPHASE=${.TARGET:C,^_,,} \
  734. -DNO_CPU_CFLAGS \
  735. -DNO_LINT \
  736. MK_ASAN=no \
  737. MK_CTF=no \
  738. MK_CLANG_EXTRAS=no \
  739. MK_CLANG_FORMAT=no \
  740. MK_CLANG_FULL=no \
  741. MK_LLDB=no \
  742. MK_RETPOLINE=no \
  743. MK_SSP=no \
  744. MK_TESTS=no \
  745. MK_UBSAN=no \
  746. MK_WERROR=no
  747. # cross-tools stage
  748. # TOOLS_PREFIX set in BMAKE
  749. XMAKE= ${BMAKE} \
  750. TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
  751. MK_LLDB=no \
  752. MK_LLVM_BINUTILS=no \
  753. MK_TESTS=no
  754. # kernel-tools stage
  755. KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
  756. PATH=${BPATH:Q}:${PATH:Q} \
  757. WORLDTMP=${WORLDTMP} \
  758. MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
  759. KTMAKE= ${TIME_ENV} \
  760. TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
  761. ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  762. DESTDIR= \
  763. OBJTOP='${WORLDTMP}/obj-kernel-tools' \
  764. OBJROOT='$${OBJTOP}/' \
  765. UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
  766. MAKEOBJDIRPREFIX= \
  767. BOOTSTRAPPING=${BOOTSTRAPPING_OSRELDATE} \
  768. -DNO_CPU_CFLAGS \
  769. -DNO_LINT \
  770. -DNO_PIC \
  771. -DNO_SHARED \
  772. MK_CTF=no \
  773. MK_HTML=no \
  774. MK_MAN=no \
  775. MK_PROFILE=no \
  776. MK_SSP=no \
  777. MK_RETPOLINE=no \
  778. MK_WERROR=no
  779. # world stage
  780. WMAKEENV= ${CROSSENV} \
  781. INSTALL="${INSTALL_CMD} -U" \
  782. PATH=${TMPPATH:Q} \
  783. SYSROOT=${WORLDTMP}
  784. # make hierarchy
  785. HMAKE= PATH=${TMPPATH:Q} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
  786. .if defined(NO_ROOT)
  787. HMAKE+= PATH=${TMPPATH:Q} METALOG=${METALOG} -DNO_ROOT
  788. .endif
  789. CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
  790. CPP="${XCPP} ${XCFLAGS}" \
  791. AS="${XAS}" AR="${XAR}" ELFCTL="${XELFCTL}" LD="${XLD}" \
  792. LLVM_LINK="${XLLVM_LINK}" NM=${XNM} OBJCOPY="${XOBJCOPY}" \
  793. RANLIB=${XRANLIB} STRINGS=${XSTRINGS} \
  794. SIZE="${XSIZE}" STRIPBIN="${XSTRIPBIN}"
  795. .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
  796. # In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
  797. # directory, but the compiler will look in the right place for its
  798. # tools so we don't need to tell it where to look.
  799. BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
  800. .endif
  801. # The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
  802. # and target set by TARGET/TARGET_ARCH. However, there are several needs to
  803. # always pass an explicit --sysroot and -target.
  804. # - External compiler needs sysroot and target flags.
  805. # - External ld needs sysroot.
  806. # - To be clear about the use of a sysroot when using the internal compiler.
  807. # - Easier debugging.
  808. # - Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
  809. # the flip-flopping build command when sometimes using external and
  810. # sometimes using internal.
  811. # - Allow using lld which has no support for default paths.
  812. .if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
  813. BFLAGS+= -B${WORLDTMP}/usr/bin
  814. .endif
  815. .if ${WANT_COMPILER_TYPE} == gcc || \
  816. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
  817. .elif ${WANT_COMPILER_TYPE} == clang || \
  818. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang)
  819. XCFLAGS+= -target ${TARGET_TRIPLE}
  820. .endif
  821. XCFLAGS+= --sysroot=${WORLDTMP}
  822. .if !empty(BFLAGS)
  823. XCFLAGS+= ${BFLAGS}
  824. .endif
  825. .include "share/mk/bsd.compat.pre.mk"
  826. .for LIBCOMPAT in ${_ALL_LIBCOMPATS}
  827. .if ${MK_LIB${LIBCOMPAT}} == "yes"
  828. _LIBCOMPATS+= ${LIBCOMPAT}
  829. .endif
  830. .endfor
  831. .include "Makefile.libcompat"
  832. # META_MODE normally ignores host file changes since every build updates
  833. # timestamps (see NO_META_IGNORE_HOST in sys.mk). There are known times
  834. # when the ABI breaks though that we want to force rebuilding WORLDTMP
  835. # to get updated host tools.
  836. .if ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" && \
  837. !defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
  838. !defined(_MKSHOWCONFIG)
  839. # r318736 - ino64 major ABI breakage
  840. META_MODE_BAD_ABI_VERS+= 1200031
  841. .if !defined(OBJDIR_HOST_OSRELDATE)
  842. .if exists(${OBJTOP}/host-osreldate.h)
  843. OBJDIR_HOST_OSRELDATE!= \
  844. awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
  845. ${OBJTOP}/host-osreldate.h
  846. .elif exists(${WORLDTMP}/usr/include/osreldate.h)
  847. OBJDIR_HOST_OSRELDATE= 0
  848. .endif
  849. .export OBJDIR_HOST_OSRELDATE
  850. .endif
  851. # Note that this logic is the opposite of normal BOOTSTRAP handling. We want
  852. # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP
  853. # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild.
  854. .if defined(OBJDIR_HOST_OSRELDATE)
  855. .for _ver in ${META_MODE_BAD_ABI_VERS}
  856. .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver}
  857. _meta_mode_need_rebuild= ${_ver}
  858. .endif
  859. .endfor
  860. .if defined(_meta_mode_need_rebuild)
  861. .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}.
  862. NO_META_IGNORE_HOST_HEADERS= 1
  863. .export NO_META_IGNORE_HOST_HEADERS
  864. .endif # defined(_meta_mode_need_rebuild)
  865. .endif # defined(OBJDIR_HOST_OSRELDATE)
  866. .endif # ${MK_META_MODE} == "yes" && ${MK_CLEAN} == "no" ...
  867. # This is only used for META_MODE+filemon to track what the oldest
  868. # __FreeBSD_version is in WORLDTMP. This purposely does NOT have
  869. # a make dependency on /usr/include/osreldate.h as the file should
  870. # only be copied when it is missing or meta mode determines it has changed.
  871. # Since host files are normally ignored without NO_META_IGNORE_HOST
  872. # the file will never be updated unless that flag is specified. This
  873. # allows tracking the oldest osreldate to force rebuilds via
  874. # META_MODE_BADABI_REVS above.
  875. host-osreldate.h: # DO NOT ADD /usr/include/osreldate.h here
  876. .if !defined(CROSSBUILD_HOST)
  877. @cp -f /usr/include/osreldate.h ${.TARGET}
  878. .else
  879. @echo "#ifndef __FreeBSD_version" > ${.TARGET}
  880. @echo "#define __FreeBSD_version ${OSRELDATE}" >> ${.TARGET}
  881. @echo "#endif" >> ${.TARGET}
  882. .endif
  883. WMAKE= ${TIME_ENV} ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
  884. BWPHASE=${.TARGET:C,^_,,} \
  885. DESTDIR=${WORLDTMP}
  886. IMAKEENV= ${CROSSENV}
  887. IMAKE= ${TIME_ENV} ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
  888. ${IMAKE_INSTALL} ${IMAKE_MTREE}
  889. .if empty(.MAKEFLAGS:M-n)
  890. IMAKEENV+= PATH=${STRICTTMPPATH:Q}:${INSTALLTMP:Q} \
  891. LD_LIBRARY_PATH=${INSTALLTMP:Q} \
  892. PATH_LOCALE=${INSTALLTMP}/locale
  893. IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
  894. .else
  895. IMAKEENV+= PATH=${TMPPATH:Q}:${INSTALLTMP:Q}
  896. .endif
  897. # When generating install media, do not allow user and group information from
  898. # the build host to affect the contents of the distribution.
  899. .if make(distributeworld) || make(distrib-dirs) || make(distribution) || \
  900. make(stageworld)
  901. DB_FROM_SRC= yes
  902. .endif
  903. .if defined(DB_FROM_SRC)
  904. INSTALLFLAGS+= -N ${.CURDIR}/etc
  905. MTREEFLAGS+= -N ${.CURDIR}/etc
  906. .endif
  907. _INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
  908. INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
  909. .if defined(NO_ROOT)
  910. METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
  911. METALOG:= ${METALOG:C,//+,/,g}
  912. IMAKE+= -DNO_ROOT METALOG=${METALOG}
  913. METALOG_INSTALLFLAGS= -U -M ${METALOG} -D ${INSTALL_DDIR}
  914. INSTALLFLAGS+= ${METALOG_INSTALLFLAGS}
  915. CERTCTLFLAGS= ${METALOG_INSTALLFLAGS}
  916. MTREEFLAGS+= -W
  917. .endif
  918. .if defined(BUILD_PKGS)
  919. INSTALLFLAGS+= -h sha256
  920. .endif
  921. .if defined(DB_FROM_SRC) || defined(NO_ROOT)
  922. IMAKE_INSTALL= INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}"
  923. IMAKE_MTREE= MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}"
  924. .endif
  925. .if make(distributeworld)
  926. CERTCTLDESTDIR= ${DESTDIR}/${DISTDIR}
  927. CERTCTLFLAGS+= -d /base
  928. .else
  929. CERTCTLDESTDIR= ${DESTDIR}
  930. .endif
  931. CERTCTLFLAGS+= -D "${CERTCTLDESTDIR}"
  932. DESTDIR_MTREEFLAGS= -deU
  933. # When creating worldtmp we don't need to set the directories as owned by root
  934. # so we also pass -W
  935. WORLDTMP_MTREEFLAGS= -deUW
  936. .if defined(NO_ROOT)
  937. # When building with -DNO_ROOT we shouldn't be changing the directories
  938. # that are created by mtree to be owned by root/wheel.
  939. DESTDIR_MTREEFLAGS+= -W
  940. .endif
  941. .if defined(DB_FROM_SRC)
  942. DISTR_MTREEFLAGS= -N ${.CURDIR}/etc
  943. .endif
  944. DISTR_MTREECMD= ${MTREE_CMD}
  945. .if ${BUILD_WITH_STRICT_TMPPATH} != 0
  946. DISTR_MTREECMD= ${WORLDTMP}/legacy/usr/sbin/mtree
  947. .endif
  948. DISTR_MTREE= ${DISTR_MTREECMD} ${DISTR_MTREEFLAGS}
  949. WORLDTMP_MTREE= ${DISTR_MTREECMD} ${WORLDTMP_MTREEFLAGS}
  950. DESTDIR_MTREE= ${DISTR_MTREECMD} ${DESTDIR_MTREEFLAGS}
  951. METALOG_SORT_CMD= env -i LC_COLLATE=C sort
  952. # kernel stage
  953. KMAKEENV= ${WMAKEENV:NSYSROOT=*}
  954. KMAKE= ${TIME_ENV} ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
  955. #
  956. # buildworld
  957. #
  958. # Attempt to rebuild the entire system, with reasonable chance of
  959. # success, regardless of how old your existing system is.
  960. #
  961. _sanity_check: .PHONY .MAKE
  962. .if ${.CURDIR:C/[^,]//g} != ""
  963. # The m4 build of sendmail files doesn't like it if ',' is used
  964. # anywhere in the path of it's files.
  965. @echo
  966. @echo "*** Error: path to source tree contains a comma ','"
  967. @echo
  968. @false
  969. .elif ${.CURDIR:M*\:*} != ""
  970. # Using ':' leaks into PATH and breaks finding cross-tools.
  971. @echo
  972. @echo "*** Error: path to source tree contains a colon ':'"
  973. @echo
  974. @false
  975. .endif
  976. # Our current approach to dependency tracking cannot cope with certain source
  977. # tree changes, particularly with respect to removing source files and
  978. # replacing generated files. Handle these cases here in an ad-hoc fashion.
  979. _cleanobj_fast_depend_hack: .PHONY
  980. @echo ">>> Deleting stale dependencies...";
  981. MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
  982. ALL_libcompats=${_ALL_libcompats:Q} \
  983. sh ${.CURDIR}/tools/build/depend-cleanup.sh ${OBJTOP}
  984. _cleanworldtmp: .PHONY
  985. .if ${MK_CLEAN} == "yes"
  986. @echo
  987. @echo "--------------------------------------------------------------"
  988. @echo ">>> Cleaning up the temporary build tree"
  989. @echo "--------------------------------------------------------------"
  990. rm -rf ${WORLDTMP}
  991. .else
  992. # Note: for delete-old we need to set $PATH to also include the host $PATH
  993. # since otherwise a partial build with missing symlinks in ${WORLDTMP}/legacy/
  994. # will fail to run due to missing binaries. $WMAKE sets PATH to only ${TMPPATH}
  995. # so we remove that assignment from $WMAKE and prepend the new $PATH
  996. ${_+_}@if [ -e "${WORLDTMP}" ]; then \
  997. echo ">>> Deleting stale files in build tree..."; \
  998. cd ${.CURDIR}; env PATH=${TMPPATH:Q}:${PATH:Q} ${WMAKE:NPATH=*} \
  999. _NO_INCLUDE_COMPILERMK=t -DBATCH_DELETE_OLD_FILES delete-old \
  1000. delete-old-libs >/dev/null; \
  1001. fi
  1002. rm -rf ${WORLDTMP}/legacy/usr/include
  1003. .if ${USING_SYSTEM_COMPILER} == "yes"
  1004. .for cc in cc c++
  1005. if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
  1006. inum=$$(ls -i ${WORLDTMP}/usr/bin/${cc}); \
  1007. find ${WORLDTMP}/usr/bin -inum $${inum%% *} -delete; \
  1008. fi
  1009. .endfor
  1010. .endif # ${USING_SYSTEM_COMPILER} == "yes"
  1011. .if ${USING_SYSTEM_LINKER} == "yes"
  1012. @rm -f ${WORLDTMP}/usr/bin/ld ${WORLDTMP}/usr/bin/ld.lld
  1013. .endif # ${USING_SYSTEM_LINKER} == "yes"
  1014. .endif # ${MK_CLEAN} == "yes"
  1015. _worldtmp: .PHONY
  1016. @echo
  1017. @echo "--------------------------------------------------------------"
  1018. @echo ">>> Rebuilding the temporary build tree"
  1019. @echo "--------------------------------------------------------------"
  1020. @mkdir -p ${WORLDTMP}
  1021. @touch ${WORLDTMP}/${.TARGET}
  1022. # We can't use mtree to create the worldtmp directories since it may not be
  1023. # available on the target system (this happens e.g. when building on non-FreeBSD)
  1024. ${_+_}cd ${.CURDIR}/tools/build; \
  1025. ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy installdirs
  1026. # In order to build without inheriting $PATH we need to add symlinks to the host
  1027. # tools in $WORLDTMP for the tools that we don't build during bootstrap-tools
  1028. ${_+_}cd ${.CURDIR}/tools/build; \
  1029. ${MAKE} DIRPRFX=tools/build/ DESTDIR=${WORLDTMP}/legacy host-symlinks
  1030. _legacy:
  1031. @echo
  1032. @echo "--------------------------------------------------------------"
  1033. @echo ">>> stage 1.1: legacy release compatibility shims"
  1034. @echo "--------------------------------------------------------------"
  1035. ${_+_}cd ${.CURDIR}; ${BMAKE} legacy
  1036. _bootstrap-tools:
  1037. @echo
  1038. @echo "--------------------------------------------------------------"
  1039. @echo ">>> stage 1.2: bootstrap tools"
  1040. @echo "--------------------------------------------------------------"
  1041. .if ${MK_CLEAN} != "yes"
  1042. ${_+_}cd ${.CURDIR}; ${BMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
  1043. .endif
  1044. ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools
  1045. mkdir -p ${WORLDTMP}/usr ${WORLDTMP}/lib/geom ${WORLDTMP}/bin
  1046. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  1047. -p ${WORLDTMP}/usr >/dev/null
  1048. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  1049. -p ${WORLDTMP}/usr/include >/dev/null
  1050. .for d in ${LIBCOMPAT_INCLUDE_DIRS}
  1051. mkdir -p ${WORLDTMP}/usr/include/${d}
  1052. .endfor
  1053. ln -sf ${.CURDIR}/sys ${WORLDTMP}
  1054. .if ${MK_DEBUG_FILES} != "no"
  1055. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
  1056. -p ${WORLDTMP}/usr/lib >/dev/null
  1057. .endif
  1058. .for _mtree in ${LOCAL_MTREE}
  1059. ${WORLDTMP_MTREE} -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null
  1060. .endfor
  1061. _cleanobj:
  1062. .if ${MK_CLEAN} == "yes"
  1063. @echo
  1064. @echo "--------------------------------------------------------------"
  1065. @echo ">>> stage 2.1: cleaning up the object tree"
  1066. @echo "--------------------------------------------------------------"
  1067. # Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
  1068. # since the restricted $PATH might not contain a valid cc binary
  1069. ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
  1070. .for LIBCOMPAT in ${_LIBCOMPATS}
  1071. ${_+_}cd ${.CURDIR}; ${LIB${LIBCOMPAT}WMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
  1072. .endfor
  1073. .else
  1074. ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
  1075. .endif # ${MK_CLEAN} == "yes"
  1076. _obj:
  1077. @echo
  1078. @echo "--------------------------------------------------------------"
  1079. @echo ">>> stage 2.2: rebuilding the object tree"
  1080. @echo "--------------------------------------------------------------"
  1081. ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
  1082. _build-tools:
  1083. @echo
  1084. @echo "--------------------------------------------------------------"
  1085. @echo ">>> stage 2.3: build tools"
  1086. @echo "--------------------------------------------------------------"
  1087. ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools
  1088. _cross-tools:
  1089. @echo
  1090. @echo "--------------------------------------------------------------"
  1091. @echo ">>> stage 3: cross tools"
  1092. @echo "--------------------------------------------------------------"
  1093. @rm -f ${OBJTOP}/toolchain-metadata.mk
  1094. ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools
  1095. ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools
  1096. _build-metadata:
  1097. @echo
  1098. @echo "--------------------------------------------------------------"
  1099. @echo ">>> stage 3.1: recording build metadata"
  1100. @echo "--------------------------------------------------------------"
  1101. ${_+_}cd ${.CURDIR}; ${WMAKE} toolchain-metadata.mk
  1102. ${_+_}cd ${.CURDIR}; ${WMAKE} host-osreldate.h
  1103. _includes:
  1104. @echo
  1105. @echo "--------------------------------------------------------------"
  1106. @echo ">>> stage 4.1: building includes"
  1107. @echo "--------------------------------------------------------------"
  1108. # Special handling for SUBDIR_OVERRIDE in buildworld as they most likely need
  1109. # headers from default SUBDIR. Do SUBDIR_OVERRIDE includes last.
  1110. ${_+_}cd ${.CURDIR}; ${WMAKE} SUBDIR_OVERRIDE= SHARED=symlinks \
  1111. MK_INCLUDES=yes includes
  1112. .if !empty(SUBDIR_OVERRIDE) && make(buildworld)
  1113. ${_+_}cd ${.CURDIR}; ${WMAKE} MK_INCLUDES=yes SHARED=symlinks includes
  1114. .endif
  1115. ${_+_}cd ${.CURDIR}; ${WMAKE} test-includes
  1116. _libraries:
  1117. @echo
  1118. @echo "--------------------------------------------------------------"
  1119. @echo ">>> stage 4.2: building libraries"
  1120. @echo "--------------------------------------------------------------"
  1121. ${_+_}cd ${.CURDIR}; \
  1122. ${WMAKE} -DNO_FSCHG MK_HTML=no -DNO_LINT MK_MAN=no \
  1123. MK_PROFILE=no MK_TESTS=no MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} \
  1124. libraries
  1125. everything: .PHONY
  1126. @echo
  1127. @echo "--------------------------------------------------------------"
  1128. @echo ">>> stage 4.4: building everything"
  1129. @echo "--------------------------------------------------------------"
  1130. ${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
  1131. WMAKE_TGTS=
  1132. .if !defined(WORLDFAST)
  1133. WMAKE_TGTS+= _sanity_check _cleanworldtmp _worldtmp _legacy
  1134. .if empty(SUBDIR_OVERRIDE)
  1135. WMAKE_TGTS+= _bootstrap-tools
  1136. .endif
  1137. WMAKE_TGTS+= _cleanobj
  1138. .if !defined(NO_OBJWALK)
  1139. WMAKE_TGTS+= _obj
  1140. .endif
  1141. WMAKE_TGTS+= _build-tools _cross-tools
  1142. WMAKE_TGTS+= _build-metadata
  1143. WMAKE_TGTS+= _includes
  1144. .endif
  1145. .if !defined(NO_LIBS)
  1146. WMAKE_TGTS+= _libraries
  1147. .endif
  1148. .if empty(SUBDIR_OVERRIDE)
  1149. .for libcompat in ${libcompats}
  1150. WMAKE_TGTS+= build${libcompat}
  1151. .endfor
  1152. .endif
  1153. WMAKE_TGTS+= everything
  1154. # record buildworld / install time in seconds
  1155. .if make(buildworld)
  1156. _BUILDWORLD_START!= date '+%s'
  1157. .export _BUILDWORLD_START
  1158. .endif
  1159. .if make(reinstall) || make(restage)
  1160. _INSTALLWORLD_START!= date '+%s'
  1161. .export _INSTALLWORLD_START
  1162. .endif
  1163. .if make(*installkernel*)
  1164. _INSTALLKERNEL_START!= date '+%s'
  1165. .export _INSTALLKERNEL_START
  1166. .endif
  1167. buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .PHONY
  1168. .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
  1169. _ncpu_cmd=sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo unknown
  1170. buildworld_prologue: .PHONY
  1171. @echo "--------------------------------------------------------------"
  1172. @echo ">>> World build started on `LC_ALL=C date`"
  1173. @echo "--------------------------------------------------------------"
  1174. buildworld_epilogue: .PHONY
  1175. @echo
  1176. @echo "--------------------------------------------------------------"
  1177. @echo ">>> World build completed on `LC_ALL=C date`"
  1178. @seconds=$$(($$(date '+%s') - ${_BUILDWORLD_START})); \
  1179. echo ">>> World built in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
  1180. @echo "--------------------------------------------------------------"
  1181. #
  1182. # We need to have this as a target because the indirection between Makefile
  1183. # and Makefile.inc1 causes the correct PATH to be used, rather than a
  1184. # modification of the current environment's PATH. In addition, we need
  1185. # to quote multiword values.
  1186. #
  1187. buildenvvars: .PHONY
  1188. @echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
  1189. .if ${.TARGETS:Mbuildenv}
  1190. .if ${.MAKEFLAGS:M-j}
  1191. .error The buildenv target is incompatible with -j
  1192. .endif
  1193. .endif
  1194. BUILDENV_DIR?= ${.CURDIR}
  1195. #
  1196. # Note: make will report any errors the shell reports. This can
  1197. # be odd if the last command in an interactive shell generates an
  1198. # error or is terminated by SIGINT. These reported errors look bad,
  1199. # but are harmless. Allowing them also allows BUILDENV_SHELL to
  1200. # be a complex command whose status will be returned to the caller.
  1201. # Some scripts in tools rely on this behavior to report build errors.
  1202. #
  1203. buildenv: .PHONY
  1204. @echo Entering world for ${TARGET_ARCH}:${TARGET}
  1205. .if ${BUILDENV_SHELL:M*zsh*}
  1206. @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE}
  1207. .endif
  1208. @cd ${BUILDENV_DIR} && env ${WMAKEENV} \
  1209. INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" \
  1210. MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" BUILDENV=1 ${BUILDENV_SHELL}
  1211. TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:${libcompats:@v@Nbuild${v}@:ts:}}
  1212. toolchain: ${TOOLCHAIN_TGTS} .PHONY
  1213. KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries}
  1214. .if make(kernel-toolchain)
  1215. .ORDER: ${KERNEL_TOOLCHAIN_TGTS}
  1216. .endif
  1217. kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY
  1218. #
  1219. # installcheck
  1220. #
  1221. # Checks to be sure system is ready for installworld/installkernel.
  1222. #
  1223. installcheck: _installcheck_world _installcheck_kernel .PHONY
  1224. _installcheck_world: .PHONY
  1225. @echo "--------------------------------------------------------------"
  1226. @echo ">>> Install check world started on `LC_ALL=C date`"
  1227. @echo "--------------------------------------------------------------"
  1228. _installcheck_kernel: .PHONY
  1229. @echo "--------------------------------------------------------------"
  1230. @echo ">>> Install check kernel started on `LC_ALL=C date`"
  1231. @echo "--------------------------------------------------------------"
  1232. #
  1233. # Require DESTDIR to be set if installing for a different architecture or
  1234. # using the user/group database in the source tree.
  1235. #
  1236. .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \
  1237. defined(DB_FROM_SRC)
  1238. .if !make(distributeworld)
  1239. _installcheck_world: __installcheck_DESTDIR
  1240. _installcheck_kernel: __installcheck_DESTDIR
  1241. __installcheck_DESTDIR: .PHONY
  1242. .if !defined(DESTDIR) || empty(DESTDIR)
  1243. @echo "ERROR: Please set DESTDIR!"; \
  1244. false
  1245. .endif
  1246. .endif
  1247. .endif
  1248. .if !defined(DB_FROM_SRC)
  1249. #
  1250. # Check for missing UIDs/GIDs.
  1251. #
  1252. CHECK_UIDS= auditdistd
  1253. CHECK_GIDS= audit
  1254. CHECK_UIDS+= ntpd
  1255. CHECK_GIDS+= ntpd
  1256. CHECK_UIDS+= proxy
  1257. CHECK_GIDS+= proxy authpf
  1258. CHECK_UIDS+= smmsp
  1259. CHECK_GIDS+= smmsp
  1260. CHECK_UIDS+= unbound
  1261. CHECK_GIDS+= unbound
  1262. _installcheck_world: __installcheck_UGID
  1263. __installcheck_UGID: .PHONY
  1264. .for uid in ${CHECK_UIDS}
  1265. @if ! `id -u ${uid} >/dev/null 2>&1`; then \
  1266. echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
  1267. false; \
  1268. fi
  1269. .endfor
  1270. .for gid in ${CHECK_GIDS}
  1271. @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
  1272. echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
  1273. false; \
  1274. fi
  1275. .endfor
  1276. .endif
  1277. #
  1278. # If installing over the running system (DESTDIR is / or unset) and the install
  1279. # includes rescue, try running rescue from the objdir as a sanity check. If
  1280. # rescue is not functional (e.g., because it depends on a system call not
  1281. # supported by the currently running kernel), abort the installation.
  1282. #
  1283. .if !make(distributeworld) && ${MK_RESCUE} != "no" && \
  1284. (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH)
  1285. _installcheck_world: __installcheck_sh_check
  1286. __installcheck_sh_check: .PHONY
  1287. @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \
  1288. OK ]; then \
  1289. echo "rescue/sh check failed, installation aborted" >&2; \
  1290. false; \
  1291. fi
  1292. .endif
  1293. #
  1294. # Required install tools to be saved in a scratch dir for safety.
  1295. #
  1296. .if !defined(CROSSBUILD_HOST)
  1297. _sysctl=sysctl
  1298. .endif
  1299. ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
  1300. date echo egrep find grep id install ${_install-info} \
  1301. ln make mkdir mtree mv pwd_mkdb \
  1302. rm sed services_mkdb sh sort strip ${_sysctl} test time true uname wc
  1303. .if ${MK_ZONEINFO} != "no"
  1304. ITOOLS+=tzsetup
  1305. .endif
  1306. # Needed for share/man
  1307. .if ${MK_MAN_UTILS} != "no"
  1308. ITOOLS+=makewhatis
  1309. .endif
  1310. ITOOLS+=${LOCAL_ITOOLS}
  1311. #
  1312. # distributeworld
  1313. #
  1314. # Distributes everything compiled by a `buildworld'.
  1315. #
  1316. # installworld
  1317. #
  1318. # Installs everything compiled by a 'buildworld'.
  1319. #
  1320. # Non-base distributions produced by the base system
  1321. EXTRA_DISTRIBUTIONS=
  1322. .for libcompat in ${libcompats}
  1323. EXTRA_DISTRIBUTIONS+= lib${libcompat}
  1324. .endfor
  1325. .if ${MK_TESTS} != "no"
  1326. EXTRA_DISTRIBUTIONS+= tests
  1327. .endif
  1328. DEBUG_DISTRIBUTIONS=
  1329. .if ${MK_DEBUG_FILES} != "no"
  1330. DEBUG_DISTRIBUTIONS+= base ${EXTRA_DISTRIBUTIONS:S,tests,,}
  1331. .endif
  1332. MTREE_MAGIC?= mtree 2.0
  1333. distributeworld installworld stageworld: _installcheck_world .PHONY
  1334. mkdir -p ${INSTALLTMP}
  1335. progs=$$(for prog in ${ITOOLS}; do \
  1336. if progpath=`env PATH=${TMPPATH:Q} which $$prog`; then \
  1337. echo $$progpath; \
  1338. else \
  1339. echo "Required tool $$prog not found in PATH ("${TMPPATH:Q}")." >&2; \
  1340. exit 1; \
  1341. fi; \
  1342. done); \
  1343. if [ -z "${CROSSBUILD_HOST}" ] ; then \
  1344. libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | grep -Ev '\[.*]' | \
  1345. while read line; do \
  1346. set -- $$line; \
  1347. if [ "$$2 $$3" != "not found" ]; then \
  1348. echo $$2; \
  1349. else \
  1350. echo "Required library $$1 not found." >&2; \
  1351. exit 1; \
  1352. fi; \
  1353. done); \
  1354. fi; \
  1355. ${INSTALLTMP_COPY_HOST_TOOL} $$libs $$progs ${INSTALLTMP}
  1356. cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale
  1357. .if defined(NO_ROOT)
  1358. -mkdir -p ${METALOG:H}
  1359. echo "#${MTREE_MAGIC}" > ${METALOG}
  1360. .endif
  1361. .if make(distributeworld)
  1362. .for dist in ${EXTRA_DISTRIBUTIONS}
  1363. -mkdir ${DESTDIR}/${DISTDIR}/${dist}
  1364. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
  1365. -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null
  1366. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  1367. -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
  1368. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  1369. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
  1370. .for d in ${LIBCOMPAT_INCLUDE_DIRS}
  1371. -mkdir ${DESTDIR}/${DISTDIR}/${dist}/usr/include/${d}
  1372. .endfor
  1373. .if ${MK_DEBUG_FILES} != "no"
  1374. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
  1375. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
  1376. .endif
  1377. .for libcompat in ${libcompats}
  1378. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  1379. -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
  1380. .if ${MK_DEBUG_FILES} != "no"
  1381. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  1382. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/usr >/dev/null
  1383. .endif
  1384. .endfor
  1385. .if ${MK_TESTS} != "no" && ${dist} == "tests"
  1386. -mkdir -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE}
  1387. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
  1388. -p ${DESTDIR}/${DISTDIR}/${dist}${TESTSBASE} >/dev/null
  1389. .if ${MK_DEBUG_FILES} != "no"
  1390. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
  1391. -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib/debug/${TESTSBASE} >/dev/null
  1392. .endif
  1393. .endif
  1394. .if defined(NO_ROOT)
  1395. ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
  1396. sed -e 's#^\./#./${dist}/#' >> ${METALOG}
  1397. ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \
  1398. sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
  1399. ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
  1400. sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
  1401. .for d in ${LIBCOMPAT_INCLUDE_DIRS}
  1402. echo "./${dist}/usr/include/${d} type=dir uname=root gname=wheel mode=0755" >> ${METALOG}
  1403. .endfor
  1404. .for libcompat in ${libcompats}
  1405. ${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
  1406. sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
  1407. .endfor
  1408. .endif
  1409. .endfor
  1410. -mkdir ${DESTDIR}/${DISTDIR}/base
  1411. ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \
  1412. METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
  1413. DISTBASE=/base DESTDIR=${INSTALL_DDIR}/base \
  1414. LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
  1415. ${INSTALL_SYMLINK} ${INSTALLFLAGS} usr/src/sys ${INSTALL_DDIR}/base/sys
  1416. .endif # make(distributeworld)
  1417. ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
  1418. ${IMAKEENV} rm -rf ${INSTALLTMP}
  1419. .if !make(packageworld) && ${MK_CAROOT} != "no"
  1420. @if which openssl>/dev/null; then \
  1421. PATH=${TMPPATH:Q}:${PATH:Q} \
  1422. LOCALBASE=${LOCALBASE:Q} \
  1423. sh ${SRCTOP}/usr.sbin/certctl/certctl.sh ${CERTCTLFLAGS} rehash; \
  1424. else \
  1425. echo "No openssl on the host, not rehashing certificates target -- /etc/ssl may not be populated."; \
  1426. fi
  1427. .endif
  1428. .if make(distributeworld)
  1429. .for dist in ${EXTRA_DISTRIBUTIONS}
  1430. find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -type d -empty -delete
  1431. .endfor
  1432. .if defined(NO_ROOT)
  1433. .for dist in base ${EXTRA_DISTRIBUTIONS}
  1434. @# For each file that exists in this dist, print the corresponding
  1435. @# line from the METALOG. This relies on the fact that
  1436. @# a line containing only the filename will sort immediately before
  1437. @# the relevant mtree line.
  1438. cd ${DESTDIR}/${DISTDIR}; \
  1439. find ./${dist} | ${METALOG_SORT_CMD} -u ${METALOG} - | \
  1440. awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}/, "."); print } }' > \
  1441. ${DESTDIR}/${DISTDIR}/${dist}.meta
  1442. .endfor
  1443. .for dist in ${DEBUG_DISTRIBUTIONS}
  1444. @# For each file that exists in this dist, print the corresponding
  1445. @# line from the METALOG. This relies on the fact that
  1446. @# a line containing only the filename will sort immediately before
  1447. @# the relevant mtree line.
  1448. cd ${DESTDIR}/${DISTDIR}; \
  1449. find ./${dist}/usr/lib/debug | ${METALOG_SORT_CMD} -u ${METALOG} - | \
  1450. awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}/, "."); print } }' > \
  1451. ${DESTDIR}/${DISTDIR}/${dist}.debug.meta
  1452. .endfor
  1453. .endif
  1454. .endif # make(distributeworld)
  1455. packageworld: .PHONY
  1456. .for dist in base ${EXTRA_DISTRIBUTIONS}
  1457. .if defined(NO_ROOT)
  1458. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1459. ${TAR_CMD} cvf - --exclude usr/lib/debug \
  1460. @${DESTDIR}/${DISTDIR}/${dist}.meta | \
  1461. ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
  1462. .else
  1463. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1464. ${TAR_CMD} cvf - --exclude usr/lib/debug . | \
  1465. ${XZ_CMD} > ${PACKAGEDIR}/${dist}.txz
  1466. .endif
  1467. .endfor
  1468. .for dist in ${DEBUG_DISTRIBUTIONS}
  1469. . if defined(NO_ROOT)
  1470. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1471. ${TAR_CMD} cvf - @${DESTDIR}/${DISTDIR}/${dist}.debug.meta | \
  1472. ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
  1473. . else
  1474. ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
  1475. ${TAR_CMD} cvLf - usr/lib/debug | \
  1476. ${XZ_CMD} > ${PACKAGEDIR}/${dist}-dbg.txz
  1477. . endif
  1478. .endfor
  1479. makeman: .PHONY
  1480. ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \
  1481. ${.CURDIR}/share/man/man5/src.conf.5
  1482. # Ensure no regressions in self-includeability of sys/*.h and net*/*.h
  1483. test-includes: .PHONY
  1484. ${_+_}cd ${.CURDIR}/tools/build/test-includes; \
  1485. ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} DESTDIR=${WORLDTMP} test-includes
  1486. # We can't assume here that ${TMPPATH} will include ${PATH} or /usr/libexec
  1487. # because we may be building with a STRICTTMPPATH, so we explicitly include
  1488. # /usr/libexec here for flua. ${TMPPATH} still usefully includes anything else
  1489. # we may need to function.
  1490. _sysent_PATH= ${TMPPATH}:/usr/libexec
  1491. _sysent_dirs= sys/kern
  1492. _sysent_dirs+= sys/compat/freebsd32
  1493. _sysent_dirs+= sys/amd64/linux \
  1494. sys/amd64/linux32 \
  1495. sys/arm64/linux \
  1496. sys/i386/linux
  1497. sysent: .PHONY
  1498. .for _dir in ${_sysent_dirs}
  1499. sysent-${_dir}: .PHONY
  1500. @echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
  1501. ${_+_}@env PATH=${_sysent_PATH:Q} ${MAKE} -C ${.CURDIR}/${_dir} sysent
  1502. sysent: sysent-${_dir}
  1503. .endfor
  1504. #
  1505. # reinstall
  1506. #
  1507. # If you have a build server, you can NFS mount the source and obj directories
  1508. # and do a 'make reinstall' on the *client* to install new binaries from the
  1509. # most recent server build.
  1510. #
  1511. restage reinstall: .MAKE .PHONY
  1512. @echo "--------------------------------------------------------------"
  1513. @echo ">>> Making hierarchy"
  1514. @echo "--------------------------------------------------------------"
  1515. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
  1516. LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
  1517. .if make(restage)
  1518. @echo "--------------------------------------------------------------"
  1519. @echo ">>> Making distribution"
  1520. @echo "--------------------------------------------------------------"
  1521. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
  1522. LOCAL_MTREE=${LOCAL_MTREE:Q} distribution
  1523. .endif
  1524. @echo
  1525. @echo "--------------------------------------------------------------"
  1526. @echo ">>> Installing everything started on `LC_ALL=C date`"
  1527. @echo "--------------------------------------------------------------"
  1528. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
  1529. .for libcompat in ${libcompats}
  1530. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install${libcompat}
  1531. .endfor
  1532. @echo "--------------------------------------------------------------"
  1533. @echo ">>> Installing everything completed on `LC_ALL=C date`"
  1534. @seconds=$$(($$(date '+%s') - ${_INSTALLWORLD_START})); \
  1535. echo ">>> Install world completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
  1536. @echo "--------------------------------------------------------------"
  1537. redistribute: .MAKE .PHONY
  1538. @echo "--------------------------------------------------------------"
  1539. @echo ">>> Distributing everything"
  1540. @echo "--------------------------------------------------------------"
  1541. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
  1542. .for libcompat in ${libcompats}
  1543. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute${libcompat} \
  1544. DISTRIBUTION=lib${libcompat}
  1545. .endfor
  1546. distrib-dirs distribution: .MAKE .PHONY
  1547. ${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \
  1548. ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
  1549. .if make(distribution)
  1550. ${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH:Q} \
  1551. ${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
  1552. METALOG=${METALOG} MK_TESTS=no \
  1553. MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig
  1554. .endif
  1555. #
  1556. # buildetc and installetc
  1557. #
  1558. buildetc: .MAKE .PHONY
  1559. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _worldtmp
  1560. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _legacy
  1561. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _bootstrap-tools \
  1562. MK_CROSS_COMPILER=no MK_TOOLCHAIN=no
  1563. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 _obj \
  1564. SUBDIR_OVERRIDE=etc
  1565. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 everything \
  1566. SUBDIR_OVERRIDE=etc
  1567. installetc: .MAKE .PHONY
  1568. @echo "--------------------------------------------------------------"
  1569. @echo ">>> Making hierarchy"
  1570. @echo "--------------------------------------------------------------"
  1571. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distrib-dirs
  1572. @echo "--------------------------------------------------------------"
  1573. @echo ">>> Making distribution"
  1574. @echo "--------------------------------------------------------------"
  1575. ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribution
  1576. #
  1577. # buildkernel and installkernel
  1578. #
  1579. # Which kernels to build and/or install is specified by setting
  1580. # KERNCONF. If not defined a GENERIC kernel is built/installed.
  1581. # Only the existing (depending TARGET) config files are used
  1582. # for building kernels and only the first of these is designated
  1583. # as the one being installed.
  1584. #
  1585. # Note that we have to use TARGET instead of TARGET_ARCH when
  1586. # we're in kernel-land. Since only TARGET_ARCH is (expected) to
  1587. # be set to cross-build, we have to make sure TARGET is set
  1588. # properly.
  1589. .if defined(KERNFAST)
  1590. NO_KERNELCLEAN= t
  1591. NO_KERNELCONFIG= t
  1592. NO_KERNELOBJ= t
  1593. # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah
  1594. .if !defined(KERNCONF) && ${KERNFAST} != "1"
  1595. KERNCONF=${KERNFAST}
  1596. .endif
  1597. .endif
  1598. GENERIC_KERNCONF_SUFX_powerpc64= 64
  1599. GENERIC_KERNCONF_SUFX_powerpc64le= 64LE
  1600. GENERIC_KERNCONF_powerpcspe= MPC85XXSPE
  1601. GENERIC_KERNCONF?= ${GENERIC_KERNCONF_${TARGET_ARCH}:UGENERIC${GENERIC_KERNCONF_SUFX_${TARGET_ARCH}}}
  1602. INSTKERNNAME?= kernel
  1603. KERNSRCDIR?= ${.CURDIR}/sys
  1604. KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf
  1605. KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,}
  1606. KERNCONFDIR?= ${KRNLCONFDIR}
  1607. .for _k in ${GENERIC_KERNCONF} MINIMAL${GENERIC_KERNCONF_SUFX_${TARGET_ARCH}} ${GENERIC_KERNCONF}-MMCCAM
  1608. .if exists(${KERNCONFDIR}/${_k})
  1609. PKG_KERNCONF+= ${_k}
  1610. .for _dbg in NODEBUG DEBUG
  1611. .if exists(${KERNCONFDIR}/${_k}-${_dbg})
  1612. PKG_KERNCONF+= ${_k}-${_dbg}
  1613. .endif
  1614. .endfor
  1615. .endif
  1616. .endfor
  1617. .if defined(PACKAGE_BUILDING)
  1618. KERNCONF?= ${PKG_KERNCONF}
  1619. .else
  1620. KERNCONF?= ${GENERIC_KERNCONF}
  1621. .endif
  1622. BUILDKERNELS=
  1623. INSTALLKERNEL=
  1624. .if defined(NO_INSTALLKERNEL)
  1625. # All of the BUILDKERNELS loops start at index 1.
  1626. BUILDKERNELS+= dummy
  1627. .endif
  1628. .for _kernel in ${KERNCONF}
  1629. .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${_kernel})
  1630. BUILDKERNELS+= ${_kernel}
  1631. .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL)
  1632. INSTALLKERNEL= ${_kernel}
  1633. .endif
  1634. .else
  1635. .if make(buildkernel)
  1636. .error Missing KERNCONF ${KERNCONFDIR}/${_kernel}
  1637. .endif
  1638. .endif
  1639. .endfor
  1640. _cleankernobj_fast_depend_hack: .PHONY
  1641. # 20191009 r353340 removal of opensolaris_atomic.S (also r353381)
  1642. .if ${MACHINE} != i386
  1643. .for f in opensolaris_atomic
  1644. .for m in opensolaris zfs
  1645. @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \
  1646. grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \
  1647. echo "Removing stale dependencies for opensolaris_atomic"; \
  1648. rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
  1649. fi
  1650. .endfor
  1651. .endfor
  1652. .endif
  1653. ${WMAKE_TGTS:N_cleanworldtmp:N_worldtmp:${libcompats:@v@Nbuild${v}@:ts:}}: .MAKE .PHONY
  1654. ${.ALLTARGETS:M_*:N_cleanworldtmp:N_worldtmp}: .MAKE .PHONY
  1655. # record kernel(s) build time in seconds
  1656. .if make(buildkernel)
  1657. _BUILDKERNEL_START!= date '+%s'
  1658. .endif
  1659. #
  1660. # buildkernel
  1661. #
  1662. # Builds all kernels defined by BUILDKERNELS.
  1663. #
  1664. buildkernel: .MAKE .PHONY
  1665. .if empty(BUILDKERNELS:Ndummy)
  1666. @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
  1667. false
  1668. .endif
  1669. @echo
  1670. .for _kernel in ${BUILDKERNELS:Ndummy}
  1671. @echo "--------------------------------------------------------------"
  1672. @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`"
  1673. @echo "--------------------------------------------------------------"
  1674. @echo "===> ${_kernel}"
  1675. mkdir -p ${KRNLOBJDIR}
  1676. .if !defined(NO_KERNELCONFIG)
  1677. @echo
  1678. @echo "--------------------------------------------------------------"
  1679. @echo ">>> stage 1: configuring the kernel"
  1680. @echo "--------------------------------------------------------------"
  1681. cd ${KRNLCONFDIR}; \
  1682. PATH=${TMPPATH:Q} \
  1683. config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
  1684. -I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
  1685. '${KERNCONFDIR}/${_kernel}'
  1686. .endif
  1687. .if ${MK_CLEAN} == "yes" && !defined(NO_KERNELCLEAN)
  1688. @echo
  1689. @echo "--------------------------------------------------------------"
  1690. @echo ">>> stage 2.1: cleaning up the object tree"
  1691. @echo "--------------------------------------------------------------"
  1692. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR}
  1693. .else
  1694. ${_+_}cd ${.CURDIR}; ${WMAKE} _cleankernobj_fast_depend_hack
  1695. .endif
  1696. .if !defined(NO_KERNELOBJ)
  1697. @echo
  1698. @echo "--------------------------------------------------------------"
  1699. @echo ">>> stage 2.2: rebuilding the object tree"
  1700. @echo "--------------------------------------------------------------"
  1701. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj
  1702. .endif
  1703. @echo
  1704. @echo "--------------------------------------------------------------"
  1705. @echo ">>> stage 2.3: build tools"
  1706. @echo "--------------------------------------------------------------"
  1707. ${_+_}cd ${.CURDIR}; ${KTMAKE} kernel-tools
  1708. @echo
  1709. @echo "--------------------------------------------------------------"
  1710. @echo ">>> stage 3.1: building everything"
  1711. @echo "--------------------------------------------------------------"
  1712. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ
  1713. @echo "--------------------------------------------------------------"
  1714. @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
  1715. @echo "--------------------------------------------------------------"
  1716. .endfor
  1717. @seconds=$$(($$(date '+%s') - ${_BUILDKERNEL_START})); \
  1718. echo ">>> Kernel(s) ${BUILDKERNELS} built in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
  1719. @echo "--------------------------------------------------------------"
  1720. .if !make(packages) && !make(update-packages)
  1721. NO_INSTALLEXTRAKERNELS?= yes
  1722. .else
  1723. # packages/update-packages installs kernels to a staging directory then builds
  1724. # packages from the result to be installed, typically to other systems. It is
  1725. # less surprising for these targets to honor KERNCONF if multiple kernels are
  1726. # specified.
  1727. NO_INSTALLEXTRAKERNELS?= no
  1728. .endif
  1729. #
  1730. # installkernel, etc.
  1731. #
  1732. # Install the kernel defined by INSTALLKERNEL
  1733. #
  1734. installkernel installkernel.debug \
  1735. reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
  1736. .if !defined(NO_INSTALLKERNEL)
  1737. .if empty(INSTALLKERNEL)
  1738. @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
  1739. false
  1740. .endif
  1741. @echo "--------------------------------------------------------------"
  1742. @echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
  1743. @echo "--------------------------------------------------------------"
  1744. ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
  1745. ${CROSSENV} PATH=${TMPPATH:Q} \
  1746. ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} METALOG=${METALOG} \
  1747. ${.TARGET:S/kernel//}
  1748. @echo "--------------------------------------------------------------"
  1749. @echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
  1750. @echo "--------------------------------------------------------------"
  1751. @seconds=$$(($$(date '+%s') - ${_INSTALLKERNEL_START})); \
  1752. echo ">>> Install kernel(s) ${INSTALLKERNEL} completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
  1753. @echo "--------------------------------------------------------------"
  1754. .endif
  1755. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1756. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1757. @echo "--------------------------------------------------------------"
  1758. @echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
  1759. @echo "--------------------------------------------------------------"
  1760. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
  1761. ${CROSSENV} PATH=${TMPPATH:Q} \
  1762. ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} METALOG=${METALOG} \
  1763. ${.TARGET:S/kernel//}
  1764. @echo "--------------------------------------------------------------"
  1765. @echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
  1766. @echo "--------------------------------------------------------------"
  1767. .endfor
  1768. @seconds=$$(($$(date '+%s') - ${_INSTALLKERNEL_START})); \
  1769. echo ">>> Install kernel(s) ${BUILDKERNELS} completed in $$seconds seconds, ncpu: $$(${_ncpu_cmd})${.MAKE.JOBS:S/^/, make -j/}"
  1770. @echo "--------------------------------------------------------------"
  1771. .endif
  1772. distributekernel distributekernel.debug: .PHONY
  1773. .if !defined(NO_INSTALLKERNEL)
  1774. .if empty(INSTALLKERNEL)
  1775. @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
  1776. false
  1777. .endif
  1778. mkdir -p ${DESTDIR}/${DISTDIR}
  1779. .if defined(NO_ROOT)
  1780. @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
  1781. .endif
  1782. ${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
  1783. ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
  1784. ${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} KERNEL=${INSTKERNNAME} \
  1785. DISTBASE=/kernel DESTDIR=${INSTALL_DDIR}/kernel \
  1786. METALOG=${METALOG:S/METALOG/kernel.premeta/} \
  1787. ${.TARGET:S/distributekernel/install/}
  1788. .if defined(NO_ROOT)
  1789. @sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
  1790. ${DESTDIR}/${DISTDIR}/kernel.meta
  1791. .endif
  1792. .endif
  1793. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1794. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1795. .if defined(NO_ROOT)
  1796. @echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
  1797. .endif
  1798. ${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
  1799. ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
  1800. ${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} \
  1801. KERNEL=${INSTKERNNAME}.${_kernel} \
  1802. DISTBASE=/kernel.${_kernel} DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
  1803. METALOG=${METALOG:S/METALOG/kernel.${_kernel}.premeta/} \
  1804. ${.TARGET:S/distributekernel/install/}
  1805. .if defined(NO_ROOT)
  1806. @sed -e "s|^./kernel.${_kernel}|.|" \
  1807. ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
  1808. ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
  1809. .endif
  1810. .endfor
  1811. .endif
  1812. packagekernel: .PHONY
  1813. .if defined(NO_ROOT)
  1814. .if !defined(NO_INSTALLKERNEL)
  1815. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1816. ${TAR_CMD} cvf - --exclude '*.debug' \
  1817. @${DESTDIR}/${DISTDIR}/kernel.meta | \
  1818. ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
  1819. .endif
  1820. .if ${MK_DEBUG_FILES} != "no"
  1821. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1822. ${TAR_CMD} cvf - --include '*/*/*.debug' \
  1823. @${DESTDIR}/${DISTDIR}/kernel.meta | \
  1824. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
  1825. .endif
  1826. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1827. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1828. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1829. ${TAR_CMD} cvf - --exclude '*.debug' \
  1830. @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
  1831. ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
  1832. .if ${MK_DEBUG_FILES} != "no"
  1833. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1834. ${TAR_CMD} cvf - --include '*/*/*.debug' \
  1835. @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
  1836. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
  1837. .endif
  1838. .endfor
  1839. .endif
  1840. .else
  1841. .if !defined(NO_INSTALLKERNEL)
  1842. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1843. ${TAR_CMD} cvf - --exclude '*.debug' . | \
  1844. ${XZ_CMD} > ${PACKAGEDIR}/kernel.txz
  1845. .endif
  1846. .if ${MK_DEBUG_FILES} != "no"
  1847. cd ${DESTDIR}/${DISTDIR}/kernel; \
  1848. ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \
  1849. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel-dbg.txz
  1850. .endif
  1851. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  1852. .for _kernel in ${BUILDKERNELS:[2..-1]}
  1853. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1854. ${TAR_CMD} cvf - --exclude '*.debug' . | \
  1855. ${XZ_CMD} > ${PACKAGEDIR}/kernel.${_kernel}.txz
  1856. .if ${MK_DEBUG_FILES} != "no"
  1857. cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
  1858. ${TAR_CMD} cvf - --include '*/*/*.debug' $$(eval find .) | \
  1859. ${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}-dbg.txz
  1860. .endif
  1861. .endfor
  1862. .endif
  1863. .endif
  1864. stagekernel: .PHONY
  1865. ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel
  1866. PORTSDIR?= /usr/ports
  1867. WSTAGEDIR?= ${OBJTOP}/worldstage
  1868. KSTAGEDIR?= ${OBJTOP}/kernelstage
  1869. SSTAGEDIR?= ${OBJTOP}/sourcestage
  1870. REPODIR?= ${OBJROOT}repo
  1871. PKG_FORMAT?= tzst
  1872. PKG_LEVEL?= -1
  1873. PKG_CLEVEL?= ${"${PKG_FORMAT:Mtar}" != "":?:-l ${PKG_LEVEL}}
  1874. PKG_REPO_SIGNING_KEY?= # empty
  1875. PKG_OUTPUT_DIR?= ${PKG_VERSION}
  1876. PKG_ABI_FILE?= ${WSTAGEDIR}/usr/bin/uname
  1877. .if make(create-*-packages*) || make(real-update-packages) || make(real-sign-packages)
  1878. PKG_ABI!= ${PKG_CMD} -o ABI_FILE=${PKG_ABI_FILE} config ABI
  1879. .endif
  1880. .ORDER: stage-packages create-packages
  1881. .ORDER: create-packages create-world-packages
  1882. .ORDER: create-packages create-source-packages
  1883. .ORDER: create-packages create-kernel-packages
  1884. .ORDER: create-packages sign-packages
  1885. _pkgbootstrap: .PHONY
  1886. .if make(*package*) && !exists(${LOCALBASE}/sbin/pkg)
  1887. @env ASSUME_ALWAYS_YES=YES pkg bootstrap
  1888. .endif
  1889. PKG_BIN_VERSION!=${PKG_CMD} --version </dev/null 2>/dev/null |\
  1890. awk -F. '/^[0-9.]+$$/ {print $$1 * 10000 + $$2 * 100 + $$3}'
  1891. .if ${PKG_BIN_VERSION} < 11700
  1892. PKG_EXT= ${PKG_FORMAT}
  1893. .else
  1894. PKG_EXT= pkg
  1895. .endif
  1896. .if !defined(PKG_VERSION_FROM) && make(real-update-packages)
  1897. .if exists(${PKG_ABI_FILE}) && exists(${REPODIR}/${PKG_ABI})
  1898. PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
  1899. PKG_VERSION_FROM_DIR= ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}
  1900. # Determine the name of the branch base on the version
  1901. # X.bY => beta
  1902. # X.aY => alpha
  1903. # X.rcY => rc
  1904. # X.snap => snap
  1905. # all others mean release
  1906. #
  1907. # This will be used when comparing to the branch that we are building
  1908. # to decide if we keep old packages or new packages when only their
  1909. # version differs
  1910. BRANCH_EXT_FROM=
  1911. .if ${PKG_VERSION_FROM:M*.snap*}
  1912. BRANCH_EXT_FROM= ${PKG_VERSION_FROM:C/.snap.*$//}.snap
  1913. .elif ${PKG_VERSION_FROM:M*.b*}
  1914. BRANCH_EXT_FROM= beta
  1915. .elif ${PKG_VERSION_FROM:M*.rc*}
  1916. BRANCH_EXT_FROM= rc
  1917. .elif ${PKG_VERSION_FROM:M*.a*}
  1918. BRANCH_EXT_FROM= alpha
  1919. .endif
  1920. .else
  1921. PKG_VERSION_FROM=
  1922. PKG_VERSION_FROM_DIR=
  1923. BRANCH_EXT_FROM=
  1924. .endif
  1925. .endif
  1926. PKGMAKEARGS+= PKG_VERSION=${PKG_VERSION} \
  1927. NO_INSTALLEXTRAKERNELS=${NO_INSTALLEXTRAKERNELS}
  1928. packages: .PHONY
  1929. ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-packages
  1930. update-packages: .PHONY
  1931. ${_+_}${MAKE} -C ${.CURDIR} ${PKGMAKEARGS} real-update-packages
  1932. package-pkg: .PHONY
  1933. rm -rf /tmp/ports.${TARGET} || :
  1934. env ${WMAKEENV:Q} SRCDIR=${.CURDIR} PORTSDIR=${PORTSDIR} REVISION=${_REVISION} \
  1935. PKG_CMD=${PKG_CMD} PKG_VERSION=${PKG_VERSION} REPODIR=${REPODIR} \
  1936. WSTAGEDIR=${WSTAGEDIR} \
  1937. OSVERSION="${SRCRELDATE}" \
  1938. sh ${.CURDIR}/release/scripts/make-pkg-package.sh
  1939. real-packages: stage-packages create-packages sign-packages .PHONY
  1940. real-update-packages: stage-packages .PHONY
  1941. ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages
  1942. .if empty(PKG_VERSION_FROM_DIR)
  1943. @echo "==> Bootstrapping repository, not checking for new packages"
  1944. .else
  1945. @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})"
  1946. @for pkg in ${PKG_VERSION_FROM_DIR}/${PKG_NAME_PREFIX}-*; do \
  1947. pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \
  1948. newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_EXT} ; \
  1949. oldsum=$$(pkg query -F $${pkg} '%X') ; \
  1950. if [ ! -f ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ]; then \
  1951. continue; \
  1952. fi ; \
  1953. newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
  1954. if [ "${BRANCH_EXT_FROM}" = "${BRANCH_EXT}" -a "$${oldsum}" = "$${newsum}" ]; then \
  1955. echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_EXT}" ; \
  1956. rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \
  1957. cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \
  1958. else \
  1959. echo "==> New package $${newpkgname}" ; \
  1960. fi ; \
  1961. done
  1962. .endif
  1963. ${_+_}@cd ${.CURDIR}; \
  1964. ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages
  1965. stage-packages-world: .PHONY
  1966. @mkdir -p ${WSTAGEDIR}
  1967. ${_+_}@cd ${.CURDIR}; \
  1968. ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT stageworld
  1969. stage-packages-kernel: .PHONY
  1970. @mkdir -p ${KSTAGEDIR}
  1971. ${_+_}@cd ${.CURDIR}; \
  1972. ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT stagekernel
  1973. stage-packages-source: .PHONY
  1974. @mkdir -p ${SSTAGEDIR};
  1975. stage-packages: .PHONY stage-packages-world stage-packages-kernel stage-packages-source
  1976. _repodir: .PHONY
  1977. @mkdir -p ${REPODIR}
  1978. create-packages-world: _pkgbootstrap _repodir .PHONY
  1979. ${_+_}@cd ${.CURDIR}; \
  1980. ${MAKE} -f Makefile.inc1 \
  1981. DESTDIR=${WSTAGEDIR} \
  1982. PKG_VERSION=${PKG_VERSION} create-world-packages
  1983. create-packages-kernel: _pkgbootstrap _repodir .PHONY
  1984. ${_+_}@cd ${.CURDIR}; \
  1985. ${MAKE} -f Makefile.inc1 \
  1986. DESTDIR=${KSTAGEDIR} \
  1987. PKG_VERSION=${PKG_VERSION} DISTDIR=kernel \
  1988. SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
  1989. create-kernel-packages
  1990. create-packages-kernel-repo: .PHONY create-packages-kernel sign-packages
  1991. create-packages-world-repo: .PHONY create-packages-world sign-packages
  1992. create-packages-source: _pkgbootstrap _repodir .PHONY
  1993. ${_+_}@cd ${.CURDIR}; \
  1994. ${MAKE} -f Makefile.inc1 \
  1995. DESTDIR=${SSTAGEDIR} \
  1996. PKG_VERSION=${PKG_VERSION} create-source-packages
  1997. create-packages: .PHONY create-packages-world create-packages-kernel create-packages-source
  1998. create-source-src-package: _pkgbootstrap .PHONY
  1999. rm -f ${SSTAGEDIR}/src.plist 2>/dev/null || :
  2000. .if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git)
  2001. @cd ${SRCDIR}; \
  2002. ( echo "@override_prefix /usr/src" ; \
  2003. ${GIT_CMD} ls-files --recurse-submodules ":!:sys/" ) \
  2004. > ${SSTAGEDIR}/src.plist
  2005. ${SRCDIR}/release/packages/generate-ucl.lua \
  2006. PKGNAME "src" \
  2007. PKGGENNAME "src" \
  2008. VERSION "${PKG_VERSION}" \
  2009. DESC "FreeBSD Kernel Sources" \
  2010. COMMENT "FreeBSD Userland Sources" \
  2011. PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
  2012. PKG_MAINTAINER "${PKG_MAINTAINER}" \
  2013. PKG_WWW "${PKG_WWW}" \
  2014. ${SRCDIR}/release/packages/template.ucl \
  2015. ${SSTAGEDIR}/src.ucl
  2016. ${PKG_CMD} -o ABI=${PKG_ABI} \
  2017. -o OSVERSION="${SRCRELDATE}" \
  2018. create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
  2019. -M ${SSTAGEDIR}/src.ucl \
  2020. -p ${SSTAGEDIR}/src.plist \
  2021. -r ${SRCDIR} \
  2022. -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
  2023. .endif
  2024. create-source-src-sys-package: _pkgbootstrap .PHONY
  2025. rm -f ${SSTAGEDIR}/src-sys.plist 2>/dev/null || :
  2026. .if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git)
  2027. @cd ${SRCDIR}; \
  2028. ( echo "@override_prefix /usr/src" ; \
  2029. ${GIT_CMD} ls-files --recurse-submodules "sys/" ) \
  2030. > ${SSTAGEDIR}/src-sys.plist
  2031. ${SRCDIR}/release/packages/generate-ucl.lua \
  2032. PKGNAME "src-sys" \
  2033. PKGGENNAME "src" \
  2034. VERSION "${PKG_VERSION}" \
  2035. DESC "FreeBSD Kernel Sources" \
  2036. COMMENT "FreeBSD Kernel Sources" \
  2037. PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
  2038. PKG_MAINTAINER "${PKG_MAINTAINER}" \
  2039. PKG_WWW "${PKG_WWW}" \
  2040. ${SRCDIR}/release/packages/template.ucl \
  2041. ${SSTAGEDIR}/src-sys.ucl
  2042. ${PKG_CMD} -o ABI=${PKG_ABI} \
  2043. -o OSVERSION="${SRCRELDATE}" \
  2044. create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
  2045. -M ${SSTAGEDIR}/src-sys.ucl \
  2046. -p ${SSTAGEDIR}/src-sys.plist \
  2047. -r ${SRCDIR} \
  2048. -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
  2049. .endif
  2050. create-source-packages: .PHONY _pkgbootstrap create-source-src-package create-source-src-sys-package
  2051. create-world-packages: _pkgbootstrap .PHONY
  2052. @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
  2053. @cd ${WSTAGEDIR} ; \
  2054. ${METALOG_SORT_CMD} ${WSTAGEDIR}/${DISTDIR}/METALOG | \
  2055. awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk
  2056. @for plist in ${WSTAGEDIR}/*.plist; do \
  2057. plist=$${plist##*/} ; \
  2058. pkgname=$${plist%.plist} ; \
  2059. echo "_PKGS+= $${pkgname}" ; \
  2060. done > ${WSTAGEDIR}/packages.mk
  2061. ${_+_}@cd ${.CURDIR}; \
  2062. ${MAKE} -f Makefile.inc1 create-world-packages-jobs \
  2063. SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
  2064. .MAKE.JOB.PREFIX=
  2065. .if make(create-world-packages-jobs)
  2066. .include "${WSTAGEDIR}/packages.mk"
  2067. .endif
  2068. create-world-packages-jobs: .PHONY
  2069. .for pkgname in ${_PKGS}
  2070. create-world-packages-jobs: create-world-package-${pkgname}
  2071. create-world-package-${pkgname}: .PHONY
  2072. @sh ${SRCDIR}/release/packages/generate-ucl.sh -o ${pkgname} \
  2073. -s ${SRCDIR} -u ${WSTAGEDIR}/${pkgname}.ucl
  2074. @awk -F\" ' \
  2075. /^name/ { printf("===> Creating %s-", $$2); next } \
  2076. /^version/ { print $$2; next } \
  2077. ' ${WSTAGEDIR}/${pkgname}.ucl
  2078. @if [ "${pkgname}" == "runtime" ]; then \
  2079. sed -i '' -e "s/%VCS_REVISION%/${VCS_REVISION}/" ${WSTAGEDIR}/${pkgname}.ucl ; \
  2080. fi
  2081. ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
  2082. -o OSVERSION="${SRCRELDATE}" \
  2083. create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
  2084. -M ${WSTAGEDIR}/${pkgname}.ucl \
  2085. -p ${WSTAGEDIR}/${pkgname}.plist \
  2086. -r ${WSTAGEDIR} \
  2087. -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
  2088. .endfor
  2089. _default_flavor= -default
  2090. .if make(*package*) && exists(${KSTAGEDIR}/kernel.meta)
  2091. . if ${MK_DEBUG_FILES} != "no"
  2092. _debug=-dbg
  2093. . endif
  2094. create-dtb-package:
  2095. @if [ -f ${KSTAGEDIR}/${DISTDIR}/dtb.plist ]; then \
  2096. ${SRCDIR}/release/packages/generate-ucl.lua \
  2097. PKGNAME "dtb" \
  2098. VERSION "${PKG_VERSION}" \
  2099. COMMENT "FreeBSD Devicetree Blobs" \
  2100. DESC "FreeBSD Devicetree Blobs" \
  2101. PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
  2102. PKG_MAINTAINER "${PKG_MAINTAINER}" \
  2103. PKG_WWW "${PKG_WWW}" \
  2104. ${SRCDIR}/release/packages/template.ucl \
  2105. ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \
  2106. awk -F\" ' \
  2107. /name/ { printf("===> Creating %s-", $$2); next } \
  2108. /version/ {print $$2; next } ' \
  2109. ${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \
  2110. ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
  2111. -o OSVERSION="${SRCRELDATE}" \
  2112. create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
  2113. -M ${KSTAGEDIR}/${DISTDIR}/dtb.ucl \
  2114. -p ${KSTAGEDIR}/${DISTDIR}/dtb.plist \
  2115. -r ${KSTAGEDIR}/${DISTDIR} \
  2116. -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} ; \
  2117. fi
  2118. create-kernel-packages: .PHONY
  2119. . for flavor in "" ${_debug}
  2120. create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} create-dtb-package
  2121. create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
  2122. @cd ${KSTAGEDIR}/${DISTDIR} ; \
  2123. ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.meta | \
  2124. awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
  2125. -v kernel=yes -v _kernconf=${INSTALLKERNEL} ; \
  2126. ${SRCDIR}/release/packages/generate-ucl.lua \
  2127. PKGNAME "kernel-${INSTALLKERNEL:tl}${flavor}" \
  2128. VERSION "${PKG_VERSION}" \
  2129. KERNELDIR "kernel" \
  2130. COMMENT "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \
  2131. DESC "FreeBSD ${INSTALLKERNEL} kernel ${flavor}" \
  2132. PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
  2133. PKG_MAINTAINER "${PKG_MAINTAINER}" \
  2134. PKG_WWW "${PKG_WWW}" \
  2135. ${SRCDIR}/release/packages/template.ucl \
  2136. ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
  2137. awk -F\" ' \
  2138. /name/ { printf("===> Creating %s-", $$2); next } \
  2139. /version/ {print $$2; next } ' \
  2140. ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
  2141. ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
  2142. -o OSVERSION="${SRCRELDATE}" \
  2143. create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
  2144. -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
  2145. -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
  2146. -r ${KSTAGEDIR}/${DISTDIR} \
  2147. -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
  2148. . endfor
  2149. .endif
  2150. .if ${BUILDKERNELS:[#]} > 1 && ${NO_INSTALLEXTRAKERNELS} != "yes"
  2151. . for _kernel in ${BUILDKERNELS:[2..-1]}
  2152. . if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
  2153. . if ${MK_DEBUG_FILES} != "no"
  2154. _debug=-dbg
  2155. . endif
  2156. . for flavor in "" ${_debug}
  2157. create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
  2158. create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
  2159. @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
  2160. ${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.${_kernel}.meta | \
  2161. awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
  2162. -v kernel=yes -v _kernconf=${_kernel} ; \
  2163. ${SRCDIR}/release/packages/generate-ucl.lua \
  2164. PKGNAME "kernel-${_kernel:tl}${flavor}" \
  2165. PKGGENNAME "kernel" \
  2166. FORCEINCLUDE "kernel${flavor}" \
  2167. UCLFILES "${SRCDIR}/release/packages/" \
  2168. VERSION "${PKG_VERSION}" \
  2169. KERNELDIR "kernel.${_kernel}" \
  2170. DESC "FreeBSD ${_kernel} kernel ${flavor}" \
  2171. COMMENT "FreeBSD ${_kernel} kernel ${flavor}" \
  2172. PKG_NAME_PREFIX "${PKG_NAME_PREFIX}" \
  2173. PKG_MAINTAINER "${PKG_MAINTAINER}" \
  2174. PKG_WWW "${PKG_WWW}" \
  2175. ${SRCDIR}/release/packages/template.ucl \
  2176. ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
  2177. awk -F\" ' \
  2178. /name/ { printf("===> Creating %s-", $$2); next } \
  2179. /version/ {print $$2; next } ' \
  2180. ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
  2181. ${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
  2182. -o OSVERSION="${SRCRELDATE}" \
  2183. create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
  2184. -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
  2185. -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
  2186. -r ${KSTAGEDIR}/kernel.${_kernel} \
  2187. -o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}
  2188. . endfor
  2189. . endif
  2190. . endfor
  2191. .endif
  2192. sign-packages: .PHONY
  2193. ${_+_}@cd ${.CURDIR}; \
  2194. ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} real-sign-packages
  2195. real-sign-packages: _pkgbootstrap .PHONY
  2196. printf "version = 2;\n" > ${WSTAGEDIR}/meta
  2197. .if ${PKG_BIN_VERSION} < 11700
  2198. printf "packing_format = \"${PKG_FORMAT}\";\n" >> ${WSTAGEDIR}/meta
  2199. .endif
  2200. @[ -L "${REPODIR}/${PKG_ABI}/latest" ] && unlink ${REPODIR}/${PKG_ABI}/latest; \
  2201. ${PKG_CMD} -o ABI=${PKG_ABI} repo -o OSVERSION="${SRCRELDATE}" \
  2202. -m ${WSTAGEDIR}/meta \
  2203. -o ${REPODIR}/${PKG_ABI}/${PKG_VERSION} \
  2204. ${REPODIR}/${PKG_ABI}/${PKG_VERSION} \
  2205. ${PKG_REPO_SIGNING_KEY} ; \
  2206. cd ${REPODIR}/${PKG_ABI}; \
  2207. ln -s ${PKG_OUTPUT_DIR} latest
  2208. #
  2209. #
  2210. # checkworld
  2211. #
  2212. # Run test suite on installed world.
  2213. #
  2214. checkworld: .PHONY
  2215. @if [ ! -x "${LOCALBASE}/bin/kyua" ] && [ ! -x "/usr/bin/kyua" ]; then \
  2216. echo "You need kyua (devel/kyua) to run the test suite." | /usr/bin/fmt; \
  2217. exit 1; \
  2218. fi
  2219. ${_+_}PATH="$$PATH:${LOCALBASE}/bin" kyua test -k ${TESTSBASE}/Kyuafile
  2220. #
  2221. #
  2222. # doxygen
  2223. #
  2224. # Build the API documentation with doxygen
  2225. #
  2226. doxygen: .PHONY
  2227. @if [ ! -x "${LOCALBASE}/bin/doxygen" ]; then \
  2228. echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \
  2229. exit 1; \
  2230. fi
  2231. ${_+_}cd ${.CURDIR}/tools/kerneldoc/subsys; ${MAKE} obj all
  2232. #
  2233. # ------------------------------------------------------------------------
  2234. #
  2235. # From here onwards are utility targets used by the 'make world' and
  2236. # related targets. If your 'world' breaks, you may like to try to fix
  2237. # the problem and manually run the following targets to attempt to
  2238. # complete the build. Beware, this is *not* guaranteed to work, you
  2239. # need to have a pretty good grip on the current state of the system
  2240. # to attempt to manually finish it. If in doubt, 'make world' again.
  2241. #
  2242. #
  2243. # legacy: Build compatibility shims for the next three targets. This is a
  2244. # minimal set of tools and shims necessary to compensate for older systems
  2245. # which don't have the APIs required by the targets built in bootstrap-tools,
  2246. # build-tools or cross-tools.
  2247. #
  2248. legacy: .PHONY
  2249. .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
  2250. @echo "ERROR: Source upgrades from versions prior to ${MINIMUM_SUPPORTED_REL} are not supported."; \
  2251. false
  2252. .endif
  2253. .for _tool in \
  2254. tools/build \
  2255. ${LOCAL_LEGACY_DIRS}
  2256. ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
  2257. cd ${.CURDIR}/${_tool}; \
  2258. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  2259. ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \
  2260. ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
  2261. ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
  2262. DESTDIR=${WORLDTMP}/legacy install
  2263. .endfor
  2264. #
  2265. # bootstrap-tools: Build tools needed for compatibility. These are binaries that
  2266. # are built to build other binaries in the system. However, the focus of these
  2267. # binaries is usually quite narrow. Bootstrap tools use the host's compiler and
  2268. # libraries, augmented by -legacy, in addition to the libraries built during
  2269. # bootstrap-tools.
  2270. #
  2271. _bt= _bootstrap-tools
  2272. # We want to run the build with only ${WORLDTMP} in $PATH to ensure we don't
  2273. # accidentally run tools that are incompatible but happen to be in $PATH.
  2274. # This is especially important when building on Linux/MacOS where many of the
  2275. # programs used during the build accept different flags or generate different
  2276. # output. On those platforms we only symlink the tools known to be compatible
  2277. # (e.g. basic utilities such as mkdir) into ${WORLDTMP} and build all others
  2278. # from the FreeBSD sources during the bootstrap-tools stage.
  2279. # We want to build without the user's $PATH starting in the bootstrap-tools
  2280. # phase so the tools used in that phase (ln, cp, etc) must have already been
  2281. # linked to $WORLDTMP. The tools are listed in the _host_tools_to_symlink
  2282. # variable in tools/build/Makefile and are linked during the legacy phase.
  2283. # Since they could be Linux or MacOS binaries, too we must only use flags that
  2284. # are portable across operating systems.
  2285. # If BOOTSTRAP_ALL_TOOLS is set we will build all the required tools from the
  2286. # current source tree. Otherwise we create a symlink to the version found in
  2287. # $PATH during the bootstrap-tools stage.
  2288. # When building on non-FreeBSD systems we can't assume that the host binaries
  2289. # accept compatible flags or produce compatible output. Therefore we force
  2290. # BOOTSTRAP_ALL_TOOLS and just build the FreeBSD version of the binary.
  2291. .if defined(CROSSBUILD_HOST)
  2292. BOOTSTRAP_ALL_TOOLS:= 1
  2293. .endif
  2294. .if defined(BOOTSTRAP_ALL_TOOLS)
  2295. # BOOTSTRAPPING will be set on the command line so we can't override it here.
  2296. # Instead set BOOTSTRAPPING_OSRELDATE so that the value 0 is set ${BSARGS}
  2297. BOOTSTRAPPING_OSRELDATE:= 0
  2298. .endif
  2299. .if ${MK_GAMES} != "no"
  2300. _strfile= usr.bin/fortune/strfile
  2301. .endif
  2302. # vtfontcvt is used to build font files for loader and to generate
  2303. # C source for loader built in font (8x16.c).
  2304. _vtfontcvt= usr.bin/vtfontcvt
  2305. # zic is used to compile timezone data
  2306. .if ${MK_ZONEINFO} != "no"
  2307. _zic= usr.sbin/zic
  2308. .endif
  2309. # If we are not building the bootstrap because BOOTSTRAPPING is sufficient
  2310. # we symlink the host version to $WORLDTMP instead. By doing this we can also
  2311. # detect when a bootstrap tool is being used without the required MK_FOO.
  2312. # If you add a new bootstrap tool where we could also use the host version,
  2313. # please ensure that you also add a .else case where you add the tool to the
  2314. # _bootstrap_tools_links variable.
  2315. .if ${BOOTSTRAPPING} < 1000033
  2316. # Note: lex needs m4 to build but m4 also depends on lex (which needs m4 to
  2317. # generate any files). To fix this cyclic dependency we can build a bootstrap
  2318. # version of m4 (with pre-generated files) then use that to build the real m4.
  2319. # We can't simply use the host m4 since e.g. the macOS version does not accept
  2320. # the flags that are passed by lex.
  2321. # For lex we also use the pre-gerated files since we would otherwise need to
  2322. # build awk and sed first (which need lex to build)
  2323. # TODO: add a _bootstrap_lex and then build the real lex afterwards
  2324. _lex= usr.bin/lex
  2325. _m4= tools/build/bootstrap-m4 usr.bin/m4
  2326. ${_bt}-tools/build/bootstrap-m4: ${_bt}-usr.bin/lex ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc
  2327. ${_bt}-usr.bin/m4: ${_bt}-lib/libopenbsd ${_bt}-usr.bin/yacc ${_bt}-usr.bin/lex ${_bt}-tools/build/bootstrap-m4
  2328. _bt_m4_depend=${_bt}-usr.bin/m4
  2329. _bt_lex_depend=${_bt}-usr.bin/lex ${_bt_m4_depend}
  2330. .else
  2331. _bootstrap_tools_links+=m4 lex
  2332. .endif
  2333. # ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
  2334. # r296685 fix cross-endian objcopy
  2335. # r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2.
  2336. # r334881 added libdwarf constants used by ctfconvert.
  2337. # r338478 fixed a crash in objcopy for mips64el objects
  2338. # r339083 libelf: correct mips64el test to use ELF header
  2339. # r348347 Add missing powerpc64 relocation support to libdwarf
  2340. .if ${BOOTSTRAPPING} < 1300030
  2341. _elftoolchain_libs= lib/libelf lib/libdwarf lib/libzstd
  2342. ${_bt}-lib/libelf: ${_bt_m4_depend}
  2343. ${_bt}-lib/libdwarf: ${_bt_m4_depend}
  2344. _bt_libelf_depend=${_bt}-lib/libelf
  2345. .endif
  2346. _kldxref= usr.sbin/kldxref
  2347. ${_bt}-usr.sbin/kldxref: ${_bt_libelf_depend}
  2348. # flua is required to regenerate syscall files. It first appeared during the
  2349. # 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
  2350. # branches.
  2351. .if ${BOOTSTRAPPING} < 1300059
  2352. ${_bt}-libexec/flua: ${_bt}-lib/liblua
  2353. _flua= lib/liblua libexec/flua
  2354. .endif
  2355. # r245440 mtree -N support added
  2356. # r313404 requires sha384.h for libnetbsd, added to libmd in r292782
  2357. .if ${BOOTSTRAPPING} < 1100093
  2358. _libnetbsd= lib/libnetbsd
  2359. _nmtree= lib/libmd \
  2360. usr.sbin/nmtree
  2361. ${_bt}-lib/libnetbsd: ${_bt}-lib/libmd
  2362. ${_bt}-usr.sbin/nmtree: ${_bt}-lib/libnetbsd
  2363. .else
  2364. _bootstrap_tools_links+=mtree
  2365. .endif
  2366. # r246097: log addition login.conf.db, passwd, pwd.db, and spwd.db with cat -l
  2367. .if ${BOOTSTRAPPING} < 1000027
  2368. _cat= bin/cat
  2369. .else
  2370. _bootstrap_tools_links+=cat
  2371. .endif
  2372. # r277259 crunchide: Correct 64-bit section header offset
  2373. # r281674 crunchide: always include both 32- and 64-bit ELF support
  2374. .if ${BOOTSTRAPPING} < 1100078
  2375. _crunchide= usr.sbin/crunch/crunchide
  2376. .else
  2377. _bootstrap_tools_links+=crunchide
  2378. .endif
  2379. # 1400052, 1300526, 1203507: Removed -dc from linker invocation
  2380. .if ${BOOTSTRAPPING} < 1203507 || \
  2381. (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300526) || \
  2382. (${BOOTSTRAPPING} > 1400000 && ${BOOTSTRAPPING} < 1400052)
  2383. _crunchgen= usr.sbin/crunch/crunchgen
  2384. .else
  2385. _bootstrap_tools_links+=crunchgen
  2386. .endif
  2387. # The ATKBD_DFLT_KEYMAP, UKBD_DFLT_KEYMAP and KBDMUX_DFLT_KEYMAP kernel options
  2388. # require kbdcontrol. Note that, even on FreeBSD, the host will lack kbdcontrol
  2389. # if built with WITHOUT_LEGACY_CONSOLE.
  2390. .if defined(BOOTSTRAP_ALL_TOOLS) || !exists(/usr/sbin/kbdcontrol)
  2391. _kbdcontrol= usr.sbin/kbdcontrol
  2392. .else
  2393. _bootstrap_tools_links+=kbdcontrol
  2394. .endif
  2395. .if ${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no"
  2396. _etdump= usr.bin/etdump
  2397. _makefs= usr.sbin/makefs
  2398. _libnetbsd= lib/libnetbsd
  2399. ${_bt}-usr.sbin/makefs: ${_bt}-lib/libnetbsd
  2400. .if defined(BOOTSTRAP_ALL_TOOLS)
  2401. _libsbuf= lib/libsbuf
  2402. ${_bt}-usr.sbin/makefs: ${_bt}-lib/libsbuf
  2403. .endif
  2404. .endif
  2405. # 1300102: VHDX support
  2406. .if ${BOOTSTRAPPING} < 1201520 || \
  2407. (${BOOTSTRAPPING} > 1300000 && ${BOOTSTRAPPING} < 1300102) || \
  2408. ${MK_DISK_IMAGE_TOOLS_BOOTSTRAP} != "no"
  2409. _mkimg= usr.bin/mkimg
  2410. .else
  2411. _bootstrap_tools_links+=mkimg
  2412. .endif
  2413. _yacc= usr.bin/yacc
  2414. .if ${MK_BSNMP} != "no"
  2415. _gensnmptree= usr.sbin/bsnmpd/gensnmptree
  2416. .endif
  2417. _migcom= usr.bin/migcom
  2418. gnu/lib/libobjc2__L: usr.bin/migcom__L
  2419. # We need to build tblgen when we're building clang or lld, either as
  2420. # bootstrap tools, or as the part of the normal build.
  2421. # llvm-tblgen is also needed for various llvm binutils (e.g. objcopy).
  2422. .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
  2423. ${MK_LLD_BOOTSTRAP} != "no" || ${MK_LLD} != "no" || \
  2424. ${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS} != "no"
  2425. _clang_tblgen= \
  2426. lib/clang/libllvmminimal \
  2427. usr.bin/clang/llvm-min-tblgen \
  2428. usr.bin/clang/llvm-tblgen
  2429. .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
  2430. ${MK_LLDB} != "no"
  2431. _clang_tblgen+= lib/clang/libclangminimal
  2432. _clang_tblgen+= usr.bin/clang/clang-tblgen
  2433. .endif
  2434. .if ${MK_LLDB} != "no"
  2435. _clang_tblgen+= usr.bin/clang/lldb-tblgen
  2436. .endif
  2437. ${_bt}-usr.bin/clang/clang-tblgen: ${_bt}-lib/clang/libllvmminimal
  2438. ${_bt}-usr.bin/clang/lldb-tblgen: ${_bt}-lib/clang/libllvmminimal
  2439. ${_bt}-usr.bin/clang/llvm-min-tblgen: ${_bt}-lib/clang/libllvmminimal
  2440. ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/clang/libllvmminimal
  2441. ${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-usr.bin/clang/llvm-min-tblgen
  2442. .endif
  2443. # C.UTF-8 is always built in share/ctypes and we need localedef for that.
  2444. _localedef= usr.bin/localedef
  2445. ${_bt}-usr.bin/localedef: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
  2446. .if ${MK_ICONV} != "no"
  2447. _mkesdb= usr.bin/mkesdb
  2448. _mkcsmapper= usr.bin/mkcsmapper
  2449. ${_bt}-usr.bin/mkesdb: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
  2450. ${_bt}-usr.bin/mkcsmapper: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
  2451. .endif
  2452. .if ${MK_KERBEROS} != "no"
  2453. _kerberos5_bootstrap_tools= \
  2454. kerberos5/tools/make-roken \
  2455. kerberos5/lib/libroken \
  2456. kerberos5/lib/libvers \
  2457. kerberos5/tools/asn1_compile \
  2458. kerberos5/tools/slc \
  2459. usr.bin/compile_et
  2460. .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
  2461. .for _tool in ${_kerberos5_bootstrap_tools}
  2462. ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}
  2463. .endfor
  2464. .endif
  2465. ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
  2466. # The tools listed in _basic_bootstrap_tools will generally not be
  2467. # bootstrapped unless BOOTSTRAP_ALL_TOOL is set. However, when building on a
  2468. # Linux or MacOS host the host versions are incompatible so we need to build
  2469. # them from the source tree. Usually the link name will be the same as the subdir,
  2470. # but some directories such as grep or test install multiple binaries. In that
  2471. # case we use the _basic_bootstrap_tools_multilink variable which is a list of
  2472. # subdirectory and comma-separated list of files.
  2473. _basic_bootstrap_tools_multilink=usr.bin/grep grep,egrep,fgrep
  2474. _basic_bootstrap_tools_multilink+=bin/test test,[
  2475. # bootstrap tools needed by buildworld:
  2476. _basic_bootstrap_tools+=usr.bin/cut bin/expr usr.bin/gencat usr.bin/join \
  2477. usr.bin/mktemp bin/realpath bin/rmdir usr.bin/sed usr.bin/sort \
  2478. usr.bin/truncate usr.bin/tsort
  2479. # Some build scripts use nawk instead of awk (this happens at least in
  2480. # cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh) so we need both awk
  2481. # and nawk in ${WORLDTMP}/legacy/bin.
  2482. _basic_bootstrap_tools_multilink+=usr.bin/awk awk,nawk
  2483. # file2c is required for building usr.sbin/config:
  2484. _basic_bootstrap_tools+=usr.bin/file2c
  2485. # uuencode/uudecode required for share/tabset
  2486. _basic_bootstrap_tools_multilink+=usr.bin/bintrans uuencode,uudecode
  2487. # xargs is required by mkioctls
  2488. _basic_bootstrap_tools+=usr.bin/xargs
  2489. # cap_mkdb is required for share/termcap:
  2490. _basic_bootstrap_tools+=usr.bin/cap_mkdb
  2491. # services_mkdb/pwd_mkdb are required for installworld:
  2492. _basic_bootstrap_tools+=usr.sbin/services_mkdb usr.sbin/pwd_mkdb
  2493. # ldd is required for installcheck (TODO: just always use /usr/bin/ldd instead?)
  2494. .if !defined(CROSSBUILD_HOST)
  2495. # ldd is only needed for updating the running system so we don't need to
  2496. # bootstrap ldd on non-FreeBSD systems
  2497. _basic_bootstrap_tools+=usr.bin/ldd
  2498. .endif
  2499. # sysctl/chflags are required for installkernel:
  2500. .if !defined(CROSSBUILD_HOST)
  2501. _basic_bootstrap_tools+=bin/chflags
  2502. # Note: sysctl does not bootstrap on FreeBSD < 13 anymore, but that doesn't
  2503. # matter since we don't need any of the new features for the build.
  2504. _bootstrap_tools_links+=sysctl
  2505. .else
  2506. # When building on non-FreeBSD, install a fake chflags instead since the
  2507. # version from the source tree cannot work. We also don't need sysctl since we
  2508. # are install with -DNO_ROOT.
  2509. _other_bootstrap_tools+=tools/build/cross-build/fake_chflags
  2510. .endif
  2511. # mkfifo is used by sys/conf/newvers.sh
  2512. _basic_bootstrap_tools+=usr.bin/mkfifo
  2513. # jot is needed for the mkimg tests
  2514. _basic_bootstrap_tools+=usr.bin/jot
  2515. .if defined(BOOTSTRAP_ALL_TOOLS)
  2516. # sha256 and sha512 are used by release/ (and possibly others)
  2517. _basic_bootstrap_tools+=sbin/md5
  2518. .endif
  2519. # tzsetup is needed as an install tool
  2520. .if ${MK_ZONEINFO} != "no"
  2521. _basic_bootstrap_tools+=usr.sbin/tzsetup
  2522. .endif
  2523. .if defined(BOOTSTRAP_ALL_TOOLS)
  2524. _other_bootstrap_tools+=${_basic_bootstrap_tools}
  2525. .for _subdir _links in ${_basic_bootstrap_tools_multilink}
  2526. _other_bootstrap_tools+=${_subdir}
  2527. .endfor
  2528. ${_bt}-usr.bin/awk: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
  2529. ${_bt}-bin/expr: ${_bt_lex_depend} ${_bt}-usr.bin/yacc
  2530. # If we are bootstrapping file2c, we have to build it before config:
  2531. ${_bt}-usr.sbin/config: ${_bt}-usr.bin/file2c ${_bt_lex_depend}
  2532. # Note: no symlink to make/bmake in the !BOOTSTRAP_ALL_TOOLS case here since
  2533. # the links to make/bmake make links will have already have been created in the
  2534. # `make legacy` step. Not adding a link to make is important on non-FreeBSD
  2535. # since "make" will usually point to GNU make there.
  2536. _other_bootstrap_tools+=usr.bin/bmake
  2537. # Avoid dependency on host bz2 headers:
  2538. _other_bootstrap_tools+=lib/libbz2
  2539. ${_bt}-usr.bin/grep: ${_bt}-lib/libbz2
  2540. # libdwarf depends on libz
  2541. _other_bootstrap_tools+=lib/libz
  2542. ${_bt}-lib/libdwarf: ${_bt}-lib/libz
  2543. # libroken depends on libcrypt
  2544. _other_bootstrap_tools+=lib/libcrypt
  2545. ${_bt}-lib/libroken: ${_bt}-lib/libcrypt
  2546. .else
  2547. # All tools in _basic_bootstrap_tools have the same name as the subdirectory
  2548. # so we can use :T to get the name of the symlinks that we need to create.
  2549. _bootstrap_tools_links+=${_basic_bootstrap_tools:T}
  2550. .for _subdir _links in ${_basic_bootstrap_tools_multilink}
  2551. _bootstrap_tools_links+=${_links:S/,/ /g}
  2552. .endfor
  2553. .endif # defined(BOOTSTRAP_ALL_TOOLS)
  2554. # Link the tools that we need for building but don't need to bootstrap because
  2555. # the host version is known to be compatible into ${WORLDTMP}/legacy
  2556. # We do this before building any of the bootstrap tools in case they depend on
  2557. # the presence of any of the links (e.g. as m4/lex/awk)
  2558. ${_bt}-links: .PHONY
  2559. .for _tool in ${_bootstrap_tools_links}
  2560. ${_bt}-link-${_tool}: .PHONY
  2561. @rm -f "${WORLDTMP}/legacy/bin/${_tool}"; \
  2562. source_path=`which ${_tool}`; \
  2563. if [ ! -e "$${source_path}" ] ; then \
  2564. echo "Cannot find host tool '${_tool}'"; false; \
  2565. fi; \
  2566. cp -pf "$${source_path}" "${WORLDTMP}/legacy/bin/${_tool}"
  2567. ${_bt}-links: ${_bt}-link-${_tool}
  2568. .endfor
  2569. bootstrap-tools: ${_bt}-links .PHONY
  2570. # Please document (add comment) why something is in 'bootstrap-tools'.
  2571. # Try to bound the building of the bootstrap-tool to just the
  2572. # FreeBSD versions that need the tool built at this stage of the build.
  2573. .for _tool in \
  2574. ${_clang_tblgen} \
  2575. ${_kerberos5_bootstrap_tools} \
  2576. ${_strfile} \
  2577. usr.bin/dtc \
  2578. ${_cat} \
  2579. ${_kbdcontrol} \
  2580. ${_elftoolchain_libs} \
  2581. ${_kldxref} \
  2582. lib/libopenbsd \
  2583. usr.bin/mandoc \
  2584. usr.bin/rpcgen \
  2585. ${_yacc} \
  2586. ${_m4} \
  2587. ${_lex} \
  2588. ${_other_bootstrap_tools} \
  2589. usr.bin/xinstall \
  2590. ${_gensnmptree} \
  2591. usr.sbin/config \
  2592. ${_flua} \
  2593. ${_crunchide} \
  2594. ${_crunchgen} \
  2595. ${_etdump} \
  2596. ${_libnetbsd} \
  2597. ${_libsbuf} \
  2598. ${_makefs} \
  2599. ${_mkimg} \
  2600. ${_nmtree} \
  2601. ${_vtfontcvt} \
  2602. ${_localedef} \
  2603. ${_mkcsmapper} \
  2604. ${_mkesdb} \
  2605. ${_migcom} \
  2606. ${_zic} \
  2607. gnu/usr.bin/gmake \
  2608. usr.bin/perl5 \
  2609. usr.bin/nasm \
  2610. ${LOCAL_BSTOOL_DIRS}
  2611. ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
  2612. ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
  2613. cd ${.CURDIR}/${_tool}; \
  2614. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  2615. if [ "${_tool}" = "usr.bin/lex" ]; then \
  2616. ${MAKE} DIRPRFX=${_tool}/ bootstrap; \
  2617. fi; \
  2618. ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy all; \
  2619. ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
  2620. bootstrap-tools: ${_bt}-${_tool}
  2621. .endfor
  2622. .if target(${_bt}-lib/libmd)
  2623. # If we are bootstrapping libmd (e.g. when building on macOS/Linux) add the
  2624. # necessary dependencies:
  2625. ${_bt}-usr.bin/sort: ${_bt}-lib/libmd
  2626. ${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd
  2627. ${_bt}-sbin/md5: ${_bt}-lib/libmd
  2628. .endif
  2629. # Ensure we build gmake & perl before nasm
  2630. .ORDER: _bootstrap-tools-gnu/usr.bin/gmake _bootstrap-tools-usr.bin/perl5 _bootstrap-tools-usr.bin/nasm
  2631. #
  2632. # build-tools: Build special purpose build tools
  2633. #
  2634. .if !defined(NO_SHARE) && ${MK_SYSCONS} != "no"
  2635. _share= share/syscons/scrnmaps
  2636. .endif
  2637. .if ${MK_RESCUE} != "no"
  2638. # rescue includes programs that have build-tools targets
  2639. _rescue=rescue/rescue
  2640. .endif
  2641. .if ${MK_TCSH} != "no"
  2642. _tcsh=bin/csh
  2643. .endif
  2644. .if ${MK_FILE} != "no"
  2645. _libmagic=lib/libmagic
  2646. .endif
  2647. .if ${MK_PMC} != "no"
  2648. _jevents=lib/libpmc/pmu-events
  2649. .endif
  2650. # kernel-toolchain skips _cleanobj, so handle cleaning up previous
  2651. # build-tools directories if needed.
  2652. .if ${MK_CLEAN} == "yes" && make(kernel-toolchain)
  2653. _bt_clean= ${CLEANDIR}
  2654. .endif
  2655. .for _tool in \
  2656. ${_tcsh} \
  2657. bin/sh \
  2658. ${LOCAL_TOOL_DIRS} \
  2659. ${_jevents} \
  2660. lib/ncurses/tinfo \
  2661. ${_rescue} \
  2662. ${_share} \
  2663. usr.bin/awk \
  2664. ${_libmagic} \
  2665. usr.bin/cmake \
  2666. usr.bin/vi/catalog
  2667. build-tools_${_tool}: .PHONY
  2668. ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \
  2669. cd ${.CURDIR}/${_tool}; \
  2670. if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \
  2671. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  2672. ${MAKE} DIRPRFX=${_tool}/ build-tools
  2673. build-tools: build-tools_${_tool}
  2674. .endfor
  2675. #
  2676. # kernel-tools: Build kernel-building tools
  2677. #
  2678. kernel-tools: .PHONY
  2679. mkdir -p ${WORLDTMP}/usr
  2680. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  2681. -p ${WORLDTMP}/usr >/dev/null
  2682. #
  2683. # cross-tools: All the tools needed to build the rest of the system after
  2684. # we get done with the earlier stages. It is the last set of tools needed
  2685. # to begin building the target binaries.
  2686. #
  2687. .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BUILD_WITH_STRICT_TMPPATH} != 0
  2688. .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
  2689. _btxld= usr.sbin/btxld
  2690. .endif
  2691. .endif
  2692. # Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
  2693. # resulting from missing bug fixes or ELF Toolchain updates.
  2694. .if ${MK_CDDL} != "no"
  2695. _dtrace_tools= cddl/lib/libctf cddl/lib/libspl cddl/usr.bin/ctfconvert \
  2696. cddl/usr.bin/ctfmerge
  2697. .endif
  2698. # If we're given an XAS, don't build binutils.
  2699. .if ${XAS:M/*} == ""
  2700. .if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
  2701. _elftctools= lib/libelftc \
  2702. lib/libpe \
  2703. usr.bin/elfctl \
  2704. usr.bin/elfdump \
  2705. usr.bin/objcopy \
  2706. usr.bin/nm \
  2707. usr.bin/size \
  2708. usr.bin/strings
  2709. # These are not required by the build, but can be useful for developers who
  2710. # cross-build on a FreeBSD 10 host:
  2711. _elftctools+= usr.bin/addr2line
  2712. .endif
  2713. .elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
  2714. # If cross-building with an external binutils we still need to build strip for
  2715. # the target (for at least crunchide).
  2716. _elftctools= lib/libelftc \
  2717. lib/libpe \
  2718. usr.bin/elfctl \
  2719. usr.bin/elfdump \
  2720. usr.bin/objcopy
  2721. .endif
  2722. .if ${MK_CLANG_BOOTSTRAP} != "no"
  2723. _clang= usr.bin/clang
  2724. .endif
  2725. .if ${MK_LLD_BOOTSTRAP} != "no"
  2726. _lld= usr.bin/clang/lld
  2727. .endif
  2728. .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no"
  2729. _clang_libs= lib/clang
  2730. .endif
  2731. .if ${MK_USB} != "no"
  2732. _usb_tools= stand/usb/tools
  2733. .endif
  2734. .if ${BUILD_WITH_STRICT_TMPPATH} != 0 || defined(BOOTSTRAP_ALL_TOOLS)
  2735. _ar=usr.bin/ar
  2736. .endif
  2737. cross-tools: .MAKE .PHONY
  2738. .for _tool in \
  2739. ${LOCAL_XTOOL_DIRS} \
  2740. ${_ar} \
  2741. ${_clang_libs} \
  2742. ${_clang} \
  2743. ${_lld} \
  2744. ${_elftctools} \
  2745. ${_dtrace_tools} \
  2746. ${_btxld} \
  2747. ${_usb_tools}
  2748. ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
  2749. cd ${.CURDIR}/${_tool}; \
  2750. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
  2751. ${MAKE} DIRPRFX=${_tool}/ all; \
  2752. ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install
  2753. .endfor
  2754. #
  2755. # native-xtools is the current target for qemu-user cross builds of ports
  2756. # via poudriere and the imgact_binmisc kernel module.
  2757. # This target merely builds a toolchan/sysroot, then builds the tools it wants
  2758. # with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain
  2759. # already built. It then installs the static tools to NXBDESTDIR for Poudriere
  2760. # to pickup.
  2761. #
  2762. NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/
  2763. NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH}
  2764. NXTP?= /nxb-bin
  2765. .if ${NXTP:N/*}
  2766. .error NXTP variable should be an absolute path
  2767. .endif
  2768. NXBDESTDIR?= ${DESTDIR}${NXTP}
  2769. # This is the list of tools to be built/installed as static and where
  2770. # appropriate to build for the given TARGET.TARGET_ARCH.
  2771. NXBDIRS+= \
  2772. bin/cat \
  2773. bin/chmod \
  2774. bin/cp \
  2775. ${_tcsh} \
  2776. bin/echo \
  2777. bin/expr \
  2778. bin/hostname \
  2779. bin/ln \
  2780. bin/ls \
  2781. bin/mkdir \
  2782. bin/mv \
  2783. bin/ps \
  2784. bin/realpath \
  2785. bin/rm \
  2786. bin/rmdir \
  2787. bin/sh \
  2788. bin/sleep \
  2789. sbin/md5 \
  2790. sbin/sysctl \
  2791. usr.bin/addr2line \
  2792. usr.bin/ar \
  2793. usr.bin/awk \
  2794. usr.bin/basename \
  2795. usr.bin/bmake \
  2796. usr.bin/bzip2 \
  2797. usr.bin/cmp \
  2798. usr.bin/diff \
  2799. usr.bin/dirname \
  2800. usr.bin/objcopy \
  2801. usr.bin/env \
  2802. usr.bin/fetch \
  2803. usr.bin/find \
  2804. usr.bin/grep \
  2805. usr.bin/gzip \
  2806. usr.bin/head \
  2807. usr.bin/id \
  2808. usr.bin/lex \
  2809. usr.bin/limits \
  2810. usr.bin/mandoc \
  2811. usr.bin/mktemp \
  2812. usr.bin/mt \
  2813. usr.bin/nm \
  2814. usr.bin/patch \
  2815. usr.bin/readelf \
  2816. usr.bin/sed \
  2817. usr.bin/size \
  2818. usr.bin/sort \
  2819. usr.bin/strings \
  2820. usr.bin/tar \
  2821. usr.bin/touch \
  2822. usr.bin/tr \
  2823. usr.bin/true \
  2824. usr.bin/uniq \
  2825. usr.bin/unzip \
  2826. usr.bin/wc \
  2827. usr.bin/xargs \
  2828. usr.bin/xinstall \
  2829. usr.bin/xz \
  2830. usr.bin/yacc \
  2831. usr.sbin/chown
  2832. SUBDIR_DEPEND_usr.bin/clang= lib/clang
  2833. .if ${MK_CLANG} != "no"
  2834. NXBDIRS+= lib/clang
  2835. NXBDIRS+= usr.bin/clang
  2836. .endif
  2837. # XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs
  2838. # to be evaluated after NXBDIRS is set.
  2839. .if make(install) && !empty(SUBDIR_OVERRIDE)
  2840. SUBDIR= ${SUBDIR_OVERRIDE}
  2841. .endif
  2842. NXBMAKEARGS+= \
  2843. OBJTOP=${NXBOBJTOP:Q} \
  2844. OBJROOT=${NXBOBJROOT:Q} \
  2845. -DNO_SHARED \
  2846. -DNO_CPU_CFLAGS \
  2847. -DNO_PIC \
  2848. MK_CASPER=no \
  2849. MK_CLANG_EXTRAS=no \
  2850. MK_CLANG_FORMAT=no \
  2851. MK_CLANG_FULL=no \
  2852. MK_CTF=no \
  2853. MK_DEBUG_FILES=no \
  2854. MK_HTML=no \
  2855. MK_LLDB=no \
  2856. MK_MAN=no \
  2857. MK_MAN_UTILS=yes \
  2858. MK_OFED=no \
  2859. MK_OPENSSH=no \
  2860. MK_PROFILE=no \
  2861. MK_RETPOLINE=no \
  2862. MK_SENDMAIL=no \
  2863. MK_SSP=no \
  2864. MK_TESTS=no \
  2865. MK_WERROR=no \
  2866. MK_ZFS=no
  2867. NXBMAKEENV+= \
  2868. MAKEOBJDIRPREFIX=
  2869. # This should match all of the knobs in lib/Makefile that it takes to avoid
  2870. # descending into lib/clang!
  2871. NXBTNOTOOLS= MK_CLANG=no MK_LLD=no MK_LLDB=no MK_LLVM_BINUTILS=no
  2872. .if make(native-xtools*) && \
  2873. (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH))
  2874. .error Missing NXB_TARGET / NXB_TARGET_ARCH
  2875. .endif
  2876. # For 'toolchain' we want to produce native binaries that themselves generate
  2877. # native binaries.
  2878. NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \
  2879. TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH}
  2880. # For 'everything' we want to produce native binaries (hence -target to
  2881. # be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries.
  2882. # TARGET/TARGET_ARCH are still passed along from user.
  2883. #
  2884. # Use the toolchain we create as an external toolchain.
  2885. .if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*}
  2886. NXBMAKE+= XCC="${XCC}" \
  2887. XCXX="${XCXX}" \
  2888. XCPP="${XCPP}"
  2889. .else
  2890. NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \
  2891. XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \
  2892. XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp"
  2893. .endif
  2894. NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \
  2895. MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
  2896. TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \
  2897. TARGET_TRIPLE=${MACHINE_TRIPLE:Q}
  2898. # NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to
  2899. # invoke a sub-make to reevaluate MK_CLANG, etc, for NXBDIRS.
  2900. NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}'
  2901. # Need to avoid the -isystem logic when using clang as an external toolchain
  2902. # even if the TARGET being built for wants GCC.
  2903. NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}'
  2904. native-xtools: .PHONY
  2905. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj
  2906. # Build the bootstrap/host/cross tools that produce native binaries
  2907. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain
  2908. # Populate includes/libraries sysroot that produce native binaries.
  2909. # This is split out from 'toolchain' above mostly so that target LLVM
  2910. # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without
  2911. # polluting the cross-compiler build. The LLVM libs are skipped
  2912. # here to avoid the problem but are kept in 'toolchain' so that
  2913. # needed build tools are built.
  2914. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes ${NXBTNOTOOLS}
  2915. ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries ${NXBTNOTOOLS}
  2916. .if !defined(NO_OBJWALK)
  2917. ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj
  2918. .endif
  2919. ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything
  2920. @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR"
  2921. native-xtools-install: .PHONY
  2922. mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr
  2923. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  2924. -p ${NXBDESTDIR}/usr >/dev/null
  2925. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  2926. -p ${NXBDESTDIR}/usr/include >/dev/null
  2927. .for d in ${LIBCOMPAT_INCLUDE_DIRS}
  2928. mkdir -p ${NXBDESTDIR}/usr/include/${d}
  2929. .endfor
  2930. ${_+_}cd ${.CURDIR}; ${NXBMAKE} \
  2931. DESTDIR=${NXBDESTDIR} \
  2932. -DNO_ROOT \
  2933. install
  2934. #
  2935. # hierarchy - ensure that all the needed directories are present
  2936. #
  2937. hierarchy hier: .MAKE .PHONY
  2938. ${_+_}cd ${.CURDIR}/etc; ${HMAKE} distrib-dirs
  2939. #
  2940. # libraries - build all libraries, and install them under ${DESTDIR}.
  2941. #
  2942. # The list of libraries with dependents (${_prebuild_libs}) and their
  2943. # interdependencies (__L) are built automatically by the
  2944. # ${.CURDIR}/tools/make_libdeps.sh script.
  2945. #
  2946. libraries: .MAKE .PHONY
  2947. ${_+_}cd ${.CURDIR}; \
  2948. ${MAKE} -f Makefile.inc1 _prereq_libs; \
  2949. ${MAKE} -f Makefile.inc1 _startup_libs; \
  2950. ${MAKE} -f Makefile.inc1 _prebuild_libs -DLIBCRYPTO_WITHOUT_SUBDIRS; \
  2951. ${MAKE} -f Makefile.inc1 _generic_libs
  2952. #
  2953. # static libgcc.a prerequisite for shared libc
  2954. #
  2955. _prereq_libs= lib/libcompiler_rt
  2956. .if ${MK_SSP} != "no"
  2957. _prereq_libs+= lib/libssp_nonshared
  2958. .endif
  2959. .if ${MK_ASAN} != "no"
  2960. _prereq_libs+= lib/libclang_rt/asan
  2961. _prereq_libs+= lib/libclang_rt/asan-preinit
  2962. _prereq_libs+= lib/libclang_rt/asan_cxx
  2963. _prereq_libs+= lib/libclang_rt/asan_static
  2964. .endif
  2965. .if ${MK_UBSAN} != "no"
  2966. _prereq_libs+= lib/libclang_rt/ubsan_minimal
  2967. _prereq_libs+= lib/libclang_rt/ubsan_standalone
  2968. _prereq_libs+= lib/libclang_rt/ubsan_standalone_cxx
  2969. .endif
  2970. # These dependencies are not automatically generated:
  2971. #
  2972. # lib/csu and lib/libc must be built before
  2973. # all shared libraries for ELF.
  2974. #
  2975. _startup_libs= lib/csu
  2976. _startup_libs+= lib/libc
  2977. _startup_libs+= lib/libc_nonshared
  2978. _startup_libs+= lib/libcxxrt
  2979. _startup_libs+= lib/libsys
  2980. _prereq_libs+= lib/libgcc_eh lib/libgcc_s
  2981. _startup_libs+= lib/libgcc_eh lib/libgcc_s
  2982. lib/libc__L: lib/libsys__L
  2983. lib/libgcc_s__L: lib/libc__L
  2984. lib/libgcc_s__L: lib/libc_nonshared__L
  2985. lib/libcxxrt__L: lib/libgcc_s__L
  2986. _prebuild_libs= ${_kerberos5_lib_libasn1} \
  2987. ${_kerberos5_lib_libhdb} \
  2988. ${_kerberos5_lib_libheimbase} \
  2989. ${_kerberos5_lib_libheimntlm} \
  2990. ${_libsqlite3} \
  2991. ${_kerberos5_lib_libheimipcc} \
  2992. ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
  2993. ${_kerberos5_lib_libroken} \
  2994. ${_kerberos5_lib_libwind} \
  2995. lib/libbz2 ${_libcom_err} lib/libcrypt \
  2996. lib/libc++ \
  2997. lib/libelf lib/libexpat \
  2998. lib/libfigpar \
  2999. ${_lib_libgssapi} \
  3000. lib/libjail \
  3001. lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
  3002. lib/libzstd \
  3003. ${_lib_casper} \
  3004. lib/ncurses/tinfo \
  3005. lib/ncurses/ncurses \
  3006. lib/libpam/libpam lib/libthr \
  3007. ${_lib_libradius} lib/libsbuf lib/libtacplus \
  3008. lib/libgeom \
  3009. ${_lib_librt} \
  3010. ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
  3011. ${_cddl_lib_libuutil} \
  3012. ${_cddl_lib_libavl} \
  3013. ${_cddl_lib_libicp} \
  3014. ${_cddl_lib_libicp_rescue} \
  3015. ${_cddl_lib_libspl} \
  3016. ${_cddl_lib_libtpool} \
  3017. ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
  3018. ${_cddl_lib_libzutil} \
  3019. ${_cddl_lib_libctf} ${_cddl_lib_libzfsbootenv} \
  3020. lib/libufs \
  3021. lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
  3022. lib/libxo \
  3023. ${_secure_lib_libcrypto} ${_secure_lib_libssl} \
  3024. ${_lib_libldns} ${_secure_lib_libssh}
  3025. .if ${MK_DIALOG} != "no"
  3026. _prebuild_libs+= gnu/lib/libdialog
  3027. gnu/lib/libdialog__L: lib/msun__L lib/ncurses/tinfo__L lib/ncurses/ncurses__L
  3028. .endif
  3029. .if ${MK_GOOGLETEST} != "no"
  3030. _prebuild_libs+= lib/libregex
  3031. .endif
  3032. lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
  3033. lib/libkvm__L: lib/libelf__L
  3034. .if ${MK_RADIUS_SUPPORT} != "no"
  3035. _lib_libradius= lib/libradius
  3036. .endif
  3037. lib/ncurses/ncurses__L: lib/ncurses/tinfo__L
  3038. .if ${MK_OFED} != "no"
  3039. _prebuild_libs+= \
  3040. lib/ofed/libibverbs \
  3041. lib/ofed/libibmad \
  3042. lib/ofed/libibumad \
  3043. lib/ofed/complib \
  3044. lib/ofed/libmlx5
  3045. lib/ofed/libibmad__L: lib/ofed/libibumad__L
  3046. lib/ofed/complib__L: lib/libthr__L
  3047. lib/ofed/libmlx5__L: lib/ofed/libibverbs__L lib/libthr__L
  3048. .endif
  3049. .if ${MK_CASPER} != "no"
  3050. _lib_casper= lib/libcasper
  3051. .endif
  3052. lib/libpjdlog__L: lib/libutil__L
  3053. lib/libcasper__L: lib/libnv__L
  3054. lib/liblzma__L: lib/libmd__L lib/libthr__L
  3055. lib/libzstd__L: lib/libthr__L
  3056. lib/librt__L: lib/libthr__L
  3057. _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib}
  3058. .if ${MK_IPFILTER} != "no"
  3059. _generic_libs+= sbin/ipf/libipf
  3060. .endif
  3061. .for _DIR in ${LOCAL_LIB_DIRS}
  3062. .if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile))
  3063. _generic_libs+= ${_DIR}
  3064. .endif
  3065. .endfor
  3066. lib/libtacplus__L: lib/libmd__L lib/libpam/libpam__L
  3067. lib/libxo__L: lib/libutil__L
  3068. .if ${MK_CDDL} != "no"
  3069. _cddl_lib_libumem= cddl/lib/libumem
  3070. _cddl_lib_libnvpair= cddl/lib/libnvpair
  3071. _cddl_lib_libavl= cddl/lib/libavl
  3072. _cddl_lib_libuutil= cddl/lib/libuutil
  3073. _cddl_lib_libspl= cddl/lib/libspl
  3074. cddl/lib/libavl__L: cddl/lib/libspl__L
  3075. cddl/lib/libnvpair__L: cddl/lib/libspl__L
  3076. cddl/lib/libuutil__L: cddl/lib/libavl__L cddl/lib/libspl__L
  3077. .if ${MK_ZFS} != "no"
  3078. _lib_librt= lib/librt
  3079. _cddl_lib_libicp= cddl/lib/libicp
  3080. _cddl_lib_libicp_rescue= cddl/lib/libicp_rescue
  3081. _cddl_lib_libtpool= cddl/lib/libtpool
  3082. _cddl_lib_libzutil= cddl/lib/libzutil
  3083. _cddl_lib_libzfs_core= cddl/lib/libzfs_core
  3084. _cddl_lib_libzfs= cddl/lib/libzfs
  3085. _cddl_lib_libzfsbootenv= cddl/lib/libzfsbootenv
  3086. cddl/lib/libtpool__L: cddl/lib/libspl__L
  3087. cddl/lib/libzutil__L: cddl/lib/libavl__L lib/libgeom__L lib/msun__L cddl/lib/libtpool__L
  3088. cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L cddl/lib/libspl__L cddl/lib/libzutil__L
  3089. cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L lib/librt__L
  3090. cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
  3091. cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
  3092. cddl/lib/libzfs__L: cddl/lib/libnvpair__L cddl/lib/libzutil__L
  3093. cddl/lib/libzfs__L: secure/lib/libcrypto__L
  3094. cddl/lib/libzfsbootenv__L: cddl/lib/libzfs__L
  3095. lib/libbe__L: cddl/lib/libzfs__L cddl/lib/libzfsbootenv__L
  3096. .endif
  3097. _cddl_lib_libctf= cddl/lib/libctf
  3098. _cddl_lib= cddl/lib
  3099. cddl/lib/libctf__L: lib/libz__L cddl/lib/libspl__L
  3100. cddl/lib/libdtrace__L: lib/libxo__L
  3101. .endif
  3102. # cddl/lib/libdtrace requires lib/libproc and lib/librtld_db
  3103. _prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
  3104. lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
  3105. lib/libproc__L: lib/libprocstat__L
  3106. lib/librtld_db__L: lib/libprocstat__L
  3107. .if ${MK_CRYPT} != "no"
  3108. .if ${MK_OPENSSL} != "no"
  3109. _secure_lib_libcrypto= secure/lib/libcrypto
  3110. _secure_lib_libssl= secure/lib/libssl
  3111. lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
  3112. secure/lib/libcrypto__L: lib/libthr__L
  3113. .if ${MK_LDNS} != "no"
  3114. _lib_libldns= lib/libldns
  3115. lib/libldns__L: secure/lib/libssl__L
  3116. .endif
  3117. .if ${MK_OPENSSH} != "no"
  3118. _secure_lib_libssh= secure/lib/libssh
  3119. secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L
  3120. .if ${MK_LDNS} != "no"
  3121. secure/lib/libssh__L: lib/libldns__L
  3122. .endif
  3123. .if ${MK_GSSAPI} != "no" && ${MK_KERBEROS_SUPPORT} != "no"
  3124. secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \
  3125. kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \
  3126. lib/libmd__L kerberos5/lib/libroken__L
  3127. .endif
  3128. .endif
  3129. .endif
  3130. _secure_lib= secure/lib
  3131. .endif
  3132. .if ${MK_KERBEROS} != "no"
  3133. kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
  3134. kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
  3135. kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
  3136. kerberos5/lib/libwind__L lib/libsqlite3__L
  3137. kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
  3138. kerberos5/lib/libroken__L lib/libcom_err__L
  3139. kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
  3140. secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L
  3141. kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
  3142. lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \
  3143. kerberos5/lib/libroken__L kerberos5/lib/libwind__L \
  3144. kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L
  3145. kerberos5/lib/libroken__L: lib/libcrypt__L
  3146. kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
  3147. kerberos5/lib/libheimbase__L: lib/libthr__L
  3148. kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
  3149. .endif
  3150. lib/libsqlite3__L: lib/libthr__L
  3151. .if ${MK_GSSAPI} != "no"
  3152. _lib_libgssapi= lib/libgssapi
  3153. .endif
  3154. .if ${MK_KERBEROS} != "no"
  3155. _kerberos5_lib= kerberos5/lib
  3156. _kerberos5_lib_libasn1= kerberos5/lib/libasn1
  3157. _kerberos5_lib_libhdb= kerberos5/lib/libhdb
  3158. _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase
  3159. _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
  3160. _kerberos5_lib_libhx509= kerberos5/lib/libhx509
  3161. _kerberos5_lib_libroken= kerberos5/lib/libroken
  3162. _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
  3163. _libsqlite3= lib/libsqlite3
  3164. _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
  3165. _kerberos5_lib_libwind= kerberos5/lib/libwind
  3166. _libcom_err= lib/libcom_err
  3167. .endif
  3168. .if ${MK_NIS} != "no"
  3169. _lib_libypclnt= lib/libypclnt
  3170. .endif
  3171. .if ${MK_OPENSSL} == "no"
  3172. lib/libradius__L: lib/libmd__L
  3173. .endif
  3174. lib/libproc__L: \
  3175. ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} \
  3176. lib/libelf__L lib/librtld_db__L lib/libutil__L lib/libcxxrt__L
  3177. .for _lib in ${_prereq_libs}
  3178. ${_lib}__PL: .PHONY .MAKE
  3179. .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
  3180. ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
  3181. cd ${.CURDIR}/${_lib}; \
  3182. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
  3183. ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
  3184. DIRPRFX=${_lib}/ all; \
  3185. ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
  3186. DIRPRFX=${_lib}/ install
  3187. .endif
  3188. .endfor
  3189. .for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
  3190. ${_lib}__L: .PHONY .MAKE
  3191. .if !defined(_MKSHOWCONFIG) && exists(${.CURDIR}/${_lib})
  3192. ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
  3193. cd ${.CURDIR}/${_lib}; \
  3194. if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
  3195. ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
  3196. ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
  3197. .endif
  3198. .endfor
  3199. _prereq_libs: ${_prereq_libs:S/$/__PL/}
  3200. _startup_libs: ${_startup_libs:S/$/__L/}
  3201. _prebuild_libs: ${_prebuild_libs:S/$/__L/}
  3202. _generic_libs: ${_generic_libs:S/$/__L/}
  3203. # Enable SUBDIR_PARALLEL when not calling 'make all', unless called from
  3204. # 'everything' with _PARALLEL_SUBDIR_OK set. This is because it is unlikely
  3205. # that running 'make all' from the top-level, especially with a SUBDIR_OVERRIDE
  3206. # or LOCAL_DIRS set, will have a reliable build if SUBDIRs are built in
  3207. # parallel. This is safe for the world stage of buildworld though since it has
  3208. # already built libraries in a proper order and installed includes into
  3209. # WORLDTMP. Special handling is done for SUBDIR ordering for 'install*' to
  3210. # avoid trashing a system if it crashes mid-install.
  3211. .if !make(all) || defined(_PARALLEL_SUBDIR_OK)
  3212. SUBDIR_PARALLEL=
  3213. .endif
  3214. .include <bsd.subdir.mk>
  3215. .if make(check-old) || make(check-old-dirs) || \
  3216. make(check-old-files) || make(check-old-libs) || \
  3217. make(delete-old) || make(delete-old-dirs) || \
  3218. make(delete-old-files) || make(delete-old-libs) || \
  3219. make(list-old-dirs) || make(list-old-files) || make(list-old-libs)
  3220. #
  3221. # check for / delete old files section
  3222. #
  3223. .include "ObsoleteFiles.inc"
  3224. OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \
  3225. else you can not start such an application. Consult UPDATING for more \
  3226. information regarding how to cope with the removal/revision bump of a \
  3227. specific library."
  3228. .if !defined(BATCH_DELETE_OLD_FILES)
  3229. RM_I=-i
  3230. .else
  3231. RM_I=-fv
  3232. .endif
  3233. list-old-files: .PHONY
  3234. @cd ${.CURDIR}; \
  3235. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  3236. -V "OLD_FILES:ts\n" -V "OLD_FILES:Musr/share/*.gz:R:ts\n" \
  3237. -V "MOVED_LIBS:ts\n" \
  3238. ${_ALL_libcompats:@v@-V "OLD_FILES:Mlib/*.so.*:S,^lib,usr/lib$v,:ts\n"@} \
  3239. ${_ALL_libcompats:@v@-V "OLD_FILES:Musr/lib/*:S,^usr/lib,usr/lib$v,:ts\n"@} | \
  3240. sort
  3241. delete-old-files: .PHONY
  3242. @echo ">>> Removing old files (only deletes safe to delete libs)"
  3243. # Ask for every old file if the user really wants to remove it.
  3244. # It's annoying, but better safe than sorry.
  3245. # NB: We cannot pass the list of OLD_FILES as a parameter because the
  3246. # argument list will get too long. Using .for/.endfor make "loops" will make
  3247. # the Makefile parser segfault.
  3248. @exec 3<&0; \
  3249. cd ${.CURDIR}; \
  3250. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \
  3251. while read file; do \
  3252. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  3253. chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
  3254. rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
  3255. fi; \
  3256. for ext in debug symbols; do \
  3257. if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
  3258. "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  3259. rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
  3260. <&3; \
  3261. fi; \
  3262. done; \
  3263. done
  3264. # Remove catpages without corresponding manpages.
  3265. @exec 3<&0; \
  3266. find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | sort | \
  3267. sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
  3268. while read catpage; do \
  3269. read manpage; \
  3270. if [ ! -e "$${manpage}" ]; then \
  3271. rm ${RM_I} $${catpage} <&3; \
  3272. fi; \
  3273. done
  3274. @echo ">>> Old files removed"
  3275. check-old-files: .PHONY
  3276. @echo ">>> Checking for old files"
  3277. @cd ${.CURDIR}; \
  3278. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-files | \
  3279. while read file; do \
  3280. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  3281. echo "${DESTDIR}/$${file}"; \
  3282. fi; \
  3283. for ext in debug symbols; do \
  3284. if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  3285. echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
  3286. fi; \
  3287. done; \
  3288. done
  3289. # Check for catpages without corresponding manpages.
  3290. @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \
  3291. sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \
  3292. while read catpage; do \
  3293. read manpage; \
  3294. if [ ! -e "$${manpage}" ]; then \
  3295. echo $${catpage}; \
  3296. fi; \
  3297. done | sort
  3298. list-old-libs: .PHONY
  3299. @cd ${.CURDIR}; \
  3300. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  3301. -V "OLD_LIBS:ts\n" \
  3302. ${_ALL_libcompats:@v@-V "OLD_LIBS:Mlib/*:S,^lib,usr/lib$v,:ts\n"@} \
  3303. ${_ALL_libcompats:@v@-V "OLD_LIBS:Musr/lib/*:S,^usr/lib,usr/lib$v,:ts\n"@} \
  3304. ${_ALL_libcompats:@v@-V "OLD_LIBS:Mlib/casper/*:S,^lib/casper,usr/lib$v,:ts\n"@} | \
  3305. sort
  3306. delete-old-libs: .PHONY
  3307. @echo ">>> Removing old libraries"
  3308. @echo "${OLD_LIBS_MESSAGE}" | fmt
  3309. @exec 3<&0; \
  3310. cd ${.CURDIR}; \
  3311. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \
  3312. while read file; do \
  3313. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  3314. chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \
  3315. rm ${RM_I} "${DESTDIR}/$${file}" <&3; \
  3316. fi; \
  3317. for ext in debug symbols; do \
  3318. if ! [ -e "${DESTDIR}/$${file}" ] && [ -f \
  3319. "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  3320. rm ${RM_I} "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" \
  3321. <&3; \
  3322. fi; \
  3323. done; \
  3324. done
  3325. @echo ">>> Old libraries removed"
  3326. check-old-libs: .PHONY
  3327. @echo ">>> Checking for old libraries"
  3328. @cd ${.CURDIR}; \
  3329. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-libs | \
  3330. while read file; do \
  3331. if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \
  3332. echo "${DESTDIR}/$${file}"; \
  3333. fi; \
  3334. for ext in debug symbols; do \
  3335. if [ -f "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}" ]; then \
  3336. echo "${DESTDIR}${DEBUGDIR}/$${file}.$${ext}"; \
  3337. fi; \
  3338. done; \
  3339. done
  3340. list-old-dirs: .PHONY
  3341. @cd ${.CURDIR}; \
  3342. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
  3343. -V OLD_DIRS | sed -E 's/[[:space:]]+/\n/g' | sort -r
  3344. delete-old-dirs: .PHONY
  3345. @echo ">>> Removing old directories"
  3346. @cd ${.CURDIR}; \
  3347. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \
  3348. while read dir; do \
  3349. if [ -d "${DESTDIR}/$${dir}" ]; then \
  3350. rmdir -v "${DESTDIR}/$${dir}" || true; \
  3351. elif [ -L "${DESTDIR}/$${dir}" ]; then \
  3352. echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
  3353. fi; \
  3354. if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  3355. rmdir -v "${DESTDIR}${DEBUGDIR}/$${dir}" || true; \
  3356. elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  3357. echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
  3358. fi; \
  3359. done
  3360. @echo ">>> Old directories removed"
  3361. check-old-dirs: .PHONY
  3362. @echo ">>> Checking for old directories"
  3363. @cd ${.CURDIR}; \
  3364. ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} list-old-dirs | \
  3365. while read dir; do \
  3366. if [ -d "${DESTDIR}/$${dir}" ]; then \
  3367. echo "${DESTDIR}/$${dir}"; \
  3368. elif [ -L "${DESTDIR}/$${dir}" ]; then \
  3369. echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \
  3370. fi; \
  3371. if [ -d "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  3372. echo "${DESTDIR}${DEBUGDIR}/$${dir}"; \
  3373. elif [ -L "${DESTDIR}${DEBUGDIR}/$${dir}" ]; then \
  3374. echo "${DESTDIR}${DEBUGDIR}/$${dir} is a link, please remove everything manually."; \
  3375. fi; \
  3376. done
  3377. delete-old: delete-old-files delete-old-dirs .PHONY
  3378. @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
  3379. check-old: check-old-files check-old-libs check-old-dirs .PHONY
  3380. @echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
  3381. @echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
  3382. .endif
  3383. #
  3384. # showconfig - show build configuration.
  3385. #
  3386. # ignore lower case knobs (not for use with WITH*)
  3387. #
  3388. showconfig: .PHONY
  3389. @(${MAKE} -n -f ${.CURDIR}/sys/conf/kern.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}; \
  3390. ${MAKE} -n -f ${.CURDIR}/share/mk/src.opts.mk -V dummy -dg1 UPDATE_DEPENDFILE=no NO_OBJ=yes MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}) 2>&1 | \
  3391. grep -E '^(MK|OPT)_[A-Z]' | sort -u
  3392. .if !empty(KRNLOBJDIR) && !empty(KERNCONF)
  3393. DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/
  3394. .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE)
  3395. .if !defined(_MKSHOWCONFIG) && exists(${KERNCONFDIR}/${KERNCONF})
  3396. FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \
  3397. '${KERNCONFDIR}/${KERNCONF}' ; echo
  3398. .endif
  3399. .endif
  3400. .endif
  3401. .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH})
  3402. DTBOUTPUTPATH= ${.CURDIR}
  3403. .endif
  3404. #
  3405. # Build 'standalone' Device Tree Blob
  3406. #
  3407. builddtb: .PHONY
  3408. @PATH=${TMPPATH:Q} MACHINE=${TARGET} \
  3409. sh ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
  3410. "${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
  3411. ###############
  3412. # cleanworld
  3413. # In the following, the first 'rm' in a series will usually remove all
  3414. # files and directories. If it does not, then there are probably some
  3415. # files with file flags set, so this unsets them and tries the 'rm' a
  3416. # second time. There are situations where this target will be cleaning
  3417. # some directories via more than one method, but that duplication is
  3418. # needed to correctly handle all the possible situations. Removing all
  3419. # files without file flags set in the first 'rm' instance saves time,
  3420. # because 'chflags' will need to operate on fewer files afterwards.
  3421. #
  3422. # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be
  3423. # created by bsd.obj.mk, except that we don't want to .include that file
  3424. # in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes
  3425. # since it is not possible for files to land in the wrong place.
  3426. #
  3427. .if make(cleanworld)
  3428. BW_CANONICALOBJDIR:=${OBJTOP}/
  3429. .elif make(cleankernel)
  3430. BW_CANONICALOBJDIR:=${KRNLOBJDIR}/${KERNCONF}/
  3431. .elif make(cleanuniverse)
  3432. BW_CANONICALOBJDIR:=${OBJROOT}
  3433. .if ${MK_UNIFIED_OBJDIR} == "no"
  3434. .error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled.
  3435. .endif
  3436. .endif
  3437. cleanworld cleanuniverse cleankernel: .PHONY
  3438. .if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \
  3439. ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA}
  3440. -(cd ${BW_CANONICALOBJDIR} && rm -rf *)
  3441. -chflags -R 0 ${BW_CANONICALOBJDIR}
  3442. -(cd ${BW_CANONICALOBJDIR} && rm -rf *)
  3443. .endif
  3444. .if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \
  3445. (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA})
  3446. .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR}
  3447. # To be safe in this case, fall back to a 'make cleandir'
  3448. ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir
  3449. .endif
  3450. .endif
  3451. .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH}
  3452. XDEV_CPUTYPE?=${CPUTYPE}
  3453. .else
  3454. XDEV_CPUTYPE?=${TARGET_CPUTYPE}
  3455. .endif
  3456. NOFUN=-DNO_FSCHG MK_HTML=no -DNO_LINT \
  3457. MK_MAN=no MK_NLS=no MK_PROFILE=no \
  3458. MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WERROR=no \
  3459. TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
  3460. CPUTYPE=${XDEV_CPUTYPE}
  3461. XDDIR=${TARGET_ARCH}-freebsd
  3462. XDTP?=/usr/${XDDIR}
  3463. .if ${XDTP:N/*}
  3464. .error XDTP variable should be an absolute path
  3465. .endif
  3466. CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/
  3467. CDBOBJTOP= ${CDBOBJROOT}${XDDIR}
  3468. CDBENV= \
  3469. INSTALL="sh ${.CURDIR}/tools/install.sh"
  3470. CDENV= ${CDBENV} \
  3471. TOOLS_PREFIX=${XDTP}
  3472. CDMAKEARGS= \
  3473. OBJTOP=${CDBOBJTOP:Q} \
  3474. OBJROOT=${CDBOBJROOT:Q}
  3475. CD2MAKEARGS= ${CDMAKEARGS}
  3476. .if ${WANT_COMPILER_TYPE} == gcc || \
  3477. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
  3478. # GCC requires -isystem and -L when using a cross-compiler. --sysroot
  3479. # won't set header path and -L is used to ensure the base library path
  3480. # is added before the port PREFIX library path.
  3481. CD2CFLAGS+= -isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib
  3482. # GCC requires -B to find /usr/lib/crti.o when using a cross-compiler
  3483. # combined with --sysroot.
  3484. CD2CFLAGS+= -B${XDDESTDIR}/usr/lib
  3485. # Force using libc++ for external GCC.
  3486. .if defined(X_COMPILER_TYPE) && \
  3487. ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800
  3488. CD2CXXFLAGS+= -isystem ${XDDESTDIR}/usr/include/c++/v1 -std=c++11 \
  3489. -nostdinc++
  3490. .endif
  3491. .endif
  3492. CD2CFLAGS+= --sysroot=${XDDESTDIR}/
  3493. CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" \
  3494. CPP="${CPP} ${CD2CFLAGS}" \
  3495. MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
  3496. CDTMP= ${OBJTOP}/${XDDIR}/tmp
  3497. CDMAKE=${CDENV} PATH=${CDTMP:Q}/usr/bin:${PATH:Q} ${MAKE} ${CDMAKEARGS} ${NOFUN}
  3498. CD2MAKE=${CD2ENV} PATH=${CDTMP:Q}/usr/bin:${XDDESTDIR:Q}/usr/bin:${PATH:Q} \
  3499. ${MAKE} ${CD2MAKEARGS} ${NOFUN}
  3500. .if ${MK_META_MODE} != "no"
  3501. # Don't rebuild build-tools targets during normal build.
  3502. CD2MAKE+= BUILD_TOOLS_META=.NOMETA
  3503. .endif
  3504. XDDESTDIR=${DESTDIR}${XDTP}
  3505. .ORDER: xdev-build xdev-install xdev-links
  3506. xdev: xdev-build xdev-install .PHONY
  3507. .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools
  3508. xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools .PHONY
  3509. _xb-worldtmp: .PHONY
  3510. mkdir -p ${CDTMP}/usr
  3511. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  3512. -p ${CDTMP}/usr >/dev/null
  3513. _xb-bootstrap-tools: .PHONY
  3514. .for _tool in \
  3515. ${_clang_tblgen} \
  3516. ${_yacc}
  3517. ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
  3518. cd ${.CURDIR}/${_tool}; \
  3519. if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
  3520. ${CDMAKE} DIRPRFX=${_tool}/ all; \
  3521. ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
  3522. .endfor
  3523. _xb-build-tools: .PHONY
  3524. ${_+_}@cd ${.CURDIR}; \
  3525. ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools
  3526. XDEVDIRS= \
  3527. ${_clang_libs} \
  3528. ${_lld} \
  3529. ${_elftctools} \
  3530. usr.bin/ar \
  3531. ${_clang}
  3532. _xb-cross-tools: .PHONY
  3533. .for _tool in ${XDEVDIRS}
  3534. ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
  3535. cd ${.CURDIR}/${_tool}; \
  3536. if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
  3537. ${CDMAKE} DIRPRFX=${_tool}/ all
  3538. .endfor
  3539. _xi-mtree: .PHONY
  3540. ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}"
  3541. mkdir -p ${XDDESTDIR}
  3542. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.root.dist \
  3543. -p ${XDDESTDIR} >/dev/null
  3544. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  3545. -p ${XDDESTDIR}/usr >/dev/null
  3546. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  3547. -p ${XDDESTDIR}/usr/include >/dev/null
  3548. .for d in ${LIBCOMPAT_INCLUDE_DIRS}
  3549. mkdir -p ${XDDESTDIR}/usr/include/${d}
  3550. .endfor
  3551. .for libcompat in ${libcompats}
  3552. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  3553. -p ${XDDESTDIR}/usr >/dev/null
  3554. .endfor
  3555. .if ${MK_TESTS} != "no"
  3556. mkdir -p ${XDDESTDIR}${TESTSBASE}
  3557. ${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.tests.dist \
  3558. -p ${XDDESTDIR}${TESTSBASE} >/dev/null
  3559. .endif
  3560. .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries
  3561. xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .PHONY
  3562. _xi-cross-tools: .PHONY
  3563. @echo "_xi-cross-tools"
  3564. .for _tool in ${XDEVDIRS}
  3565. ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \
  3566. cd ${.CURDIR}/${_tool}; \
  3567. ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR}
  3568. .endfor
  3569. _xi-includes: .PHONY
  3570. .if !defined(NO_OBJWALK)
  3571. ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \
  3572. DESTDIR=${XDDESTDIR}
  3573. .endif
  3574. ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \
  3575. DESTDIR=${XDDESTDIR}
  3576. _xi-libraries: .PHONY
  3577. ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \
  3578. DESTDIR=${XDDESTDIR}
  3579. xdev-links: .PHONY
  3580. ${_+_}cd ${XDDESTDIR}/usr/bin; \
  3581. mkdir -p ../../../../usr/bin; \
  3582. for i in *; do \
  3583. ln -sf ../../${XDTP}/usr/bin/$$i \
  3584. ../../../../usr/bin/${XDDIR}-$$i; \
  3585. ln -sf ../../${XDTP}/usr/bin/$$i \
  3586. ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \
  3587. done