]> git.saurik.com Git - apple/security.git/blob - SecurityTests/regressions/Makefile
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / regressions / Makefile
1 # Makefile
2
3 .PHONY: build all install installsrc installhdrs test check Makefile testexcldebug
4 PRODUCT=regressions
5
6 TESTDIRS := .
7
8 HFILES := $(shell find $(TESTDIRS) -type f -name \*.h -print)
9 ALL_CFILES := $(shell find $(TESTDIRS) -type f -name \*.c -print)
10 ALL_CXXFILES := $(shell find $(TESTDIRS) -type f -name \*.cpp -print)
11 ALL_MFILES := $(shell find $(TESTDIRS) -type f -name \*.m -print)
12 SHFILES := $(shell find $(TESTDIRS) -type f -name \*.sh -print)
13 TFILES := $(shell find $(TESTDIRS) -type f -name \*.t -print)
14
15 PAREN := (
16 CTESTS := $(shell grep -l 'main[ \t]*$(PAREN)' $(ALL_CFILES) /dev/null)
17 CXXTESTS := $(shell grep -l 'main[ \t]*$(PAREN)' $(ALL_CXXFILES) /dev/null)
18 MTESTS := $(shell grep -l 'main[ \t]*$(PAREN)' $(ALL_MFILES) /dev/null)
19 SHTESTS := $(SHFILES)
20
21 EXCLSTR := NO_AUTOMATED_TESTING
22 EXCL_CTESTS := $(shell grep -l $(EXCLSTR) $(CTESTS) /dev/null)
23 EXCL_CXXTESTS := $(shell grep -l $(EXCLSTR) $(CXXTESTS) /dev/null)
24 EXCL_MTESTS := $(shell grep -l $(EXCLSTR) $(MTESTS) /dev/null)
25 EXCL_SHTESTS := $(shell grep -l $(EXCLSTR) $(SHTESTS) /dev/null)
26 EXCL_TESTS := $(EXCL_CTESTS) $(EXCL_CXXTESTS) $(EXCL_MTESTS) $(EXCL_SHTESTS)
27
28 CFILES = $(filter-out $(CTESTS),$(ALL_CFILES))
29 CXXFILES = $(filter-out $(CXXTESTS),$(ALL_CXXFILES))
30 MFILES = $(filter-out $(MTESTS),$(ALL_MFILES))
31
32 BUILT_PRODUCTS_DIR ?= $(shell echo $(LOCAL_BUILD_DIR))
33 ifeq "" "$(BUILT_PRODUCTS_DIR)"
34 BUILT_PRODUCTS_DIR = $(SYMROOT)
35 ifeq "" "$(BUILT_PRODUCTS_DIR)"
36 BUILT_PRODUCTS_DIR = build
37 endif
38 endif
39 SYMROOT ?= $(BUILT_PRODUCTS_DIR)
40 OBJROOT ?= $(BUILT_PRODUCTS_DIR)/intermediates/$(PRODUCT).build
41 SRCROOT ?= $(shell /bin/pwd)
42 DSTROOT ?= ""
43
44 INSTALLDIR := $(DSTROOT)/usr/local/bin
45
46 SRCFILES := Makefile $(HFILES) $(CTESTS) $(CFILES) $(CXXTESTS) $(CXXFILES) $(MTESTS) $(MFILES)
47
48 BUILT_CTARGETS := $(addprefix $(BUILT_PRODUCTS_DIR)/,$(notdir $(basename $(CTESTS))))
49 BUILT_CXXTARGETS := $(addprefix $(BUILT_PRODUCTS_DIR)/,$(notdir $(basename $(CXXTESTS))))
50 BUILT_MTARGETS := $(addprefix $(BUILT_PRODUCTS_DIR)/,$(notdir $(basename $(MTESTS))))
51 BUILT_TARGETS := $(BUILT_CTARGETS) $(BUILT_CXXTARGETS) $(BUILT_MTARGETS)
52 EXCL_TARGETS := $(addprefix $(BUILT_PRODUCTS_DIR)/, $(notdir $(basename $(EXCL_TESTS))))
53 TEST_TARGETS := $(filter-out $(EXCL_TARGETS),$(BUILT_TARGETS))
54
55 COFILES := $(addprefix $(OBJROOT)/,$(addsuffix .o, $(basename $(CFILES))))
56 CXXOFILES := $(addprefix $(OBJROOT)/,$(addsuffix .o, $(basename $(CXXFILES))))
57 MOFILES := $(addprefix $(OBJROOT)/,$(addsuffix .o, $(basename $(MFILES))))
58 OFILES := $(COFILES) $(CXXOFILES) $(MOFILES)
59
60 TEST_COFILES := $(addprefix $(OBJROOT)/,$(addsuffix .o, $(basename $(CTESTS))))
61 TEST_CXXOFILES := $(addprefix $(OBJROOT)/,$(addsuffix .o, $(basename $(CXXTESTS))))
62 TEST_MOFILES := $(addprefix $(OBJROOT)/,$(addsuffix .o, $(basename $(MTESTS))))
63 TEST_OFILES := $(TEST_COFILES) $(TEST_CXXOFILES) $(TEST_MOFILES)
64
65 OBJDIRS := $(sort $(OBJROOT) $(dir $(OFILES) $(TEST_OFILES)))
66
67 #
68 # Assume final load with cc, not ld
69 #
70
71 C_FRAMEWORK_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)
72 CPP_FRAMEWORK_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR) \
73 /System/Library/PrivateFrameworks /usr/local/SecurityPieces/Frameworks
74 M_FRAMEWORK_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR) \
75 /System/Library/PrivateFrameworks
76 STD_HEADER_SEARCH_PATHS = $(SRCROOT)/test
77 STD_LIBARY_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)
78
79 ALL_HEADER_SEARCH_PATHS = $(HEADER_SEARCH_PATHS) $(STD_HEADER_SEARCH_PATHS)
80 ALL_LIBARY_SEARCH_PATHS = $(LIBARY_SEARCH_PATHS) $(STD_LIBARY_SEARCH_PATHS)
81
82 STD_LIBRARIES =
83 ALL_LIBRARIES = $(STD_LIBRARIES) $(LIBRARIES:lib%.a=%)
84
85 C_FRAMEWORKS = Security CoreFoundation
86 CPP_FRAMEWORKS = $(C_FRAMEWORKS) #security_utilities
87 M_FRAMEWORKS = $(C_FRAMEWORKS) SecurityFoundation Foundation
88
89 C_FINCLUDES = $(addprefix -F,$(C_FRAMEWORK_SEARCH_PATHS) \
90 $(FRAMEWORK_SEARCH_PATHS))
91 CPP_FINCLUDES = $(addprefix -F,$(CPP_FRAMEWORK_SEARCH_PATHS) \
92 $(FRAMEWORK_SEARCH_PATHS))
93 M_FINCLUDES = $(addprefix -F,$(M_FRAMEWORK_SEARCH_PATHS) \
94 $(FRAMEWORK_SEARCH_PATHS))
95 ALL_INCLUDES = $(addprefix -I,$(ALL_HEADER_SEARCH_PATHS))
96
97 #
98 # Override this from the make command line to add e.g. -lMallocDebug
99 #
100 CMDLINE_LDFLAGS=
101
102 #
103 C_LDFLAGS = $(CMDLINE_LDFLAGS) \
104 $(C_FINCLUDES) \
105 $(addprefix -framework ,$(C_FRAMEWORKS) $(FRAMEWORKS)) \
106 $(addprefix -L,$(ALL_LIBARY_SEARCH_PATHS)) \
107 $(addprefix -l,$(ALL_LIBARIES)) \
108 $(OTHER_LDFLAGS)
109 CPP_LDFLAGS = $(CMDLINE_LDFLAGS) \
110 $(CPP_FINCLUDES) \
111 $(addprefix -framework ,$(CPP_FRAMEWORKS) $(FRAMEWORKS)) \
112 $(addprefix -L,$(ALL_LIBARY_SEARCH_PATHS)) \
113 $(addprefix -l,$(ALL_LIBARIES)) \
114 $(OTHER_LDFLAGS) /usr/local/lib/libsecurity_utilities.a
115 M_LDFLAGS = $(CMDLINE_LDFLAGS) \
116 $(M_FINCLUDES) \
117 $(addprefix -framework ,$(M_FRAMEWORKS) $(FRAMEWORKS)) \
118 $(addprefix -L,$(ALL_LIBARY_SEARCH_PATHS)) \
119 $(addprefix -l,$(ALL_LIBARIES)) \
120 $(OTHER_LDFLAGS)
121
122 ###WARNING_CFLAGS = -Wno-four-char-constants -Wall -Werror
123 WARNING_CFLAGS = -Wno-four-char-constants -Wall -Wno-deprecated-declarations
124 STD_CFLAGS= -g
125 DEBUG_CFLAGS=
126
127 ALL_CFLAGS = $(C_FINCLUDES) $(ALL_INCLUDES) $(STD_CFLAGS) \
128 $(WARNING_CFLAGS) $(OTHER_CFLAGS) $(DEBUG_CFLAGS)
129 ALL_CXXFLAGS = $(CPP_FINCLUDES) $(ALL_INCLUDES) $(STD_CFLAGS) \
130 $(WARNING_CFLAGS) $(OTHER_CXXFLAGS) $(DEBUG_CFLAGS)
131 ALL_MFLAGS = $(M_FINCLUDES) $(ALL_INCLUDES) $(STD_CFLAGS) \
132 $(WARNING_CFLAGS) $(OTHER_CFLAGS) $(DEBUG_CFLAGS)
133
134 build: $(OTHER_DEPENDENCIES) $(OBJDIRS) $(BUILT_TARGETS)
135
136 all: build
137
138 ppc64:
139 make CMDLINE_LDFLAGS="-arch ppc64" DEBUG_CFLAGS="-arch ppc64"
140
141 install: build
142 install -d -m 0755 $(INSTALLDIR)
143 install -p -m 0755 $(BUILT_TARGETS) $(INSTALLDIR)
144
145 installhdrs:
146
147 installsrc:
148 mkdir $(DSTROOT)
149
150 clean:
151 rm -f $(BUILT_TARGETS) $(OFILES) $(TEST_OFILES) $(OTHER_TO_CLEAN)
152 # echo rm -rf $(OBJDIRS)
153
154 test: build
155 @perl -Iinc -e 'use MyHarness; Test::Harness::runtests @ARGV;' $(sort $(TEST_TARGETS)) $(sort $(TFILES))
156
157 testexcldebug: build
158 @echo EXCL_CTESTS: $(EXCL_CTESTS)
159 @echo EXCL_CXXTESTS: $(EXCL_CXXTESTS)
160 @echo EXCL_MTESTS: $(EXCL_MTESTS)
161 @echo EXCL_SHTESTS: $(EXCL_SHTESTS)
162 @echo EXCL_TESTS: $(EXCL_TESTS)
163 @echo BUILT_TARGETS: $(BUILT_TARGETS)
164 @echo TEST_TARGETS: $(TEST_TARGETS)
165
166 LOCAL_OFILES := $(addsuffix .o, $(basename $(CFILES) $(CXXFILES) $(MFILES)))
167 OFILES := $(LOCAL_OFILES:%=$(OBJROOT)/%)
168
169 $(BUILT_CTARGETS): $(COFILES) $(TEST_COFILES)
170 $(CC) -o $@ $(filter %/$(notdir $@).o,$(TEST_COFILES)) $(OFILES) $(C_LDFLAGS)
171
172 $(BUILT_CXXTARGETS): $(COFILES) $(CXXOFILES) $(TEST_CXXOFILES)
173 $(CXX) -o $@ $(filter %/$(notdir $@).o,$(TEST_CXXOFILES)) $(OFILES) $(CPP_LDFLAGS)
174
175 $(BUILT_MTARGETS): $(COFILES) $(MOFILES) $(TEST_MOFILES)
176 $(CC) -o $@ $(filter %/$(notdir $@).o,$(TEST_MOFILES)) $(OFILES) $(M_LDFLAGS)
177
178 $(OBJDIRS):
179 @mkdir -p $@
180
181 $(OBJROOT)/%.o: %.c
182 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
183
184 $(OBJROOT)/%.o: %.cpp
185 $(CXX) $(ALL_CXXFLAGS) -c -o $(OBJROOT)/$*.o $<
186
187 $(OBJROOT)/%.o: %.m
188 $(CC) $(ALL_MFLAGS) -c -o $(OBJROOT)/$*.o $<
189
190 $(OFILES) $(TEST_OFILES): $(HFILES)