]> git.saurik.com Git - apple/security.git/blob - SecurityTests/clxutils/Makefile.lib
Security-57031.30.12.tar.gz
[apple/security.git] / SecurityTests / clxutils / Makefile.lib
1 #
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.
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 # if DSTROOT not specified, skip the extra -I to get to cspxutils headers
38 ifeq ("", $(DSTROOT))
39 UTILLIB_HDRS=
40 else
41 UTILLIB_HDRS="-I$(DSTROOT)/usr/local/include"
42 endif
43
44 INSTALLDIR := $(DSTROOT)/usr/local/lib
45
46 CC=c++
47
48 COMMON_LIB_SRC= -I../../cspxutils/
49
50 OFILES := $(CSOURCE:%.c=$(OBJROOT)/%.o) $(CPSOURCE:%.cpp=$(OBJROOT)/%.o)
51
52 PRIV_FRAMEWORK_PATH= /System/Library/PrivateFrameworks
53
54 ALL_LDFLAGS= -static $(PROJ_LDFLAGS)
55
56 STD_FRAMEWORKS=
57 ALL_FRAMEWORKS= $(STD_FRAMEWORKS) $(PROJ_FRAMEWORKS)
58
59 #
60 # to get to headers in frameworks
61 #
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)
64
65 ALL_INCLUDES= $(STD_INCLUDES) $(PROJ_INCLUDES)
66 CINCLUDES= $(STD_FINCLUDES) $(ALL_INCLUDES)
67
68 ###WFLAGS= -Wno-four-char-constants -Wall -Werror
69 WFLAGS= -Wno-four-char-constants -Wall -Wno-deprecated-declarations
70 STD_CFLAGS= -g $(VERBOSE)
71 DEBUG_CFLAGS?=
72
73 ALL_CFLAGS= $(CINCLUDES) $(STD_CFLAGS) $(PROJ_CFLAGS) $(WFLAGS) $(DEBUG_CFLAGS)
74
75 #
76 # Executable has to be in build folder for MDS
77 #
78 BUILT_TARGET= $(LOCAL_BUILD)/$(EXECUTABLE)
79
80 first: $(PROJ_DEPENDS) $(BUILT_TARGET)
81
82 build: first
83
84 # architecture options
85
86 64bit:
87 make "DEBUG_CFLAGS=-arch x86_64"
88
89 64bitFat:
90 make "DEBUG_CFLAGS=-arch x86_64 -arch i386"
91
92 fat:
93 make "DEBUG_CFLAGS=-arch i386" "CMDLINE_LDFLAGS=-arch i386"
94
95 install: build
96 install -d -m 0755 $(INSTALLDIR)
97 install -p -m 0644 $(BUILT_TARGET) $(INSTALLDIR)
98
99 installhdrs:
100
101 $(BUILT_TARGET): $(OFILES)
102 libtool $(ALL_LDFLAGS) -o $(BUILT_TARGET) $^
103
104 clean:
105 cd $(SRCROOT); rm -f $(OFILES) *.o
106 rm -f $(BUILT_TARGET)
107 rm -f $(CLEAN_DIR)/$(EXECUTABLE)
108
109 $(OBJROOT)/%.o: %.c
110 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<
111
112 $(OBJROOT)/%.o: %.cpp
113 $(CC) $(ALL_CFLAGS) -c -o $(OBJROOT)/$*.o $<