Makefile.inc1 130 KB

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