summaryrefslogtreecommitdiff
path: root/samples/build/gcc3.2/XMPSamples.mak
blob: d4ca09b008313226d426d8951a1403f5f415e545 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# ##########################################################################################
# Copyright 2008 Adobe Systems Incorporated
# All Rights Reserved.
#
# NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with
# the terms of the Adobe license agreement accompanying it.
#
# ##########################################################################################

# Define internal use variables.

Error =

Sample = ${NAME}

ifeq "${Sample}" ""
	Sample = ${name}
endif

ifeq "${Sample}" ""
	Error += The sample name must be provided
endif

# case tolerance
ifeq "${Sample}" "dumpfile"
	Sample = dumpfile/main
endif

TargetOS = ${OS}

ifeq "${TargetOS}" ""
	TargetOS = ${os}
endif

ifeq "${TargetOS}" ""
	TargetOS = ${MACHTYPE}${OSTYPE}
endif

ifeq "${TargetOS}" "i386linux"	# Linux ${MACHTYPE}${OSTYPE} is i386linux.
	TargetOS = i80386linux
endif

ifeq "${TargetOS}" "linux"
	TargetOS = i80386linux
endif

ifeq "${TargetOS}" "solaris"
	TargetOS = sparcsolaris
endif

ifneq "${TargetOS}" "i80386linux"
	ifneq "${TargetOS}" "sparcsolaris"
		Error += Invalid target OS "${TargetOS}"
	endif
endif

TargetStage = ${STAGE}

ifeq "${TargetStage}" ""
	TargetStage = ${stage}
endif

ifeq "${TargetStage}" ""
	TargetStage = debug
endif

ifneq "${TargetStage}" "debug"
	ifneq "${TargetStage}" "release"
		Error += Invalid target stage "${TargetStage}"
	endif
endif

ifeq "${TargetStage}" "debug"
   LibSuffix = StaticDebug
endif

ifeq "${TargetStage}" "release"
   LibSuffix = StaticRelease
endif

BuildRoot  = ../..
TargetRoot = ${BuildRoot}/target/${TargetOS}/${TargetStage}
TempRoot   = ${BuildRoot}/intermediate/${TargetOS}/${TargetStage}

# NB: this is SDKRoot to be exakt
XMPRoot    = ${BuildRoot}/..

LibXMP = ${XMPRoot}/public/libraries/${TargetOS}/${TargetStage}/libXMPCore${LibSuffix}.a

################################################################################################

CC  = gcc
CPP = gcc -x c++
LD  = gcc

CPPFlags =  -fexceptions -funsigned-char -fPIC -Wno-multichar -Wno-implicit -Wno-ctor-dtor-privacy
CPPFlags += -DUNIX_ENV=1 -D_FILE_OFFSET_BITS=64

LDFlags = 
LDLibs  =  ${LibXMP} -Xlinker -R -Xlinker .
LDLibs  += -lc -lm -lpthread -lstdc++

ifeq "${TargetOS}" "i80386linux"
	CPPFlags += -D__LITTLE_ENDIAN__=1
	LDLibs += -lgcc_eh
endif
ifeq "${TargetOS}" "sparcsolaris"
	CPPFlags += -mtune=ultrasparc -D__BIG_ENDIAN__=1
endif

ifeq "${TargetStage}" "debug"
	CPPFlags += -g -O0 -DDEBUG=1 -D_DEBUG=1
endif
ifeq "${TargetStage}" "release"
	CPPFlags += -O2 -Os -DNDEBUG=1
endif

################################################################################################

vpath %.cpp\
    ${BuildRoot}/source: \
    ${BuildRoot}/source/common:\
    ${XMPRoot}/source/common:

Includes = \
   -I${XMPRoot}/public/include \
   -I${XMPRoot}/samples/source/common \
   -I${XMPRoot}/source/common

DumfileCommonObj = \
	${TempRoot}/QELog.o \
	${TempRoot}/QETagTree.o \
	${TempRoot}/QEMemLeak.o \
	${TempRoot}/QEDumpFile.o \
	${TempRoot}/QEBuginese.o \
	${TempRoot}/LargeFileAccess.o \
	${TempRoot}/QEScanner.o
	
################################################################################################

${TempRoot}/%.o : %.c
	@echo ""
	@echo "Compiling $<"
	${CC} ${CPPFlags} ${Includes} -c $< -o $@

${TempRoot}/%.o : %.cpp
	@echo ""
	@echo "Compiling $<"
	${CPP} ${CPPFlags} ${Includes} -c $< -o $@

ifeq "${Sample}" "dumpfile/main"
${TargetRoot}/% :${TempRoot}/%.o ${DumfileCommonObj}
	@echo ""
	@echo "Linking ${TargetRoot}/dumpfile"
	${LD} ${LDFlags} $< ${DumfileCommonObj}  ${LDLibs} -o ${TargetRoot}/dumpfile
else
${TargetRoot}/% :${TempRoot}/%.o ${TempRoot}/XMPScanner.o
	@echo "Linking $@"
	${LD} ${LDFlags} $< ${TempRoot}/XMPScanner.o ${LDLibs} -o $@
endif
	

################################################################################################

Sample : Sample_ann msg create_dirs ${TargetRoot}/${Sample}
	@echo ""

Sample_ann : 
ifeq "${Error}" ""
	@echo ""
	@echo Building XMP sample ${Sample} for ${TargetOS} ${TargetStage}
endif

msg :
ifneq "${Error}" ""
	@echo ""
	@echo "Error: ${Error}"
	@echo ""
	@echo "# To build one of the XMP samples:"
	@echo "#   make -f XMPSamples.mak [os=<os>] [stage=<stage>] name=<sample>"
	@echo "# where"
	@echo "#   os    = i80386linux | sparcsolaris"
	@echo "#   stage = debug | release"
	@echo "#"

	@echo "# The name argument is the "simple name" of the sample:"
	@echo "# XMPCoreCoverage, CustomSchema or DumpScannedXMP."
	@echo "#"
	@echo "# If the os is omitted it will try to default from the OSTYPE and"
	@echo "# MACHTYPE environment variables. If the stage is omitted it"
	@echo "# defaults to debug."
	@echo ""
	exit 1
endif

create_dirs :
	mkdir -p ${TempRoot}
	mkdir -p ${TempRoot}/dumpfile
	mkdir -p ${TargetRoot}
	
.PHONY : clean

clean : msg
	# just to be extra safe:
	ifneq "${TempRoot}" ""
	ifneq "${TargetRoot}" ""
		rm -rf ${TempRoot}/*
	endif
	endif