]> git.saurik.com Git - apple/xnu.git/blobdiff - tools/tests/perf_index/Makefile
xnu-3248.60.10.tar.gz
[apple/xnu.git] / tools / tests / perf_index / Makefile
index ae8f3a68337e3422d0ad3885620c0e8dda19a59b..ba1218867dd1ddf86f61d12ce9186007bc5d71b6 100644 (file)
@@ -1,42 +1,85 @@
-SDKROOT ?= /
-Embedded?=$(shell echo $(SDKROOT) | grep -iq iphoneos && echo YES || echo NO)
-CC:=xcrun -sdk "$(SDKROOT)" cc
-CFLAGS:=-c -Wall -pedantic
-OPTIMIZATION:=-Os
-LDFLAGS=
+include ../Makefile.common
 
-SRCROOT?=$(shell /bin/pwd)
-DSTROOT?=$(shell /bin/pwd)
-OBJROOT?=$(shell /bin/pwd)
+CC:=$(shell xcrun -sdk "$(SDKROOT)" -find cc)
+CFLAGS:=-c -Wall -pedantic -Os -isysroot $(SDKROOT)
+LDFLAGS:=
 
-SOURCES:=main.c stress_cpu.c stress_memory.c stress_syscall.c stress_fault.c md5.c stress_file_create.c stress_file_write.c stress_file_read.c stress_file_local.c stress_file_ram.c iperf.c compile.c stress_general.c
-SOURCE_PATHS:=$(addprefix $(SRCROOT)/,$(SOURCES))
-OBJECTS:=$(addprefix $(OBJROOT)/,$(SOURCES:.c=.o))
-EXECUTABLE=perf_index
+SRCROOT?=$(shell /bin/pwd)
+DSTROOT?=$(shell /bin/pwd)/BUILD/dst
+OBJROOT?=$(shell /bin/pwd)/BUILD/obj
+SYMROOT?=$(shell /bin/pwd)/BUILD/sym
 
 ifdef RC_ARCHS
-ARCHS:=$(RC_ARCHS)
+       ARCHS:=$(RC_ARCHS)
 else
-ifeq ($(ARCHS),)
-ifeq "$(Embedded)" "YES"
-ARCHS:=armv7 armv7s
+       ifeq ($(ARCHS),)
+       ifeq "$(Embedded)" "YES"
+       ARCHS:=armv7 armv7s arm64
 else
-ARCHS:=x86_64 i386
+       ARCHS:=x86_64 i386
+endif
 endif
 endif
+
+
+ifeq "$(Embedded)" "YES"
+       TARGET_NAME:=PerfIndex.bundle-ios
+else
+       TARGET_NAME:=PerfIndex.bundle-osx
 endif
 
 CFLAGS += $(patsubst %, -arch %, $(ARCHS))
 LDFLAGS += $(patsubst %, -arch %, $(ARCHS))
 
-all: $(SOURCE_PATHS) $(EXECUTABLE)
+all: $(DSTROOT) $(OBJROOT) $(SYMROOT) \
+       $(DSTROOT)/perf_index \
+       $(DSTROOT)/perfindex-cpu.dylib \
+       $(DSTROOT)/perfindex-memory.dylib \
+       $(DSTROOT)/perfindex-syscall.dylib \
+       $(DSTROOT)/perfindex-fault.dylib \
+       $(DSTROOT)/perfindex-zfod.dylib \
+       $(DSTROOT)/perfindex-file_create.dylib \
+       $(DSTROOT)/perfindex-file_read.dylib \
+       $(DSTROOT)/perfindex-file_write.dylib \
+       $(DSTROOT)/perfindex-ram_file_create.dylib \
+       $(DSTROOT)/perfindex-ram_file_read.dylib \
+       $(DSTROOT)/perfindex-ram_file_write.dylib \
+       $(DSTROOT)/perfindex-iperf.dylib \
+       $(DSTROOT)/perfindex-compile.dylib \
+       $(DSTROOT)/PerfIndex.bundle
+
+$(DSTROOT)/perfindex-cpu.dylib: $(OBJROOT)/md5.o
+$(DSTROOT)/perfindex-fault.dylib: $(OBJROOT)/test_fault_helper.o
+$(DSTROOT)/perfindex-zfod.dylib: $(OBJROOT)/test_fault_helper.o
+$(DSTROOT)/perfindex-file_create.dylib: $(OBJROOT)/test_file_helper.o
+$(DSTROOT)/perfindex-file_read.dylib: $(OBJROOT)/test_file_helper.o
+$(DSTROOT)/perfindex-file_write.dylib: $(OBJROOT)/test_file_helper.o
+$(DSTROOT)/perfindex-ram_file_create.dylib: $(OBJROOT)/test_file_helper.o $(OBJROOT)/ramdisk.o
+$(DSTROOT)/perfindex-ram_file_read.dylib: $(OBJROOT)/test_file_helper.o $(OBJROOT)/ramdisk.o
+$(DSTROOT)/perfindex-ram_file_write.dylib: $(OBJROOT)/test_file_helper.o $(OBJROOT)/ramdisk.o
+
+$(DSTROOT)/perf_index: $(OBJROOT)/perf_index.o
+       $(CC) $(LDFLAGS) $? -o $@
+
+$(DSTROOT)/PerfIndex.bundle: $(SRCROOT)/PerfIndex_COPS_Module/PerfIndex.xcodeproj
+       xcodebuild -sdk $(SDKROOT) -target $(TARGET_NAME) OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) TARGET_TEMP_DIR=$(OBJROOT) TARGET_BUILD_DIR=$(DSTROOT) -project $? CLANG_ENABLE_MODULES=NO
 
-$(EXECUTABLE): $(OBJECTS) 
-       $(CC) $(LDFLAGS) $(OBJECTS) -o $(DSTROOT)/$@
+$(DSTROOT)/%.dylib: $(OBJROOT)/%.o
+       $(CC) $(LDFLAGS) -dynamiclib $? -o $@
 
 $(OBJROOT)/%.o: $(SRCROOT)/%.c
-       $(CC) $(CFLAGS) $(OPTIMIZATION) $< -o $@
+       $(CC) $(CFLAGS) $? -o $@
+
+$(DSTROOT):
+       mkdir -p $(DSTROOT);
+
+$(OBJROOT):
+       mkdir -p $(OBJROOT);
+
+$(SYMROOT):
+       mkdir -p $(SYMROOT);
 
 clean:
-       rm -f *.o
-       rm -f $(EXECUTABLE)
+       rm -rf $(OBJROOT)
+       rm -rf $(DSTROOT)
+       rm -rf $(SYMROOT)