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.
6 # See Makefile.template for sample project-specific Makefile.
9 # Defaults for variables provided by buildit
11 # Object files written to '.' unless OBJROOT specified
16 # Executables written to SYMROOT if specified, else to LOCAL_BUILD_DIR
17 # env var if specified, else to '.'.
19 SYMROOT ?= $(shell echo $(LOCAL_BUILD_DIR))
20 LOCAL_BUILD=$(SYMROOT)
21 ifeq "" "$(LOCAL_BUILD)"
27 # independent of SYMROOT
28 CLEAN_DIR=$(shell echo $(LOCAL_BUILD_DIR))
29 ifeq "" "$(CLEAN_DIR)"
34 # DSTROOT only used for install
38 INSTALLDIR := $(DSTROOT)/usr/local/bin
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:
45 # and comment out this, which makes Sphinx the default:
48 UTIL_LIB_SRC= ../utilLib
49 UTIL_LIB_BIN= libcsputils.a
51 # libcsputils comes from ../cspxutils, or from DSTROOT if it's specified
53 CSPUTIL_PATH=$(UTIL_LIB_SRC)
54 UTIL_LIB_BIN_PATH=$(LOCAL_BUILD)/$(UTIL_LIB_BIN)
56 CSPUTIL_PATH=$(DSTROOT)/usr/local/lib
57 UTIL_LIB_BIN_PATH=$(CSPUTIL_PATH)/$(UTIL_LIB_BIN)
60 OFILES= $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
63 # Assume final load with cc, not ld
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
72 # Override this from the make command line to add e.g. -lMallocDebug
77 ALL_LDFLAGS= $(CMDLINE_LDFLAGS) -F$(LOCAL_BUILD) $(ALL_LIBS) $(ALL_LIBPATHS) \
78 $(PROJ_LDFLAGS) -F$(PRIV_FRAMEWORK_PATH)
80 STD_FRAMEWORKS= -framework Security -framework CoreFoundation
82 ALL_FRAMEWORKS= $(STD_FRAMEWORKS) $(PROJ_FRAMEWORKS)
85 # to get to headers in frameworks - may not be necessary
87 STD_FINCLUDES= -F$(LOCAL_BUILD) -F$(PRIV_FRAMEWORK_PATH) -F$(PIECES_FRAMEWORK_PATH) -F$(COMPS_FRAMEWORK_PATH)
89 STD_INCLUDES= -I../utilLib
90 ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
91 CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
93 ###WFLAGS= -Wno-four-char-constants -Wall -Werror
94 WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
95 STD_CFLAGS= -g $(VERBOSE) $(SPHINX)
97 PROJ_CFLAGS?= -fvisibility=hidden
99 ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
102 # Executable in SYMROOT, build folder, '.' in that order
104 BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
106 first: UTIL_LIB $(PROJ_DEPENDS) $(BUILT_TARGET)
111 make "VARIANT_SUFFIX=,_debug"
114 make "SPHINX=-DSPHINX"
116 # architecture options
119 make "DEBUG_CFLAGS=-arch x86_64" "CMDLINE_LDFLAGS=-arch x86_64"
122 make "DEBUG_CFLAGS=-arch x86_64 -arch i386" "CMDLINE_LDFLAGS=-arch x86_64 -arch i386"
125 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
128 install -d -m 0755 $(INSTALLDIR)
129 install -p -m 0755 $(BUILT_TARGET) $(INSTALLDIR)
134 # Executable might be in . if no LOCAL_BUILD_DIR specified
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)
143 (cd $(UTIL_LIB_SRC); make)
145 $(BUILT_TARGET): $(OFILES) $(UTIL_LIB_BIN_PATH)
146 $(CC) -o $(BUILT_TARGET) $(ALL_FRAMEWORKS) $^ $(ALL_LDFLAGS)
149 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
151 $(OBJROOT)/%.o: %.cpp
152 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<