]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/Makefile.cdsa
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / clxutils / Makefile.cdsa
1 #
2 # Common makefile fragment for dmitch's clxutils.
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 # independent of SYMROOT
26 CLEAN_DIR=$(shell echo $(LOCAL_BUILD_DIR))
27 ifeq "" "$(CLEAN_DIR)"
28 CLEAN_DIR = .
29 endif
30
31 #
32 # DSTROOT only used for install
33 $
34 DSTROOT ?= ""
35
36 INSTALLDIR := $(DSTROOT)/usr/local/bin
37
38 UTIL_LIB_SRC= ../clAppUtils
39 COMMON_LIB_SRC= ../../cspxutils
40 CSPUTIL_LIB_BIN=libcsputils.a
41 CLUTIL_LIB_BIN=libclutils.a
42
43 # cspxutils headers and lib come from ../cspxutils, or from /usr/local if DSTROOT is specified
44 ifeq ("", $(DSTROOT))
45 UTILLIB_HDRS=$(COMMON_LIB_SRC)
46 UTILLIB_PATH=$(COMMON_LIB_SRC)/utilLib
47 CSPUTIL_LIB_BIN_PATH=$(LOCAL_BUILD)/$(CSPUTIL_LIB_BIN)
48 CLUTIL_LIB_BIN_PATH=$(LOCAL_BUILD)/$(CLUTIL_LIB_BIN)
49 else
50 UTILLIB_HDRS=$(DSTROOT)/usr/local/include
51 UTILLIB_PATH=$(DSTROOT)/usr/local/lib
52 CSPUTIL_LIB_BIN_PATH=/usr/local/lib/$(CSPUTIL_LIB_BIN)
53 CLUTIL_LIB_BIN_PATH=$(UTILLIB_PATH)/$(CLUTIL_LIB_BIN)
54 endif
55
56 OFILES= $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
57
58 #
59 # Assume final load with cc, not ld
60 #
61 STD_LIBS=-lclutils -lcsputils
62 STD_LIBPATH= -L$(LOCAL_BUILD) -L$(UTILLIB_PATH) -L$(UTIL_LIB_SRC)
63 ALL_LIBS= $(STD_LIBS) $(PROJ_LIBS)
64 ALL_LIBPATHS= $(STD_LIBPATH) $(PROJ_LIBPATH)
65 PRIV_FRAMEWORK_PATH= /System/Library/PrivateFrameworks
66
67 #
68 # Override this from the make command line to add e.g. -lMallocDebug
69 #
70 CMDLINE_LDFLAGS?=
71
72 ALL_LDFLAGS= $(CMDLINE_LDFLAGS) -F$(LOCAL_BUILD) $(ALL_LIBS) $(ALL_LIBPATHS) \
73 $(PROJ_LDFLAGS) -F$(PRIV_FRAMEWORK_PATH) -lsecurity_cdsa_client -lsecurity_utilities -lsecurity_cdsa_utilities -lsecurity_cdsa_utils
74
75 CC=c++
76
77 VARIANT_SUFFIX=
78
79 STD_FRAMEWORKS= -framework Security$(VARIANT_SUFFIX) -framework CoreFoundation
80
81 ALL_FRAMEWORKS= $(STD_FRAMEWORKS) $(PROJ_FRAMEWORKS)
82
83 #
84 # to get to headers in frameworks
85 #
86 STD_FINCLUDES= -F$(LOCAL_BUILD) -F$(PRIV_FRAMEWORK_PATH) -F$(PRIV_FRAMEWORK_PATH)
87 #
88 # the common headers for csputils
89 #
90 STD_INCLUDES= -I.. -I$(UTILLIB_HDRS) -F$(PRIV_FRAMEWORK_PATH)
91 ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
92 CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
93
94 ###WFLAGS= -Wno-four-char-constants -Wall -Werror
95 WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
96
97 STD_CFLAGS= -g $(VERBOSE) $(SPHINX)
98 DEBUG_CFLAGS?=
99
100 ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
101
102 #
103 # Executable in build folder
104 #
105 BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
106
107 first: LIB_CLUTILS $(PROJ_DEPENDS) $(CSPUTIL_LIB_BIN_PATH) $(BUILT_TARGET)
108
109 build: first
110
111 debug:
112 make "VARIANT_SUFFIX=,_debug"
113
114 sphinx:
115 make "SPHINX=-DSPHINX"
116
117 # architecture options
118
119 64bit:
120 make "DEBUG_CFLAGS=-arch x86_64" "CMDLINE_LDFLAGS=-arch x86_64"
121
122 64bitFat:
123 make "DEBUG_CFLAGS=-arch x86_64 -arch i386" "CMDLINE_LDFLAGS=-arch x86_64 -arch i386"
124
125 fat:
126 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
127
128 install: build
129 install -d -m 0755 $(INSTALLDIR)
130 install -p -m 0755 $(BUILT_TARGET) $(INSTALLDIR)
131
132 installhdrs:
133
134 #
135 # Executable might be in . if no LOCAL_BUILD_DIR specified
136 #
137 clean:
138 rm -f $(BUILT_TARGET) $(EXECUTABLE)
139 cd $(SRCROOT); rm -f $(OFILES) *.o
140 cd $(LOCAL_BUILD); rm -f $(EXECUTABLE) $(OTHER_TO_CLEAN)
141 rm -f $(CLEAN_DIR)/$(EXECUTABLE)
142
143 #
144 # Make sure libcsputils.a has been built...
145 #
146 $(CSPUTIL_LIB_BIN_PATH):
147 @if ! ( [ -e $(CSPUTIL_LIB_BIN_PATH) ] );\
148 then \
149 echo === You must build libcsputils.a before building this project. === ;\
150 echo === Please cd to the cspxutils/utilLib directory and type make. === ;\
151 echo === $(CSPUTIL_LIB_BIN_PATH) not found. === ;\
152 exit 1; \
153 fi
154
155 LIB_CLUTILS:
156 (cd $(UTIL_LIB_SRC); make)
157
158 $(BUILT_TARGET): $(OFILES) $(CSPUTIL_LIB_BIN_PATH) $(CLUTIL_LIB_BIN_PATH)
159 $(CC) -o $(BUILT_TARGET) $(ALL_FRAMEWORKS) $^ $(ALL_LDFLAGS)
160
161 $(OBJROOT)/%.o: %.c $(HDR_DEPENDS)
162 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
163
164 $(OBJROOT)/%.o: %.cpp $(HDR_DEPENDS)
165 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<