]> git.saurik.com Git - apple/xnu.git/blobdiff - tools/tests/affinity/Makefile
xnu-4903.221.2.tar.gz
[apple/xnu.git] / tools / tests / affinity / Makefile
index b8563d54e0e3577b53764d615f822e4fa36a0e4b..5f45973ab8924f237e43f99e4b27d03cd0957912 100644 (file)
@@ -1,18 +1,53 @@
-CFLAGS =-g -arch i386
-CFLAGS64=-g -arch x86_64
+include ../Makefile.common
 
-TESTS =                \
-       sets    \
-       pool    \
-       tags    \
+CC:=$(shell xcrun -sdk "$(SDKROOT)" -find cc)
 
-TARGETS = $(TESTS) $(TESTS:=64)
+SYMROOT?=$(shell /bin/pwd)
 
-all:   $(TESTS)
+ifdef RC_ARCHS
+    ARCHS:=$(RC_ARCHS)
+  else
+    ifeq "$(Embedded)" "YES"
+      ARCHS:=armv7 armv7s arm64
+    else
+      ARCHS:=x86_64 i386
+  endif
+endif
 
-.c:    
-       gcc $(CFLAGS) $< -o $@          # 32-bit fat 
-       gcc $(CFLAGS64) $< -o $@64              # 64-bit fat
+# These are convenience functions for filtering based on substrings, as the
+# normal filter functions only accept one wildcard.
+FILTER_OUT_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),,$(string))))
+FILTER_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),$(string),)))
+
+ARCH_32:=$(call FILTER_OUT_SUBSTRING,64,$(ARCHS))
+ARCH_64:=$(call FILTER_SUBSTRING,64,$(ARCHS))
+
+ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32))
+ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64))
+
+CFLAGS :=-g -isysroot $(SDKROOT) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
+
+DSTROOT?=$(shell /bin/pwd)
+SRCROOT?=$(shell /bin/pwd)
+
+SOURCES := sets.c pool.c tags.c
+ARCH_32_TARGETS := $(addprefix $(DSTROOT)/, sets pool tags)
+ARCH_64_TARGETS := $(addprefix $(DSTROOT)/, sets64 pool64 tags64)
+
+TARGETS := $(if $(ARCH_64), $(ARCH_64_TARGETS)) $(if $(ARCH_32), $(ARCH_32_TARGETS))
+
+
+all:   $(TARGETS)
+
+$(ARCH_32_TARGETS): $(DSTROOT)/%: $(SRCROOT)/%.c
+       $(CC) $(CFLAGS) $(ARCH_32_FLAGS) $< -o $(SYMROOT)/$(notdir $@) # 32-bit fat
+       if [ ! -e $@ ]; then ditto $(SYMROOT)/$(notdir $@) $@; fi
+
+.SECONDEXPANSION:
+$(ARCH_64_TARGETS): $(DSTROOT)/%: $(SRCROOT)/$$(subst 64,,%).c
+       $(CC) $(CFLAGS) $(ARCH_64_FLAGS) $< -o $(SYMROOT)/$(notdir $@) # 64-bit fat
+       if [ ! -e $@ ]; then ditto $(SYMROOT)/$(notdir $@) $@; fi
 
 clean:
-       rm -rf $(TARGETS) 
+       rm -f $(TARGETS)
+       rm -rf $(SYMROOT)/*.dSYM