1 | # $Id: Makefile.kmk 29 2009-07-01 20:30:29Z bird $
|
---|
2 | ## @file
|
---|
3 | # kProfiler Mark 2, sub-makefile.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2006-2007 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
|
---|
8 | #
|
---|
9 | # Permission is hereby granted, free of charge, to any person
|
---|
10 | # obtaining a copy of this software and associated documentation
|
---|
11 | # files (the "Software"), to deal in the Software without
|
---|
12 | # restriction, including without limitation the rights to use,
|
---|
13 | # copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
14 | # copies of the Software, and to permit persons to whom the
|
---|
15 | # Software is furnished to do so, subject to the following
|
---|
16 | # conditions:
|
---|
17 | #
|
---|
18 | # The above copyright notice and this permission notice shall be
|
---|
19 | # included in all copies or substantial portions of the Software.
|
---|
20 | #
|
---|
21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
23 | # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
24 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
25 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
26 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
27 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
28 | # OTHER DEALINGS IN THE SOFTWARE.
|
---|
29 | #
|
---|
30 |
|
---|
31 | DEPTH ?= ..
|
---|
32 | SUB_DEPTH = ..
|
---|
33 | include $(PATH_KBUILD)/subheader.kmk
|
---|
34 |
|
---|
35 | #LIBRARIES += kPrf2GC kPrf2R0
|
---|
36 | DLLS += kPrf2
|
---|
37 | PROGRAMS += kPrf2Read
|
---|
38 |
|
---|
39 |
|
---|
40 | #
|
---|
41 | # Our template.
|
---|
42 | #
|
---|
43 | TEMPLATE_kPrf2 = kProfiler Template
|
---|
44 | if1of ($(BUILD_TARGET), win)
|
---|
45 | TEMPLATE_kPrf2_EXTENDS = kStuff
|
---|
46 |
|
---|
47 | else # Eliminate these
|
---|
48 | TEMPLATE_kPrf2_TOOL = GCC3
|
---|
49 | TEMPLATE_kPrf2_TOOL.os2 = GCC3OMF
|
---|
50 | TEMPLATE_kPrf2_TOOL.win.x86 = VCC70
|
---|
51 | TEMPLATE_kPrf2_TOOL.win.amd64 = VCC80AMD64
|
---|
52 | TEMPLATE_kPrf2_ASTOOL = YASM
|
---|
53 | TEMPLATE_kPrf2_ASTOOL.os2 = NASM
|
---|
54 |
|
---|
55 | TEMPLATE_kPrf2_SDKS.win = WINPSDK
|
---|
56 |
|
---|
57 | TEMPLATE_kPrf2_CXXFLAGS.freebsd = -g
|
---|
58 | TEMPLATE_kPrf2_CXXFLAGS.linux = -g
|
---|
59 | TEMPLATE_kPrf2_CXXFLAGS.os2 = -g
|
---|
60 | TEMPLATE_kPrf2_CXXFLAGS.win = -Zi -Zl -W3 -GF -GR-
|
---|
61 | TEMPLATE_kPrf2_CXXFLAGS.win.amd64 = -GS- #-FAcs
|
---|
62 | ifneq ($(BUILD_TYPE),debug)
|
---|
63 | TEMPLATE_kPrf2_CXXFLAGS.freebsd+= -O3
|
---|
64 | TEMPLATE_kPrf2_CXXFLAGS.linux += -O3
|
---|
65 | TEMPLATE_kPrf2_CXXFLAGS.os2 += -O3
|
---|
66 | TEMPLATE_kPrf2_CXXFLAGS.win += -O2b2
|
---|
67 | endif
|
---|
68 |
|
---|
69 | TEMPLATE_kPrf2_ASFLAGS.freebsd = -f elf
|
---|
70 | TEMPLATE_kPrf2_ASFLAGS.linux = -f elf
|
---|
71 | TEMPLATE_kPrf2_ASFLAGS.os2 = -f omf
|
---|
72 | TEMPLATE_kPrf2_ASFLAGS.win.x86 = -f win32 -g cv8
|
---|
73 | TEMPLATE_kPrf2_ASFLAGS.win.amd64 = -f win64 -g cv8
|
---|
74 |
|
---|
75 | TEMPLATE_kPrf2_INCS = \
|
---|
76 | ../include
|
---|
77 |
|
---|
78 | TEMPLATE_kPrf2_LDFLAGS.freebsd = -g
|
---|
79 | TEMPLATE_kPrf2_LDFLAGS.linux = -g
|
---|
80 | TEMPLATE_kPrf2_LDFLAGS.os2 = -g
|
---|
81 | TEMPLATE_kPrf2_LDFLAGS.win = /DEBUG
|
---|
82 |
|
---|
83 | TEMPLATE_kPrf2_LIBS.freebsd =
|
---|
84 | TEMPLATE_kPrf2_LIBS.linux =
|
---|
85 | TEMPLATE_kPrf2_LIBS.os2 =
|
---|
86 | TEMPLATE_kPrf2_LIBS.win = \
|
---|
87 | $(PATH_SDK_WINPSDK_LIB)/psapi.Lib
|
---|
88 | TEMPLATE_kPrf2_LIBS.win.x86 = \
|
---|
89 | $(PATH_TOOL_VCC70_LIB)/libcmt.lib \
|
---|
90 | $(PATH_TOOL_VCC70_LIB)/oldnames.lib
|
---|
91 | TEMPLATE_kPrf2_LIBS.win.amd64 = \
|
---|
92 | $(PATH_TOOL_VCC80AMD64_LIB)/oldnames.lib \
|
---|
93 | $(PATH_TOOL_VCC80AMD64_LIB)/libcmt.lib
|
---|
94 | endif
|
---|
95 |
|
---|
96 |
|
---|
97 | #
|
---|
98 | # kPrf2 - The profiler module.
|
---|
99 | #
|
---|
100 | kPrf2_TEMPLATE = kPrf2
|
---|
101 | kPrf2_DEFS.x86 = KPRF_BITS=32
|
---|
102 | kPrf2_DEFS.amd64 = KPRF_BITS=64
|
---|
103 | kPrf2_LDFLAGS.win.amd64 = -Entry:DllMain
|
---|
104 |
|
---|
105 | kPrf2_SOURCES = \
|
---|
106 | kProfileR3.cpp
|
---|
107 | # kProfileGC.cpp
|
---|
108 | # kProfileR0.cpp
|
---|
109 |
|
---|
110 | kPrf2_SOURCES.win = \
|
---|
111 | dllmain-win.cpp \
|
---|
112 | kPrf2WinApiWrapperHlp.c \
|
---|
113 | prf$(BUILD_TARGET_ARCH)msc.asm \
|
---|
114 | kPrf2-win-$(BUILD_TARGET_ARCH).def
|
---|
115 | prfx86msc.asm_DEFS.win.x86 = \
|
---|
116 | KPRF_ENTER=_KPrfEnter \
|
---|
117 | KPRF_LEAVE=_KPrfLeave
|
---|
118 | prfamd64msc.asm_DEFS.win.amd64 = \
|
---|
119 | KPRF_ENTER=KPrfEnter \
|
---|
120 | KPRF_LEAVE=KPrfLeave
|
---|
121 |
|
---|
122 | #
|
---|
123 | # kPrf2Read - The read & producer of statistics.
|
---|
124 | #
|
---|
125 | kPrf2Read_TEMPLATE = kStuffEXE
|
---|
126 | kPrf2Read_SOURCES = \
|
---|
127 | kPrf2Read.cpp
|
---|
128 | kPrf2Read_LIBS = \
|
---|
129 | $(PATH_LIB)/kDbgStatic$(SUFF_LIB) \
|
---|
130 | $(PATH_LIB)/kRdrStatic$(SUFF_LIB) \
|
---|
131 | $(PATH_LIB)/kHlpCRTStatic$(SUFF_LIB)
|
---|
132 |
|
---|
133 | #
|
---|
134 | # kPrf2WinApiWrappers
|
---|
135 | #
|
---|
136 | IMPORT_LIBS.win += kPrf2WinApiWrappersImp
|
---|
137 | kPrf2WinApiWrappersImp_TEMPLATE = kStuffEXE
|
---|
138 | kPrf2WinApiWrappersImp_SOURCES.x86 = kPrf2WinApiWrappersImp-x86.def
|
---|
139 | kPrf2WinApiWrappersImp_SOURCES.amd64 = kPrf2WinApiWrappersImp-amd64.def
|
---|
140 |
|
---|
141 | DLLS.win += kPrf2WinApiWrappers
|
---|
142 | kPrf2WinApiWrappers_TEMPLATE = kPrf2
|
---|
143 | kPrf2WinApiWrappers_CFLAGS = -GH -Gh
|
---|
144 | kPrf2WinApiWrappers_LDFLAGS.win.x86 = -Entry:DllMain@12
|
---|
145 | kPrf2WinApiWrappers_LDFLAGS.win.amd64 = -Entry:DllMain
|
---|
146 | kPrf2WinApiWrappers_SOURCES = \
|
---|
147 | kPrf2WinApiWrappers.c \
|
---|
148 | kPrf2WinApiWrappersImp-$(BUILD_TARGET_ARCH).def
|
---|
149 | kPrf2WinApiWrappers_LIBS = \
|
---|
150 | $(PATH_kPrf2)/kPrf2.lib
|
---|
151 |
|
---|
152 | ifeq (0,1)
|
---|
153 | kPrf2WinApiWrappers-kernel32.h:
|
---|
154 | $(SED) -f kPrf2WinApi-pre.sed --output $@.tmp \
|
---|
155 | $(PATH_SDK_WINPSDK_INC)/WinBase.h \
|
---|
156 | $(PATH_SDK_WINPSDK_INC)/WinCon.h \
|
---|
157 | $(PATH_SDK_WINPSDK_INC)/WinNLS.h \
|
---|
158 | $(PATH_SDK_WINPSDK_INC)/WinVer.h \
|
---|
159 | $(PATH_SDK_WINPSDK_INC)/WinNT.h \
|
---|
160 | $(PATH_SDK_WINPSDK_INC)/TlHelp32.h
|
---|
161 | $(APPEND) $@.tmp 'BOOL WINAPI ReplaceFile( LPCSTR lpReplacedFileName, LPCSTR lpReplacementFileName, LPCSTR lpBackupFileName, DWORD dwReplaceFlags, LPVOID lpExclude, LPVOID lpReserved );'
|
---|
162 | $(APPEND) $@.tmp 'BOOL WINAPI SetConsoleCursor( PVOID pvUnknown1, PVOID pvUnknown2 );'
|
---|
163 | $(APPEND) $@.tmp 'LPCH WINAPI GetEnvironmentStringsA( VOID );'
|
---|
164 | $(APPEND) $@.tmp 'BOOL WINAPI GetBinaryType( LPCSTR lpApplicationName, LPDWORD lpBinaryType );'
|
---|
165 | $(APPEND) $@.tmp 'WORD NTAPI RtlCaptureStackBackTrace( DWORD FramesToSkip, DWORD FramesToCapture, PVOID * BackTrace, PDWORD BackTraceHash );'
|
---|
166 | $(APPEND) $@.tmp 'PVOID RtlFillMemory( PVOID pv, int ch, SIZE_T cb );'
|
---|
167 | $(APPEND) $@.tmp 'PVOID RtlZeroMemory( PVOID pv, SIZE_T cb );'
|
---|
168 | $(APPEND) $@.tmp 'PVOID RtlMoveMemory( PVOID pvDst, PVOID pvSrc, SIZE_T cb );'
|
---|
169 | $(APPEND) $@.tmp 'VOID NTAPI RtlUnwind( PVOID TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue );'
|
---|
170 | $(APPEND) $@.tmp 'VOID NTAPI RtlUnwindEx( FRAME_POINTERS TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue, PCONTEXT ContextRecord, PUNWIND_HISTORY_TABLE HistoryTable );'
|
---|
171 | $(APPEND) $@.tmp 'ULONGLONG WINAPI RtlVirtualUnwind( ULONG HandlerType, ULONGLONG ImageBase, ULONGLONG ControlPC, PRUNTIME_FUNCTION FunctionEntry, PCONTEXT ContextRecord, PBOOLEAN InFunction, PFRAME_POINTERS EstablisherFrame, PKNONVOLATILE_CONTEXT_POINTERS ContextPointers );'
|
---|
172 | $(APPEND) $@.tmp 'PVOID WINAPI RtlPcToFileHeader( PVOID PcValue, PVOID * BaseOfImage );'
|
---|
173 | $(APPEND) $@.tmp 'PVOID WINAPI RtlLookupFunctionEntry( ULONGLONG ControlPC, PULONGLONG ImageBase, PULONGLONG TargetGp );'
|
---|
174 | $(APPEND) $@.tmp 'void WINAPI RtlRaiseException(PEXCEPTION_RECORD pXcpRec);'
|
---|
175 | $(APPEND) $@.tmp 'int WINAPI uaw_lstrcmpW( LPCUWSTR lpString1, LPCUWSTR lpString2 );'
|
---|
176 | $(APPEND) $@.tmp 'int WINAPI uaw_lstrcmpiW( LPCUWSTR lpString1, LPCUWSTR lpString2 );'
|
---|
177 | $(APPEND) $@.tmp 'int WINAPI uaw_lstrlenW( LPCUWSTR lpString );'
|
---|
178 | $(APPEND) $@.tmp 'LPUWSTR WINAPI uaw_wcschr( LPCUWSTR lpString, WCHAR wc );'
|
---|
179 | $(APPEND) $@.tmp 'LPUWSTR WINAPI uaw_wcscpy( LPUWSTR lpDst, LPCUWSTR lpSrc );'
|
---|
180 | $(APPEND) $@.tmp 'int WINAPI uaw_wcsicmp( LPCUWSTR lp1, LPCUWSTR lp2 );'
|
---|
181 | $(APPEND) $@.tmp 'SIZE_T WINAPI uaw_wcslen( LPCUWSTR lp1 );'
|
---|
182 | $(APPEND) $@.tmp 'LPUWSTR WINAPI uaw_wcsrchr( LPCUWSTR lpString, WCHAR wc );'
|
---|
183 | $(APPEND) $@.tmp 'LPSTR WINAPI lstrcat( LPSTR lpString1, LPCSTR lpString2 );'
|
---|
184 | $(APPEND) $@.tmp 'int WINAPI lstrcmp( LPCSTR lpString1, LPCSTR lpString2 );'
|
---|
185 | $(APPEND) $@.tmp 'int WINAPI lstrcmpi( LPCSTR lpString1, LPCSTR lpString2 );'
|
---|
186 | $(APPEND) $@.tmp 'LPSTR WINAPI lstrcpy( LPSTR lpString1, LPCSTR lpString2 );'
|
---|
187 | $(APPEND) $@.tmp 'LPSTR WINAPI lstrcpyn( LPSTR lpString1, LPCSTR lpString2, int iMaxLength );'
|
---|
188 | $(APPEND) $@.tmp 'int WINAPI lstrlen( LPCSTR lpString );'
|
---|
189 | $(SED) -f kPrf2WinApi-gencode.sed --output $@ $@.tmp
|
---|
190 | $(RM) -f $@.tmp
|
---|
191 |
|
---|
192 | kPrf2WinApiWrappersImp-$(KBUILD_TARGET_ARCH).def:
|
---|
193 | $(RM) -f $@
|
---|
194 | $(PATH_TOOL_$(TEMPLATE_kStuff_TOOL.win.$(BUILD_TARGET_ARCH))_BIN)/dumpbin.exe /EXPORTS /OUT:$@.tmp $(PATH_SDK_WINPSDK_LIB)/Kernel32.lib
|
---|
195 | $(SED) -f kPrf2WinApi-dumpbin.sed --output $@.tmp2 $@.tmp
|
---|
196 | $(APPEND) $@ 'LIBRARY kPrf2WinApiWrappers'
|
---|
197 | $(APPEND) $@ 'EXPORTS'
|
---|
198 | $(SED) -f kPrf2WinApi-genimp.sed --append $@ $@.tmp2
|
---|
199 | $(RM) -f $@.tmp $@.tmp2
|
---|
200 | endif
|
---|
201 |
|
---|
202 | #
|
---|
203 | # A simple testcase.
|
---|
204 | #
|
---|
205 | PROGRAMS.win.x86 += tst
|
---|
206 | tst_TOOL = VCC70
|
---|
207 | tst_SDKS = WINPSDK
|
---|
208 | tst_CFLAGS = -GH -Gh -Zi -Zl -GR- -GX- -GF- -W3 -wd4244
|
---|
209 | tst_SOURCES = tst.c
|
---|
210 | tst.c_CFLAGS = -Od
|
---|
211 | tst_LDFLAGS = /DEBUG
|
---|
212 | tst_LIBS = \
|
---|
213 | $(PATH_TOOL_VCC70_LIB)/msvcrt.lib \
|
---|
214 | $(PATH_TOOL_VCC70_LIB)/msvcprt.lib \
|
---|
215 | $(PATH_TOOL_VCC70_LIB)/oldnames.lib \
|
---|
216 | $(PATH_kPrf2)/kPrf2.lib
|
---|
217 |
|
---|
218 | PROGRAMS += tstlongjmp
|
---|
219 | tstlongjmp_TEMPLATE = kStuffEXE
|
---|
220 | tstlongjmp_CFLAGS.win = -GH -Gh -Zi
|
---|
221 | tstlongjmp_SOURCES = tstlongjmp.c
|
---|
222 | tstlongjmp_LIBS = \
|
---|
223 | $(PATH_kPrf2)/kPrf2.lib
|
---|
224 |
|
---|
225 | # Generate the rules
|
---|
226 | include $(PATH_KBUILD)/subfooter.kmk
|
---|
227 |
|
---|
228 |
|
---|
229 | #
|
---|
230 | # Aliases for .cpp.h files so we can more easily do syntax checking from the editor.
|
---|
231 | #
|
---|
232 | CORE := $(wildcard *core*.cpp.h *core*.h.h)
|
---|
233 | $(CORE:.h=.o) $(CORE:.h=.obj) : kProfileR3.o
|
---|
234 |
|
---|
235 | READ := $(wildcard *read*.cpp.h *read*.h.h)
|
---|
236 | $(READ:.h=.o) $(READ:.h=.obj) : kPrf2Read.o
|
---|
237 |
|
---|