]> git.saurik.com Git - apple/security.git/blob - SecurityTests/cspxutils/Makefile.lib
Security-57031.10.10.tar.gz
[apple/security.git] / SecurityTests / cspxutils / Makefile.lib
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 #
14 OBJROOT ?= .
15 SRCROOT ?= .
16 #
17 # Library written to SYMROOT if specified, else to LOCAL_BUILD_DIR
18 # env var if specified, else to '.'.
19 #
20 SYMROOT ?= $(shell echo $(LOCAL_BUILD_DIR))
21 LOCAL_BUILD=$(SYMROOT)
22 ifeq "" "$(LOCAL_BUILD)"
23 LOCAL_BUILD = .
24 endif
25
26 # independent of SYMROOT
27 CLEAN_DIR=$(shell echo $(LOCAL_BUILD_DIR))
28 ifeq "" "$(CLEAN_DIR)"
29 CLEAN_DIR = .
30 endif
31
32 #
33 # DSTROOT only used for install
34 $
35 DSTROOT ?= ""
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:
41 SPHINX ?=
42 # and comment out this, which makes Sphinx the default:
43 # SPHINX=-DSPHINX
44
45
46 INSTALLDIR := $(DSTROOT)/usr/local/lib
47 INSTALLHDRDIR := $(DSTROOT)/usr/local/include/utilLib
48
49 OFILES := $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
50
51 PRIV_FRAMEWORK_PATH= /System/Library/PrivateFrameworks
52
53 ALL_LDFLAGS= -static $(PROJ_LDFLAGS)
54
55 CC=c++
56
57 #
58 # to get to headers in frameworks - may not be necessary
59 #
60 STD_FINCLUDES= -F$(LOCAL_BUILD) -F$(PRIV_FRAMEWORK_PATH)
61
62 ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
63 CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
64
65 ###WFLAGS= -Wno-four-char-constants -Wall -Werror
66 WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
67 STD_CFLAGS= -g $(VERBOSE) $(SPHINX)
68 DEBUG_CFLAGS?=
69 PROJ_CFLAGS?= -fvisibility=hidden
70
71 ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
72
73 #
74 # Executable has to be in build folder for MDS
75 #
76 BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
77
78 first: $(PROJ_DEPENDS) $(BUILT_TARGET)
79
80 build: first
81
82 sphinx:
83 make "SPHINX=-DSPHINX"
84
85 # architecture options
86
87 64bit:
88 make "DEBUG_CFLAGS=-arch x86_64"
89
90 64bitFat:
91 make "DEBUG_CFLAGS=-arch x86_64 -arch i386"
92
93 fat:
94 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
95
96 install: 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
102 installhdrs:
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
110 clean:
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 $<