]> git.saurik.com Git - apple/coreosmakefiles.git/blob - ReleaseControl/Common.make
CoreOSMakefiles-52.tar.gz
[apple/coreosmakefiles.git] / ReleaseControl / Common.make
1 ##
2 # Makefile for Apple Release Control (common)
3 #
4 # Wilfredo Sanchez | wsanchez@apple.com
5 # Copyright (c) 1997-1999 Apple Computer, Inc.
6 #
7 # @APPLE_LICENSE_HEADER_START@
8 #
9 # Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
10 # Reserved. This file contains Original Code and/or Modifications of
11 # Original Code as defined in and that are subject to the Apple Public
12 # Source License Version 1.1 (the "License"). You may not use this file
13 # except in compliance with the License. Please obtain a copy of the
14 # License at http://www.apple.com/publicsource and read it before using
15 # this file.
16 #
17 # The Original Code and all software distributed under the License are
18 # distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
19 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
20 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
21 # FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
22 # License for the specific language governing rights and limitations
23 # under the License.
24 #
25 # @APPLE_LICENSE_HEADER_END@
26 ##
27 # Set these variables as needed, then include this file, then:
28 #
29 # Project [ UNTITLED_PROJECT ]
30 # ProjectName [ $(Project) ]
31 # SubProjects
32 # Extra_Environment
33 # Passed_Targets
34 #
35 # Additional variables inherited from Standard/Standard.make
36 ##
37
38 ifndef CoreOSMakefiles
39 CoreOSMakefiles = $(MAKEFILEPATH)/CoreOS
40 endif
41
42 include $(CoreOSMakefiles)/Standard/Standard.make
43
44 ##
45 # Some reasonable defaults for RC variables
46 ##
47
48 RC_ARCHS = $(shell for i in `file /usr/lib/libSystem.B.dylib | grep 'shared library ' | sed 's|.*shared library ||'`; do $(CC) -arch $$i -E -x c /dev/null > /dev/null 2>&1 && echo $$i; done)
49 RC_RELEASE = unknown
50 RC_VERSION = unknown
51
52 ifeq ($(COPY_SOURCES),YES)
53 SRCROOT = /tmp/$(ProjectName)/Sources
54 else
55 SRCROOT = $(shell pwd)
56 endif
57
58 OBJROOT = /tmp/$(ProjectName)/Build
59 SYMROOT = /tmp/$(ProjectName)/Debug
60 DSTROOT = /tmp/$(ProjectName)/Release
61
62 ##
63 # My variables
64 ##
65
66 ifndef Project
67 Project = UNTITLED_PROJECT
68 endif
69
70 ifndef ProjectName
71 ProjectName = $(Project)
72 endif
73
74 ifneq ($(RC_VERSION),unknown)
75 Version = RC_VERSION
76 else
77 Version := $(shell $(VERS_STRING) -f $(Project) 2>/dev/null | cut -d - -f 2)
78 ifeq ($(Version),)
79 Version = 0
80 endif
81 endif
82
83 Sources = $(SRCROOT)
84 Platforms = $(patsubst %,%-apple-rhapsody$(RhapsodyVersion),$(RC_ARCHS:ppc=powerpc))
85 BuildDirectory = $(OBJROOT)
86
87 CC_Archs = $(RC_ARCHS:%=-arch %)
88 #CPP_Defines += -DPROJECT_VERSION=\"$(Project)-$(Version)\"
89
90 Extra_CC_Flags += $(RC_CFLAGS)
91
92 ifneq "$(strip $(CFLAGS))" ""
93 Environment += CFLAGS="$(CFLAGS)"
94 endif
95 ifneq "$(strip $(CXXFLAGS))" ""
96 Environment += CCFLAGS="$(CXXFLAGS)" CXXFLAGS="$(CXXFLAGS)"
97 endif
98 ifneq "$(strip $(LDFLAGS))" ""
99 Environment += LDFLAGS="$(LDFLAGS)"
100 endif
101 ifneq "$(strip $(CPPFLAGS))" ""
102 Environment += CPPFLAGS="$(CPPFLAGS)"
103 endif
104 Environment += $(Extra_Environment)
105
106 VPATH=$(Sources)
107
108 ManPageDirectories = /usr/share/man
109
110 ##
111 # Targets
112 ##
113
114 .PHONY: all install installhdrs install_headers lazy_installsrc lazy_install_source installsrc install_source build clean recurse _targetconfig
115
116 all: build
117
118 $(DSTROOT): install
119
120 install:: _targetconfig install_headers build
121
122 _targetconfig::
123 @PRODUCT="`tconf --product 2>/dev/null`" ; \
124 if [ -z "$$PRODUCT" ]; then \
125 echo "Error: TargetConfig not defined" ; exit 1 ; \
126 else echo "TargetConfig: $$PRODUCT" ; fi
127
128 # For RC
129 installhdrs:: install_headers
130
131 install_headers::
132
133 lazy_install_source::
134 $(_v) if [ ! -f "$(SRCROOT)/Makefile" ]; then $(MAKE) install_source; fi
135
136 install_source::
137 ifneq ($(CommonNoInstallSource),YES)
138 @echo "Installing source for $(Project)..."
139 $(_v) $(MKDIR) "$(SRCROOT)"
140 ifneq ($(wildcard $(PAX)),)
141 $(_v) $(PAX) -rw . "$(SRCROOT)"
142 else
143 $(_v) $(TAR) cf - . | (cd "$(SRCROOT)" ; $(TAR) xfp -)
144 endif
145 $(_v) $(FIND) "$(SRCROOT)" $(Find_Cruft) -depth -exec $(RMDIR) "{}" \;
146 endif
147
148 ifndef ShadowTestFile
149 ShadowTestFile = $(BuildDirectory)/Makefile
150 endif
151
152 shadow_source:: $(ShadowTestFile)
153
154 $(ShadowTestFile):
155 echo "Creating pseudo-copy of sources in the build directory...";
156 $(_v) mkdir -p $(BuildDirectory);
157 $(_v) for dir in $$( cd $(Sources) && $(FIND) . -type d ); do \
158 cd $(BuildDirectory) && if [ ! -d $$dir ]; then $(MKDIR) $$dir; fi; \
159 done
160 $(_v) for file in $$( cd $(Sources) && $(FIND) . -type f ); do \
161 cd $(BuildDirectory) && $(LN) -fs $(Sources)/$$file $$file; \
162 done
163
164 # For RC
165 installsrc: install_source
166
167 build:: lazy_install_source
168
169 clean::
170 @echo "Cleaning $(Project)..."
171 $(_v) $(RMDIR) -f "$(BuildDirectory)" || true
172
173 $(Passed_Targets) $(Extra_Passed_Targets):
174 $(_v) umask $(Install_Mask) ; $(MAKE) -C $(BuildDirectory) $(Environment) $@
175
176 recurse:
177 ifdef SubProjects
178 $(_v) for SubProject in $(SubProjects); do \
179 $(MAKE) -C $$SubProject $(TARGET) \
180 OBJROOT=$(OBJROOT) \
181 SYMROOT=$(SYMROOT) \
182 DSTROOT=$(DSTROOT) \
183 BuildDirectory=$(BuildDirectory)/$${SubProject} \
184 Sources=$(Sources)/$${SubProject} \
185 CoreOSMakefiles=$(CoreOSMakefiles) || exit 1 ; \
186 done
187 endif
188
189 rshowvar: showvar
190 $(_v) $(MAKE) recurse TARGET=rshowvar
191
192 compress_man_pages:
193 ifneq "$(strip $(ManPageDirectories))" ""
194 @echo "Compressing man pages for $(Project)..."
195 $(_v) $(COMPRESSMANPAGES) $(ManPageDirectories)
196 endif