2 # Common makefile fragment for dmitch's SecurityX-style csputils,
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
38 # Sphinx can be overridden, else null
39 # To use this source tree to test non-Sphinx code (I.e., SUJagGreen only,
40 # uncomment the following:
42 # and comment out this, which makes Sphinx the default:
46 INSTALLDIR := $(DSTROOT)/usr/local/lib
47 INSTALLHDRDIR := $(DSTROOT)/usr/local/include/utilLib
49 OFILES := $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
51 PRIV_FRAMEWORK_PATH= /System/Library/PrivateFrameworks
53 ALL_LDFLAGS= -static $(PROJ_LDFLAGS)
58 # to get to headers in frameworks - may not be necessary
60 STD_FINCLUDES= -F$(LOCAL_BUILD) -F$(PRIV_FRAMEWORK_PATH)
62 ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
63 CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
65 ###WFLAGS= -Wno-four-char-constants -Wall -Werror
66 WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
67 STD_CFLAGS= -g $(VERBOSE) $(SPHINX)
69 PROJ_CFLAGS?= -fvisibility=hidden
71 ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
74 # Executable has to be in build folder for MDS
76 BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
78 first: $(PROJ_DEPENDS) $(BUILT_TARGET)
83 make "SPHINX=-DSPHINX"
85 # architecture options
88 make "DEBUG_CFLAGS=-arch x86_64"
91 make "DEBUG_CFLAGS=-arch x86_64 -arch i386"
94 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
97 install -d -m 0755 $(INSTALLDIR)
98 install -p -m 0644 $(BUILT_TARGET) $(INSTALLDIR)
99 install -d -m 0755 $(INSTALLHDRDIR)
100 install -p -m 0644 *.h $(INSTALLHDRDIR)
103 install -d -m 0755 $(INSTALLHDRDIR)
104 install -p -m 0644 *.h $(INSTALLHDRDIR)
106 $(BUILT_TARGET): $(OFILES)
107 @echo === building $(BUILT_TARGET) ===
108 libtool $(ALL_LDFLAGS) -o $(BUILT_TARGET) $^
111 cd $(SRCROOT); rm -f $(OFILES) *.o
112 rm -f $(BUILT_TARGET)
113 rm -f $(CLEAN_DIR)/$(EXECUTABLE)
116 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
118 $(OBJROOT)/%.o: %.cpp
119 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<