blob: bd41bf68ea8cec000f2b7b9d25f1281a789c4859 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# ------------------------------------------------------------------------ #
2# Compiler makefile for Microsoft Visual C++ 6.0 #
3# ------------------------------------------------------------------------ #
4.PHONY :
5
6# ------------------------------------------------------------------------ #
7# Compiler tools
8# ------------------------------------------------------------------------ #
9CC = cl.exe
10CPP = cl.exe
11THUMBCC = cl.exe
12THUMBCPP = cl.exe
13ASM =
14LINK = link.exe
15CONV =
16AR = lib.exe
17
18
19
20# ---------------------------------------------------------------------------
21# Apply Rational Realtime when CODECOVERAGE=YES
22# ---------------------------------------------------------------------------
23# todo: for backward compatibility, should be removed later
24ifeq '$(DEBUGINFO)' ''
25 ifeq '$(BUILDMODE)' 'DEBUG'
26 DEBUGINFO=YES
27 endif
28endif
29
30ifeq '${CODECOVERAGE}' 'YES'
31ifeq '${TESTENVIRONMENT}' 'URRCM'
32ifneq '$(findstring ${BUILD_LIB},urrc urrcbp urrcdc urrcm)' ''
33CC = attolcc -proc=ret -call -block=logical -cond=modified -count --atl_multi_treads=1 -- cl.exe
34endif # ifneq '$(findstring ${BUILD_LIB},urrc urrcbp urrcdc urrcm)' ''
35endif # ifeq '${TESTENVIRONMENT}' 'URRCM'
36
37ifeq '${TESTENVIRONMENT}' 'UPDCP'
38ifneq '$(findstring ${BUILD_LIB},urabmupdcp sif)' ''
39CC = attolcc -proc=ret -call -block=logical -cond=modified -count --atl_multi_treads=1 -- cl.exe
40endif # ifneq '$(findstring ${BUILD_LIB},urabmupdcp sif)' ''
41endif # ifeq '${TESTENVIRONMENT}' 'UPDCP'
42
43ifeq '${TESTENVIRONMENT}' 'URLC'
44ifneq '$(findstring ${BUILD_LIB},urlcc urlcdl urlcul)' ''
45CC = attolcc -proc=ret -call -block=logical -cond=modified -count --atl_multi_treads=1 -- cl.exe
46endif # ifneq '$(findstring ${BUILD_LIB},urlcc urlcdl urlcul)' ''
47endif # ifeq '${TESTENVIRONMENT}' 'URLC'
48
49ifeq '${TESTENVIRONMENT}' 'UMAC'
50ifneq '$(findstring ${BUILD_LIB},umac security ugdci)' ''
51CC = attolcc -proc=ret -call -block=logical -cond=modified -count --atl_multi_treads=1 -- cl.exe
52endif # ifneq '$(findstring ${BUILD_LIB},umac security ugdci)' ''
53endif # ifeq '${TESTENVIRONMENT}' 'UMAC'
54
55ifeq '${TESTENVIRONMENT}' 'USIM'
56ifneq '$(findstring ${BUILD_LIB},usim)' ''
57CC = attolcc -proc=ret -call -block=logical -cond=modified -count --atl_multi_treads=1 -- cl.exe
58endif # ifneq '$(findstring ${BUILD_LIB},usim)' ''
59endif # ifeq '${TESTENVIRONMENT}' 'USIM'
60
61endif # ifeq '${CODECOVERAGE}' 'YES'
62
63# ------------------------------------------------------------------------ #
64# Extensions for standard files
65# ------------------------------------------------------------------------ #
66OBJFILEEXT = obj
67DEPFILEEXT = dep
68OUTPUTFILEEXT = exe
69SRCFILEEXT = src
70MAPFILEEXT = map
71LIBFILEEXT = lib
72ERRFILEEXT = err
73SBRFILEEXT = sbr
74PDBFILEEXT = pdb
75
76CC_DEFPREFIX = -D
77CC_INCPREFIX = -I
78
79export COMPILER_VERSION := $(shell $(CC) 2>&1 | $(SED) -n "s/.*Version *\([0-9]*\).*/\1/p")
80
81msvc_version :
82 -@$(ECHO) "COMPILER VERSION: $(COMPILER_VERSION)"
83
84
85# ======================================================================== #
86# Common compiler switches for C and C++ compiler
87# ======================================================================== #
88CC_CPP_OPTIONS = /nologo # no logo and info messages
89
90ifeq '$(WARNINGS)' 'YES'
91 CC_CPP_OPTIONS += /W3 # Warning level 3 - recommended for production purposes
92else
93ifeq '$(WARNINGS)' 'NO'
94 CC_CPP_OPTIONS += /W0 # Warning level 0 - disable all warnings
95else
96 CC_CPP_OPTIONS += /W3 # Warning level 3 - default
97endif
98endif
99
100CC_CPP_OPTIONS += /c # compile without linking
101CC_CPP_OPTIONS += /Od # no optimization, speed compilation, debugging
102CC_CPP_OPTIONS += ${CC_DEFPREFIX}_MBCS # default define:
103CC_CPP_OPTIONS += ${CC_DEFPREFIX}_MSC # default define:
104CC_CPP_OPTIONS += ${CC_DEFPREFIX}_CONSOLE # default define:
105CC_CPP_OPTIONS += ${CC_DEFPREFIX}_LIB # default define:
106CC_CPP_OPTIONS += ${CC_DEFPREFIX}_Windows # default define:
107CC_CPP_OPTIONS += ${CC_DEFPREFIX}MSVCWIN # default define:
108CC_CPP_OPTIONS += ${CC_DEFPREFIX}_WIN32 # default define:
109
110ifeq '$(DEBUGINFO)' 'YES' # --- debug info
111 CC_CPP_OPTIONS += ${CC_DEFPREFIX}_DEBUG
112 CC_CPP_OPTIONS += /MTd # multithread debug
113 ifeq '$(COMPILER_VERSION)' '14'
114 CC_CPP_OPTIONS += /RTC1 # catch release build errors
115 else
116 CC_CPP_OPTIONS += /GZ # catch release build errors
117 endif
118 CC_CPP_OPTIONS += /Zi # create additional debug library
119 CC_CPP_OPTIONS += /Fd${LIBDIR}/$(basename ${BUILD_LIB}).${PDBFILEEXT} # location of PDB library
120else # --- release mode
121 CC_CPP_OPTIONS += /MT # multithread
122 CC_CPP_OPTIONS += /Gi- # dissable incremental compilation
123endif
124
125ifneq '$(TESTENVIRONMENT)' ''
126 CC_CPP_OPTIONS += /D__thumb # compile test build like target build
127 CC_CPP_OPTIONS += /DUNITEST # define UniTest build
128 CC_CPP_OPTIONS += /DSID_DEFINED #
129 CC_CPP_OPTIONS += /DWIN32_LEAN_AND_MEAN # don't include unwanted Microsoft specific header files
130 CC_CPP_OPTIONS += /DNOGDI # ditto
131 CC_CPP_OPTIONS += /DNOCRYPT # ditto
132endif
133
134# --- add compiler and library specific compile switches
135CC_CPP_OPTIONS += ${MSVC_OPTIONS} $(MSVC_CC_CPP_OPTIONS_$(BUILD_LIB))
136
137# --- assembler files - not used yet
138ifneq '$(ASMCODEGEN)' ''
139endif
140
141# --- the *_CMD variable contains options that may not go into via-file
142CC_CPP_OPTIONS_CMD += /Fo${OBJDIR}/${BUILD_LIB}/$(@F) # specifiy obj name
143CC_CPP_OPTIONS_CMD += $(subst \,/,$<) # source file
144ifneq '$(TESTENVIRONMENT)' ''
145 CC_CPP_OPTIONS_CMD += /FR${SBRDIR}/${BUILD_LIB}/$(basename ${@F}).${SBRFILEEXT} # create browse info file
146endif
147ifeq '${ERRORLOG}' 'YES'
148 CC_CPP_OPTIONS_CMD += 2>&1 > ${ERRDIR}/${BUILD_LIB}/$(basename ${@F}).${ERRFILEEXT}
149endif
150
151
152# ======================================================================== #
153# C and C++ specific compiler switches
154# ======================================================================== #
155CC_INCL = $(strip $(addprefix ${CC_INCPREFIX}, \
156 ${CC_INCLUDE} \
157 ${${BUILD_LIB}_INC} \
158 ) )
159CC_DEF = $(strip $(addprefix ${CC_DEFPREFIX},$(SYSTEM_DEFS) \
160 ${L1_DEFS} \
161 ${CC_DEFS} \
162 ${CCC_DEFS_PLATFORM} ) )
163CPP_INCL = $(strip $(addprefix ${CC_INCPREFIX}, \
164 ${CPP_INCLUDE} \
165 ${${BUILD_LIB}_INC}\
166 ) )
167CPP_DEF = $(strip $(addprefix ${CC_DEFPREFIX},${SYSTEM_DEFS} \
168 ${L1_DEFS} \
169 ${CPP_DEFS} \
170 ${CPP_DEFS_PLATFORM} ) )
171
172CC_OPTIONS = ${CC_INCL} ${CC_DEF} ${MSVC_CC_OPTIONS} $(MSVC_CC_OPTIONS_$(BUILD_LIB))
173CPP_OPTIONS = ${CPP_INCL} ${CPP_DEF} ${MSVC_CPP_OPTIONS} $(MSVC_CPP_OPTIONS_$(BUILD_LIB))
174CPP_OPTIONS+= -we4150 # turn warning C4150 into error since it's to serious
175
176# precompiled header are only supported for cpp
177ifeq '$(findstring hpp,${PCH_FILE})' 'hpp'
178 PCH_FILENAME = ${OBJDIR}/$(BUILD_LIB)/$(basename $(PCH_BUILD_FILE)).pch
179 # add pch-options to source-options
180 PCH_USE_OPTIONS += /Yu${PCH_FILE} /Fp${PCH_FILENAME}
181 # build specific pch-options
182 PCH_CREATE_OPTIONS += /Yc${PCH_FILE} /Fp${PCH_FILENAME}
183endif
184
185
186# ======================================================================== #
187# combining, via files
188# ======================================================================== #
189CC_COMPLETE_TMP = ${CC_CPP_OPTIONS} ${CC_OPTIONS}
190CPP_COMPLETE_TMP = ${CC_CPP_OPTIONS} ${CPP_OPTIONS} ${PCH_USE_OPTIONS}
191PCH_COMPLETE_TMP = ${CC_CPP_OPTIONS} ${CPP_OPTIONS} ${PCH_CREATE_OPTIONS}
192
193ifeq '${VIAFILE}' 'YES'
194 VIA_CC_COMPLETE = ${CC_COMPLETE_TMP}
195 VIA_CPP_COMPLETE = ${CPP_COMPLETE_TMP}
196 VIA_PCH_COMPLETE = ${PCH_COMPLETE_TMP}
197 CC_COMPLETE = @${OBJDIR}/${BUILD_LIB}/cc.via
198 CPP_COMPLETE = @${OBJDIR}/${BUILD_LIB}/cpp.via
199 PCH_COMPLETE = @${OBJDIR}/${BUILD_LIB}/pch.via
200else
201 CC_COMPLETE = ${CC_COMPLETE_TMP}
202 CPP_COMPLETE = ${CPP_COMPLETE_TMP}
203 PCH_COMPLETE = ${PCH_COMPLETE_TMP}
204endif # VIAFILE
205
206
207# ======================================================================== #
208# command lines
209# ======================================================================== #
210ASM_CMDLINE = # we're not using an assembler on win32
211ifeq '$(ERRORLOG)' 'YES'
212 CMDLINE_ERROR_POSTPROC=|| ( $(CAT) ${ERRDIR}/${BUILD_LIB}/$(basename ${@F}).${ERRFILEEXT} && exit 3)
213endif
214
215ASM_CMDLINE = # we're not using an assembler on win32
216CC_CMDLINE = $(strip ${CC} ${CC_COMPLETE} ${CC_CPP_OPTIONS_CMD} ) $(CMDLINE_ERROR_POSTPROC)
217CPP_CMDLINE = $(strip ${CPP} ${CPP_COMPLETE} ${CC_CPP_OPTIONS_CMD} ) $(CMDLINE_ERROR_POSTPROC)
218PCH_CMDLINE = $(strip ${CPP} ${PCH_COMPLETE} ${CC_CPP_OPTIONS_CMD} ) $(CMDLINE_ERROR_POSTPROC)
219
220
221
222# no specific THUMB-stuff!
223THUMBCC_CMDLINE = ${CC_CMDLINE}
224THUMBCPP_CMDLINE = ${CPP_CMDLINE}
225
226
227# ------------------------------------------------------------------------ #
228# Howto make dependencies per file
229# ------------------------------------------------------------------------ #
230# jwo: dep/file deactivated as we build dep-file on a per-lib base
231ifeq '0' '1'
232CC_MAKEDEP_CMDLINE = ${MKDEP} \
233 $(addprefix /I ,$(subst /,\,${${BUILD_LIB}_INC})) \
234 /T "" \
235 /X \
236 /o $(subst /,\,${DEPDIR}/${BUILD_LIB}/${BUILD_LIB}.${DEPFILEEXT}) \
237 $(subst /,\,$^)
238THUMBCC_MAKEDEP_CMDLINE = ${CC_MAKEDEP_CMDLINE}
239CPP_MAKEDEP_CMDLINE = ${CC_MAKEDEP_CMDLINE}
240THUMBCPP_MAKEDEP_CMDLINE = ${CC_MAKEDEP_CMDLINE}
241endif
242
243# ------------------------------------------------------------------------ #
244# How to run the SDL code generation
245# ------------------------------------------------------------------------ #
246runsdlcmd:
247 $(SDL_MAKE_CMD)
248
249
250# ------------------------------------------------------------------------ #
251# Target rule for 'all'
252# ------------------------------------------------------------------------ #
253ifeq '${SDLCODEGEN}' 'YES'
254 all: runsdlcmd runsdlscr config createdirs ${MAKEDIR}/${PROJECTNAME}.${OUTPUTFILEEXT}
255else # SDLCODEGEN
256 ifeq '${SDLSCR}' 'YES'
257 all: runsdlscr config createdirs ${MAKEDIR}/${PROJECTNAME}.${OUTPUTFILEEXT}
258 else # SDLSCR
259 all: config createdirs ${MAKEDIR}/${PROJECTNAME}.${OUTPUTFILEEXT}
260 endif # SDL source code reduction
261endif # SDLCODEGEN
262
263
264# ------------------------------------------------------------------------ #
265# creating the .lib
266# ------------------------------------------------------------------------ #
267L_OPTIONS = /nologo
268LINKER_CMDLINE=${AR}
269FILTEROUTFILE = $(notdir $(LIB_DEPFILE)) # jwo probably using $^ instead of ^F would be smarter
270ifeq '${VIAFILE}' 'YES'
271 LINKER_CMDLINE += @${OBJDIR}/${BUILD_LIB}/lib.via
272 VIA_LIB_COMPLETE = \
273 ${L_OPTIONS} \
274 /MACHINE:IX86 \
275 /out:${LIBDIR}/${BUILD_LIB}.${LIBFILEEXT} \
276 $(addprefix ${OBJDIR}/${BUILD_LIB}/,$(filter-out ${FILTEROUTFILE},$(^F))) \
277 ${OBJSTOLINK}
278else
279 LINKER_CMDLINE += \
280 ${L_OPTIONS} \
281 /MACHINE:IX86 \
282 /out:${LIBDIR}/${BUILD_LIB}.${LIBFILEEXT} \
283 $(addprefix ${OBJDIR}/${BUILD_LIB}/,$(filter-out ${FILTEROUTFILE},$(^F))) \
284 ${OBJSTOLINK}
285endif
286
287
288# ------------------------------------------------------------------------ #
289# Linker
290# ------------------------------------------------------------------------ #
291L_FLAGS = /subsystem:console
292L_FLAGS += /machine:I386
293L_FLAGS += /pdbtype:sept
294L_FLAGS += /verbose:lib
295L_FLAGS += /nodefaultlib:libc.lib
296L_FLAGS += /nodefaultlib:libcd.lib
297L_FLAGS += /nodefaultlib:libcmt.lib
298L_FLAGS += /nodefaultlib:libcmtd.lib
299
300L_STANDARDLIBS = # init
301ifeq '$(DEBUGINFO)' 'YES'
302 L_STANDARDLIBS += libcmtd.lib
303else
304 L_STANDARDLIBS += libcmt.lib
305endif
306L_STANDARDLIBS += kernel32.lib
307L_STANDARDLIBS += user32.lib
308L_STANDARDLIBS += ws2_32.lib
309L_STANDARDLIBS += netapi32.lib
310L_STANDARDLIBS += comctl32.lib
311L_STANDARDLIBS += gdi32.lib
312L_STANDARDLIBS += comdlg32.lib
313L_STANDARDLIBS += advapi32.lib
314L_STANDARDLIBS += winmm.lib
315L_STANDARDLIBS += imagehlp.lib
316L_STANDARDLIBS += shell32.lib
317
318# todo: check & fix this, why do apoxi need DEBUG always?
319ifeq '$(findstring APOXI,${APPLICATIONS})' 'APOXI'
320 L_FLAGS += /DEBUG
321else # APOXI
322 ifeq '$(DEBUGINFO)' 'YES'
323 L_FLAGS += /DEBUG
324 else
325 ifeq '$(findstring ${BUILD_LIB},${DEBUGLIBS})' '${BUILD_LIB}'
326 L_FLAGS += /DEBUG
327 endif # DEBUGMODE
328 endif # DEBUGMODE
329endif # APOXI
330
331
332# ------------------------------------------------------------------------ #
333# Target rule for 'link'ing executable
334# ------------------------------------------------------------------------ #
335ARC_CMDLINE = ${LINK} ${L_FLAGS}
336ARC_CMDLINE += /out:${MAKEDIR}/${PROJECTNAME}.${OUTPUTFILEEXT}
337ifeq '$(DEBUGINFO)' 'YES'
338 ARC_CMDLINE += /pdb:${MAKEDIR}/${PROJECTNAME}.pdb
339endif
340ARC_CMDLINE += /libpath:${LIBDIR}
341ARC_CMDLINE += /libpath:${GLOBALPATH}/stack-interface/sdl/msvc50
342ARC_CMDLINE += ${L_STANDARDLIBS}
343ARC_CMDLINE += ${LIBSTOBUILD} ${LIBSTOLINK}
344
345link: ${MAKEDIR}/sys_version.c
346 $(ECHO) Creating executable $(MAKEDIR)/$(PROJECTNAME).${OUTPUTFILEEXT} ...
347 ${ARC_CMDLINE}
348ifneq '${CMDPEREXE}' ''
349 ${CMDPEREXE}
350endif # CMDPEREXE
351
352
353# ------------------------------------------------------------------------ #
354# Rule to build the executable
355# ------------------------------------------------------------------------ #
356${MAKEDIR}/${PROJECTNAME}.${OUTPUTFILEEXT} : ${LIBSTOBUILD}
357 $(MAKE) link
358
359
360
361# ------------------------------------------------------------------------
362# create a dependency file per lib
363# msvc doesn't provide dep-generation so mkdep.exe (comneon-made, not to be
364# mixed up with gnu's mkdep) is used
365# there is one dependency file per library <lib>.dep
366# ------------------------------------------------------------------------
367#
368ifneq '$(DEPENDENCIES)' 'NO'
369 LIB_DEPFILE=${DEPDIR}/${BUILD_LIB}/${BUILD_LIB}.$(DEPFILEEXT)
370endif
371
372# adapt pathes to cygwin
373ifeq '${BUILDPCOS}' 'WIN32'
374PATH_DELIM=\\
375else
376PATH_DELIM=/
377endif
378
379# adapt path of executable
380MKDEP := $(subst \,${PATH_DELIM},${MKDEP})
381
382# this is tricky, but mkdep expects INCLUDE_DEP to contain a ";" separated list of directories
383# add a ":" before and after each token, then we replace ": :" with ";" and remove single ":" (start & end)
384NULL:=
385SPACE:= $(NULL) # this is a space
386# we don't modify INCLUDE as this is used by compilers; muc uses "include" (lowercase)
387export INCLUDE_DEP=$(strip $(INCLUDE))$(strip $(include))
388INCLUDE_DEP +=$(strip $(subst :,,$(subst : :,;,$(addprefix :,$(addsuffix :,${${BUILD_LIB}_INC})))))
389INCLUDE_DEP:=$(subst ;$(SPACE),;,$(INCLUDE_DEP))
390
391${DEPDIR}/${BUILD_LIB}/${BUILD_LIB}.$(DEPFILEEXT) : \
392 ${${BUILD_LIB}_THUMB_FILES} \
393 ${${BUILD_LIB}_FILES}
394 -@$(ECHO) --- generating dependency file $@ ---
395 # this command get's too long most of the time so we create a viafile anyway
396 $(shell echo $(wordlist 1,1,$($^)) > ${DEPDIR}/${BUILD_LIB}/${BUILD_LIB}.via )
397 $(foreach str, $^, $(shell echo ${str} >> ${DEPDIR}/${BUILD_LIB}/${BUILD_LIB}.via) )
398 ${MKDEP} \
399 /T "$(OBJ_DIR)" \
400 /X \
401 /E INCLUDE_DEP \
402 /o $(subst /,${PATH_DELIM},${DEPDIR}/${BUILD_LIB}/${BUILD_LIB}.${DEPFILEEXT}) \
403 @$(subst /,${PATH_DELIM},${DEPDIR}/${BUILD_LIB}/${BUILD_LIB}.via)
404# /T <dir> obj file directory <dir>
405# /X enable unix style ("/") support
406# /o write output to file <file>
407# /v verbose output
408# /S<c> file separator (\ by default)
409# /i<c> inc path seperator (; by default)
410# /x o generate dependencies with .o files (.obj is default)
411# $(addprefix /I ,$(subst /,\,${${BUILD_LIB}_INC}))
412