]> git.saurik.com Git - apple/security.git/blame - SecurityTests/cspxutils/Makefile.lib
Security-57337.40.85.tar.gz
[apple/security.git] / SecurityTests / cspxutils / Makefile.lib
CommitLineData
d8f41ccd
A
1#
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.
6#
7# See Makefile.template for sample project-specific Makefile.
8#
9
10# Defaults for variables provided by buildit
11#
12# Object files written to '.' unless OBJROOT specified
13#
14OBJROOT ?= .
15SRCROOT ?= .
16#
17# Library written to SYMROOT if specified, else to LOCAL_BUILD_DIR
18# env var if specified, else to '.'.
19#
20SYMROOT ?= $(shell echo $(LOCAL_BUILD_DIR))
21LOCAL_BUILD=$(SYMROOT)
22ifeq "" "$(LOCAL_BUILD)"
23 LOCAL_BUILD = .
24endif
25
26# independent of SYMROOT
27CLEAN_DIR=$(shell echo $(LOCAL_BUILD_DIR))
28ifeq "" "$(CLEAN_DIR)"
29 CLEAN_DIR = .
30endif
31
32#
33# DSTROOT only used for install
34$
35DSTROOT ?= ""
36
37#
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:
41SPHINX ?=
42# and comment out this, which makes Sphinx the default:
43# SPHINX=-DSPHINX
44
45
46INSTALLDIR := $(DSTROOT)/usr/local/lib
47INSTALLHDRDIR := $(DSTROOT)/usr/local/include/utilLib
48
49OFILES := $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
50
51PRIV_FRAMEWORK_PATH= /System/Library/PrivateFrameworks
52
53ALL_LDFLAGS= -static $(PROJ_LDFLAGS)
54
55CC=c++
56
57#
58# to get to headers in frameworks - may not be necessary
59#
60STD_FINCLUDES= -F$(LOCAL_BUILD) -F$(PRIV_FRAMEWORK_PATH)
61
62ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
63CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
64
65###WFLAGS= -Wno-four-char-constants -Wall -Werror
66WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
67STD_CFLAGS= -g $(VERBOSE) $(SPHINX)
68DEBUG_CFLAGS?=
69PROJ_CFLAGS?= -fvisibility=hidden
70
71ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
72
73#
74# Executable has to be in build folder for MDS
75#
76BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
77
78first: $(PROJ_DEPENDS) $(BUILT_TARGET)
79
80build: first
81
82sphinx:
83 make "SPHINX=-DSPHINX"
84
85# architecture options
86
8764bit:
88 make "DEBUG_CFLAGS=-arch x86_64"
89
9064bitFat:
91 make "DEBUG_CFLAGS=-arch x86_64 -arch i386"
92
93fat:
94 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
95
96install: build
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)
101
102installhdrs:
103 install -d -m 0755 $(INSTALLHDRDIR)
104 install -p -m 0644 *.h $(INSTALLHDRDIR)
105
106$(BUILT_TARGET): $(OFILES)
107 @echo === building $(BUILT_TARGET) ===
108 libtool $(ALL_LDFLAGS) -o $(BUILT_TARGET) $^
109
110clean:
111 cd $(SRCROOT); rm -f $(OFILES) *.o
112 rm -f $(BUILT_TARGET)
113 rm -f $(CLEAN_DIR)/$(EXECUTABLE)
114
115$(OBJROOT)/%.o: %.c
116 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
117
118$(OBJROOT)/%.o: %.cpp
119 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<