]> git.saurik.com Git - apple/security.git/blob - SecurityTests/cspxutils/Makefile.cdsa
Security-57031.10.10.tar.gz
[apple/security.git] / SecurityTests / cspxutils / Makefile.cdsa
1 #
2 # Common makefile fragment for dmitch's cspxutils.
3 # This is -included from project-specific Makefiles, assumed
4 # to be one directory down from this file.
5 #
6 # See Makefile.template for sample project-specific Makefile.
7 #
8
9 # Defaults for variables provided by buildit
10 #
11 # Object files written to '.' unless OBJROOT specified
12 #
13 OBJROOT ?= .
14 SRCROOT ?= .
15 #
16 # Executables written to SYMROOT if specified, else to LOCAL_BUILD_DIR
17 # env var if specified, else to '.'.
18 #
19 SYMROOT ?= $(shell echo $(LOCAL_BUILD_DIR))
20 LOCAL_BUILD=$(SYMROOT)
21 ifeq "" "$(LOCAL_BUILD)"
22 LOCAL_BUILD = .
23 endif
24
25 CC=c++
26
27 # independent of SYMROOT
28 CLEAN_DIR=$(shell echo $(LOCAL_BUILD_DIR))
29 ifeq "" "$(CLEAN_DIR)"
30 CLEAN_DIR = .
31 endif
32
33 #
34 # DSTROOT only used for install
35 $
36 DSTROOT ?= ""
37
38 INSTALLDIR := $(DSTROOT)/usr/local/bin
39
40 #
41 # Sphinx can be overridden, else null
42 # To use this source tree to test non-Sphinx code (I.e., SUJagGreen only,
43 # uncomment the following:
44 SPHINX ?=
45 # and comment out this, which makes Sphinx the default:
46 # SPHINX=-DSPHINX
47
48 UTIL_LIB_SRC= ../utilLib
49 UTIL_LIB_BIN= libcsputils.a
50
51 # libcsputils comes from ../cspxutils, or from DSTROOT if it's specified
52 ifeq ("", $(DSTROOT))
53 CSPUTIL_PATH=$(UTIL_LIB_SRC)
54 UTIL_LIB_BIN_PATH=$(LOCAL_BUILD)/$(UTIL_LIB_BIN)
55 else
56 CSPUTIL_PATH=$(DSTROOT)/usr/local/lib
57 UTIL_LIB_BIN_PATH=$(CSPUTIL_PATH)/$(UTIL_LIB_BIN)
58 endif
59
60 OFILES= $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
61
62 #
63 # Assume final load with cc, not ld
64 #
65 STD_LIBS=-lcsputils -lsecurity_cdsa_client -lsecurity_utilities -lsecurity_cdsa_utilities -lsecurity_cdsa_utils
66 STD_LIBPATH= -L$(LOCAL_BUILD) -L$(CSPUTIL_PATH)
67 ALL_LIBS= $(STD_LIBS) $(PROJ_LIBS)
68 ALL_LIBPATHS= $(STD_LIBPATH) $(PROJ_LIBPATH)
69 PRIV_FRAMEWORK_PATH= /System/Library/PrivateFrameworks
70
71 #
72 # Override this from the make command line to add e.g. -lMallocDebug
73 #
74 CMDLINE_LDFLAGS?=
75
76 #
77 ALL_LDFLAGS= $(CMDLINE_LDFLAGS) -F$(LOCAL_BUILD) $(ALL_LIBS) $(ALL_LIBPATHS) \
78 $(PROJ_LDFLAGS) -F$(PRIV_FRAMEWORK_PATH)
79
80 STD_FRAMEWORKS= -framework Security -framework CoreFoundation
81
82 ALL_FRAMEWORKS= $(STD_FRAMEWORKS) $(PROJ_FRAMEWORKS)
83
84 #
85 # to get to headers in frameworks - may not be necessary
86 #
87 STD_FINCLUDES= -F$(LOCAL_BUILD) -F$(PRIV_FRAMEWORK_PATH) -F$(PIECES_FRAMEWORK_PATH) -F$(COMPS_FRAMEWORK_PATH)
88
89 STD_INCLUDES= -I../utilLib
90 ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
91 CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
92
93 ###WFLAGS= -Wno-four-char-constants -Wall -Werror
94 WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
95 STD_CFLAGS= -g $(VERBOSE) $(SPHINX)
96 DEBUG_CFLAGS?=
97 PROJ_CFLAGS?= -fvisibility=hidden
98
99 ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
100
101 #
102 # Executable in SYMROOT, build folder, '.' in that order
103 #
104 BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
105
106 first: UTIL_LIB $(PROJ_DEPENDS) $(BUILT_TARGET)
107
108 build: first
109
110 debug:
111 make "VARIANT_SUFFIX=,_debug"
112
113 sphinx:
114 make "SPHINX=-DSPHINX"
115
116 # architecture options
117
118 64bit:
119 make "DEBUG_CFLAGS=-arch x86_64" "CMDLINE_LDFLAGS=-arch x86_64"
120
121 64bitFat:
122 make "DEBUG_CFLAGS=-arch x86_64 -arch i386" "CMDLINE_LDFLAGS=-arch x86_64 -arch i386"
123
124 fat:
125 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
126
127 install: build
128 install -d -m 0755 $(INSTALLDIR)
129 install -p -m 0755 $(BUILT_TARGET) $(INSTALLDIR)
130
131 installhdrs:
132
133 #
134 # Executable might be in . if no LOCAL_BUILD_DIR specified
135 #
136 clean:
137 rm -f $(BUILT_TARGET) $(EXECUTABLE)
138 cd $(SRCROOT); rm -f $(OFILES) *.o
139 cd $(LOCAL_BUILD); rm -f $(EXECUTABLE) $(OTHER_TO_CLEAN)
140 rm -f $(CLEAN_DIR)/$(EXECUTABLE)
141
142 UTIL_LIB:
143 (cd $(UTIL_LIB_SRC); make)
144
145 $(BUILT_TARGET): $(OFILES) $(UTIL_LIB_BIN_PATH)
146 $(CC) -o $(BUILT_TARGET) $(ALL_FRAMEWORKS) $^ $(ALL_LDFLAGS)
147
148 $(OBJROOT)/%.o: %.c
149 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
150
151 $(OBJROOT)/%.o: %.cpp
152 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<