| 1 | # $Id: darwin-common.kmk 3488 2020-09-22 09:47:02Z bird $
 | 
|---|
| 2 | ## @file
 | 
|---|
| 3 | # kBuild Common Darwin (macOS) Definitions - Used by tools and SDKs.
 | 
|---|
| 4 | #
 | 
|---|
| 5 | 
 | 
|---|
| 6 | #
 | 
|---|
| 7 | # Copyright (c) 2004-2020 knut st. osmundsen <bird-kBuild-spam-xx@anduin.net>
 | 
|---|
| 8 | #
 | 
|---|
| 9 | # This file is part of kBuild.
 | 
|---|
| 10 | #
 | 
|---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
 | 
|---|
| 12 | # it under the terms of the GNU General Public License as published by
 | 
|---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
 | 
|---|
| 14 | # (at your option) any later version.
 | 
|---|
| 15 | #
 | 
|---|
| 16 | # kBuild is distributed in the hope that it will be useful,
 | 
|---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 19 | # GNU General Public License for more details.
 | 
|---|
| 20 | #
 | 
|---|
| 21 | # You should have received a copy of the GNU General Public License
 | 
|---|
| 22 | # along with kBuild; if not, write to the Free Software
 | 
|---|
| 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|---|
| 24 | #
 | 
|---|
| 25 | #
 | 
|---|
| 26 | # As a special exception you are granted permission to include this file, via
 | 
|---|
| 27 | # the kmk include directive, as you wish without this in itself causing the
 | 
|---|
| 28 | # resulting makefile, program or whatever to be covered by the GPL license.
 | 
|---|
| 29 | # This exception does not however invalidate any other reasons why the makefile,
 | 
|---|
| 30 | # program, whatever should not be covered the GPL.
 | 
|---|
| 31 | #
 | 
|---|
| 32 | #
 | 
|---|
| 33 | 
 | 
|---|
| 34 | INCLUDED_DARWIN_COMMON_KMK := 1
 | 
|---|
| 35 | 
 | 
|---|
| 36 | ### @def DARWINCMN_XCODE_APP_DEVELOPER_DIRS
 | 
|---|
| 37 | # List 'Developer' directories inside 'Xcode.app' directories.
 | 
|---|
| 38 | # The idea was to use this as a basis for DARWINCMN_TOOLCHAIN_DIRS and
 | 
|---|
| 39 | # DARWINCMN_MACOSX_SDKS_DIRS, but that didn't pan out.
 | 
|---|
| 40 | #
 | 
|---|
| 41 | # Users can alter this by setting DARWINCMN_XCODE_APP_DIRS_PREFERRED,
 | 
|---|
| 42 | # DARWINCMN_XCODE_APP_DIRS_FALLBACK and DARWINCMN_XCODE_APP_DIRS_IGNORE_DEVTOOLS.
 | 
|---|
| 43 | #
 | 
|---|
| 44 | DARWINCMN_XCODE_APP_DEVELOPER_DIRS = $(DARWINCMN_XCODE_APP_DEVELOPER_DIRS_PREFERRED) \
 | 
|---|
| 45 |         $(if-expr defined(DARWINCMN_XCODE_APP_DIRS_IGNORE_DEVTOOLS),, \
 | 
|---|
| 46 |         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/xcode/v*/*.app/Contents/Developer)) \
 | 
|---|
| 47 |         $(if $(KBUILD_DEVTOOLS_HST_ALT),$(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/xcode/v*/*.app/Contents/Developer))) ) \
 | 
|---|
| 48 |         /Applications/Xcode.app/Contents/Developer \
 | 
|---|
| 49 |         $(DARWINCMN_XCODE_APP_DIRS_FALLBACK)
 | 
|---|
| 50 | 
 | 
|---|
| 51 | ## @def DARWINCMN_TOOLCHAIN_DIRS
 | 
|---|
| 52 | # List of toolchain directories containing compilers and stuff in a usr/bin subdir.
 | 
|---|
| 53 | #
 | 
|---|
| 54 | # Users can alter this by setting DARWINCMN_TOOLCHAIN_DIRS_PREFERRED and DARWINCMN_TOOLCHAIN_DIRS_FALLBACK.
 | 
|---|
| 55 | #
 | 
|---|
| 56 | # @note Would love to use DARWINCMN_XCODE_APP_DEVELOPER_DIRS here, but that doesn't really fly wrt directory priority.
 | 
|---|
| 57 | #       Also, prefer avoiding using the longer Xcode.app paths when command line tools are installed.
 | 
|---|
| 58 | DARWINCMN_TOOLCHAIN_DIRS = $(DARWINCMN_TOOLCHAIN_DIRS_PREFERRED) \
 | 
|---|
| 59 |         $(if-expr defined(DARWINCMN_TOOLCHAIN_DIRS_IGNORE_DEVTOOLS),, \
 | 
|---|
| 60 |                 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/CommandLineTools/v*)) \
 | 
