]> git.saurik.com Git - apple/libpthread.git/blob - tests/Makefile.common
libpthread-138.10.4.tar.gz
[apple/libpthread.git] / tests / Makefile.common
1 # Code 'borrowed' from xnu/tools/tests Makefile structure.
2 #
3 # This provides a somewhat flexible framework (albeit, not perfect)
4 # for building tests for multiple platforms using the correct toolset
5 #
6 # Please contact: nwertman@apple.com with any questions
7
8
9 ifneq ($(SRCROOT),)
10 SRCDIR=$(SRCROOT)
11 else
12 SRCDIR?=$(shell /bin/pwd)
13 endif
14
15 ifneq ($(OBJROOT),)
16 OBJDIR?=$(OBJROOT)
17 else
18 OBJDIR?=$(SRCDIR)/build/obj
19 endif
20
21 ifneq ($(DSTROOT),)
22 BUILDDIR?=$(DSTROOT)/AppleInternal/CoreOS/tests/$(PROJECT)
23 else
24 BUILDDIR?=$(SRCDIR)/build/dst
25 endif
26
27 #
28 # Common definitions for test directories
29 #
30
31 XCRUN := /usr/bin/xcrun
32 SDKROOT ?= macosx.internal
33
34 # SDKROOT may be passed as a shorthand like "iphoneos.internal". We
35 # must resolve these to a full path and override SDKROOT.
36
37 SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-path)
38 ifeq ($(strip $(SDKROOT)_$(SDKROOT_RESOLVED)),/_)
39 SDKROOT_RESOLVED := /
40 endif
41 override SDKROOT = $(SDKROOT_RESOLVED)
42
43 SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version)
44
45 PLATFORMPATH := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-platform-path)
46 PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
47
48 ifeq ($(PLATFORM),watchOS)
49 PLATFORM := WatchOS
50 endif
51
52 SUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS
53 Embedded = $(if $(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),YES,NO)
54
55 #
56 # Deployment target flag
57 #
58 ifeq ($(PLATFORM),MacOSX)
59 DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION)
60 else ifeq ($(PLATFORM),WatchOS)
61 DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION)
62 else ifeq ($(PLATFORM),tvOS)
63 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
64 else ifeq ($(PLATFORM),AppleTVOS)
65 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
66 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
67 DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION)
68 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
69 DEPLOYMENT_TARGET_FLAGS =
70 else
71 DEPLOYMENT_TARGET_FLAGS =
72 endif
73
74 DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM)
75
76
77
78 # setup the TARGETSDK and SDKROOT variables
79 TARGETSDK:=$(SDKROOT)
80 SDKROOTPATH:=$(SDKROOT)
81
82 # make sure we have a build directory
83 $(shell [ -d "$(BUILDDIR)" ] || mkdir -p $(BUILDDIR))
84
85 #arch configs if not provided
86 ifdef RC_ARCHS
87 ARCH_CONFIGS:=$(RC_ARCHS)
88 endif
89
90 ifeq ($(ARCH_CONFIGS),)
91 ARCH_CONFIGS:=
92 ifeq ($(Embedded),YES)
93 ARCH_CONFIGS:=$(shell $(XCRUN) -sdk $(TARGETSDK) otool -f -v $(SDKROOT)/usr/lib/system/libsystem_kernel.dylib | grep architecture | cut -d' ' -f 2 | tr '\n' ' ')
94 else
95 ARCH_CONFIGS:=x86_64 i386
96 endif
97 endif
98
99 ARCH_CONFIGS_32:=$(filter-out %64,$(ARCH_CONFIGS))
100 ARCH_CONFIGS_64:=$(filter %64,$(ARCH_CONFIGS))
101
102 ARCH_FLAGS:=$(foreach argarch,$(ARCH_CONFIGS),-arch $(argarch) )
103
104
105 #setup the compiler flags.
106 CC:=$(shell $(XCRUN) -sdk "$(TARGETSDK)" -find clang)
107 MIG:=$(shell $(XCRUN) -sdk "$(TARGETSDK)" -find mig)
108 CODESIGN:=$(shell $(XCRUN) -sdk "$(TARGETSDK)" -find codesign)
109 CODESIGN_ALLOCATE:=$(shell $(XCRUN) -sdk "$(TARGETSDK)" -find codesign_allocate)
110 PLUTIL:=$(shell $(XCRUN) -sdk "$(TARGETSDK)" -find plutil)
111
112 CFLAGS=-I$(BUILDDIR) -I. -isysroot $(SDKROOTPATH) $(ARCH_FLAGS)
113
114 ifeq ($(Embedded),YES)
115 TARGET_NAME=ios
116 CONFIG_EMBED_DEFINE:= -DCONFIG_EMBEDDED=1
117 else
118 TARGET_NAME=osx
119 CONFIG_EMBED_DEFINE:=
120 endif
121
122 MORECFLAGS=$(CONFIG_EMBED_DEFINE)