2 # Common makefile fragment for dmitch's SecurityX-style clxutils,
3 # tailored for building a library.
4 # This is -included from project-specific Makefiles, assumed
5 # to be one directory down from this file.
7 # See Makefile.template for sample project-specific Makefile.
10 # Defaults for variables provided by buildit
12 # Object files written to '.' unless OBJROOT specified
17 # Library written to SYMROOT if specified, else to LOCAL_BUILD_DIR
18 # env var if specified, else to '.'.
20 SYMROOT ?= $(shell echo $(LOCAL_BUILD_DIR))
21 LOCAL_BUILD=$(SYMROOT)
22 ifeq "" "$(LOCAL_BUILD)"
26 # independent of SYMROOT
27 CLEAN_DIR=$(shell echo $(LOCAL_BUILD_DIR))
28 ifeq "" "$(CLEAN_DIR)"
33 # DSTROOT only used for install
37 # if DSTROOT not specified, skip the extra -I to get to cspxutils headers
41 UTILLIB_HDRS="-I$(DSTROOT)/usr/local/include"
44 INSTALLDIR := $(DSTROOT)/usr/local/lib
48 COMMON_LIB_SRC= -I../../cspxutils/
50 OFILES := $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
52 PRIV_FRAMEWORK_PATH= /System/Library/PrivateFrameworks
54 ALL_LDFLAGS= -static $(PROJ_LDFLAGS)
57 ALL_FRAMEWORKS= $(STD_FRAMEWORKS) $(PROJ_FRAMEWORKS)
60 # to get to headers in frameworks
62 STD_FINCLUDES= -F$(LOCAL_BUILD) -F/System/Library/Frameworks/CoreServices.framework/Frameworks
63 STD_INCLUDES= -I.. $(COMMON_LIB_SRC) $(UTILLIB_HDRS) -F$(PRIV_FRAMEWORK_PATH)
65 ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
66 CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
68 ###WFLAGS= -Wno-four-char-constants -Wall -Werror
69 WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
70 STD_CFLAGS= -g $(VERBOSE)
73 ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
76 # Executable has to be in build folder for MDS
78 BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
80 first: $(PROJ_DEPENDS) $(BUILT_TARGET)
84 # architecture options
87 make "DEBUG_CFLAGS=-arch x86_64"
90 make "DEBUG_CFLAGS=-arch x86_64 -arch i386"
93 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
96 install -d -m 0755 $(INSTALLDIR)
97 install -p -m 0644 $(BUILT_TARGET) $(INSTALLDIR)
101 $(BUILT_TARGET): $(OFILES)
102 libtool $(ALL_LDFLAGS) -o $(BUILT_TARGET) $^
105 cd $(SRCROOT); rm -f $(OFILES) *.o
106 rm -f $(BUILT_TARGET)
107 rm -f $(CLEAN_DIR)/$(EXECUTABLE)
110 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
112 $(OBJROOT)/%.o: %.cpp
113 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<