|---|
| 61 |                 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/xcode/v*/*.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain)) \
 | 
|---|
| 62 |                 $(if-expr "$(KBUILD_DEVTOOLS_HST_ALT)" != "", \
 | 
|---|
| 63 |                         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/CommandLineTools/v*)) \
 | 
|---|
| 64 |                         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/xcode/v*/*.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain)) ,) \
 | 
|---|
| 65 |         ) \
 | 
|---|
| 66 |         /Library/Developer/CommandLineTools \
 | 
|---|
| 67 |         $(qwildcard ,/Applications/Xcode*.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain) \
 | 
|---|
| 68 |         /. \
 | 
|---|
| 69 |         $(DARWINCMN_TOOLCHAIN_DIRS_FALLBACK)
 | 
|---|
| 70 | 
 | 
|---|
| 71 | 
 | 
|---|
| 72 | ## @def DARWINCMN_MACOSX_SDKS_DIRS
 | 
|---|
| 73 | # List of 'SDKs' directories containing MacOSX (macOS) platform SDKs.
 | 
|---|
| 74 | # Users can alter this by setting DARWINCMN_MACOSX_SDKS_DIRS_PREFERRED and DARWINCMN_MACOSX_SDKS_DIRS_FALLBACK.
 | 
|---|
| 75 | DARWINCMN_MACOSX_SDKS_DIRS = $(DARWINCMN_MACOSX_SDKS_DIRS_PREFERRED) \
 | 
|---|
| 76 |         $(if-expr defined(DARWINCMN_MACOSX_SDKS_DIRS_IGNORE_DEVTOOLS),, \
 | 
|---|
| 77 |                 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_TRG_NOARCH)/SDKs)) \
 | 
|---|
| 78 |                 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_TRG)/SDKs)) \
 | 
|---|
| 79 |                 $(if-expr "$(KBUILD_DEVTOOLS_TRG_ALT)" != "", \
 | 
|---|
| 80 |                         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_TRG_ALT)/SDKs)) ,) \
 | 
|---|
| 81 |                 $(if-expr "$(KBUILD_DEVTOOLS_TRG_NOARCH)" != "$(KBUILD_DEVTOOLS_HST_NOARCH)", \
 | 
|---|
| 82 |                         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_NOARCH)/SDKs)),) \
 | 
|---|
| 83 |                 $(if-expr "$(KBUILD_DEVTOOLS_HST)" != "$(KBUILD_DEVTOOLS_TRG)", \
 | 
|---|
| 84 |                         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/SDKs)) \
 | 
|---|
| 85 |                         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/CommandLineTools/v*/SDKs)) \
 | 
|---|
| 86 |                         $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST)/xcode/v*/*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs)) \
 | 
|---|
| 87 |                         $(if-expr "$(KBUILD_DEVTOOLS_HST_ALT)" != "", \
 | 
|---|
| 88 |                                 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/CommandLineTools/v*)) \
 | 
|---|
| 89 |                                 $(rversortfiles $(qwildcard ,$(KBUILD_DEVTOOLS_HST_ALT)/xcode/v*/*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs)) ,) \
 | 
|---|
| 90 |                 ) \
 | 
|---|
| 91 |         ) \
 | 
|---|
| 92 |         /Library/Developer/CommandLineTools/SDKs \
 | 
|---|
| 93 |         $(qwildcard ,/Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs) \
 | 
|---|
| 94 |         /Developer/SDKs \
 | 
|---|
| 95 |         $(DARWINCMN_MACOSX_SDKS_DIRS_FALLBACK)
 | 
|---|
| 96 | 
 | 
|---|
| 97 | ## @def DARWINCMN_FN_FIND_MACOSX_SDK
 | 
|---|
| 98 | # Locate a given SDK.
 | 
|---|
| 99 | # @param 1 SDK name directory (e.g. MacOSX10.15.sdk).
 | 
|---|
| 100 | DARWINCMN_FN_FIND_MACOSX_SDK = $(firstfile $(qwildcard ,$(qaddsuffix ,/$(1),$(DARWINCMN_MACOSX_SDKS_DIRS))))
 | 
|---|
| 101 | ## @def DARWINCMN_FN_ERROR_MACOSX_SDK
 | 
|---|
| 102 | # Generate complaint text about SDK that DARWINCMN_FN_FIND_MACOSX_SDK failed to locate.
 | 
|---|
| 103 | # @param 1 SDK name directory (e.g. MacOSX10.15.sdk).
 | 
|---|
| 104 | define DARWINCMN_FN_ERROR_MACOSX_SDK
 | 
|---|
| 105 | Failed to locate the MacOSX SDK '$(1)' directory after checking: $(foreachfile file,$(qaddsuffix ,/$(1),$(DARWINCMN_MACOSX_SDKS_DIRS)),$(NLTAB)$(file))
 | 
|---|
| 106 | Available SDKs: $(rversortfiles $(qnotdir ,$(qwildcard ,$(qaddsuffix ,/Mac*sdk,$(DARWINCMN_MACOSX_SDKS_DIRS)))))
 | 
|---|
| 107 | endef
 | 
|---|
| 108 | 
 | 
|---|