1 | # $Id: Makefile.kmk 13 2008-04-20 10:13:43Z bird $
|
---|
2 | ## @file
|
---|
3 | # kProfiler Mark 2, sub-makefile.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
8 | #
|
---|
9 | # This file is part of kProfiler.
|
---|
10 | #
|
---|
11 | # kProfiler is free software; you can redistribute it and/or
|
---|
12 | # modify it under the terms of the GNU Lesser General Public
|
---|
13 | # License as published by the Free Software Foundation; either
|
---|
14 | # version 2.1 of the License, or (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kProfiler is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | # Lesser General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU Lesser General Public
|
---|
22 | # License along with kProfiler; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
24 | #
|
---|
25 |
|
---|
26 |
|
---|
27 | DEPTH ?= ..
|
---|
28 | SUB_DEPTH = ..
|
---|
29 | include $(PATH_KBUILD)/subheader.kmk
|
---|
30 |
|
---|
31 | #LIBRARIES += kPrf2GC kPrf2R0
|
---|
32 | DLLS += kPrf2
|
---|
33 | PROGRAMS += kPrf2Read
|
---|
34 |
|
---|
35 |
|
---|
36 | #
|
---|
37 | # Our template.
|
---|
38 | #
|
---|
39 | TEMPLATE_kPrf2 = kProfiler Template
|
---|
40 | if1of ($(BUILD_TARGET), win)
|
---|
41 | TEMPLATE_kPrf2_EXTENDS = kStuff
|
---|
42 |
|
---|
43 | else # Eliminate these
|
---|
44 | TEMPLATE_kPrf2_TOOL = GCC3
|
---|
45 | TEMPLATE_kPrf2_TOOL.os2 = GCC3OMF
|
---|
46 | TEMPLATE_kPrf2_TOOL.win.x86 = VCC70
|
---|
47 | TEMPLATE_kPrf2_TOOL.win.amd64 = VCC80AMD64
|
---|
48 | TEMPLATE_kPrf2_ASTOOL = YASM
|
---|
49 | TEMPLATE_kPrf2_ASTOOL.os2 = NASM
|
---|
50 |
|
---|
51 | TEMPLATE_kPrf2_SDKS.win = WINPSDK
|
---|
52 |
|
---|
53 | TEMPLATE_kPrf2_CXXFLAGS.freebsd = -g
|
---|
54 | TEMPLATE_kPrf2_CXXFLAGS.linux = -g
|
---|
55 | TEMPLATE_kPrf2_CXXFLAGS.os2 = -g
|
---|
56 | TEMPLATE_kPrf2_CXXFLAGS.win = -Zi -Zl -W3 -GF -GR-
|
---|
57 | TEMPLATE_kPrf2_CXXFLAGS.win.amd64 = -GS- #-FAcs
|
---|
58 | ifneq ($(BUILD_TYPE),debug)
|
---|
59 | TEMPLATE_kPrf2_CXXFLAGS.freebsd+= -O3
|
---|
60 | TEMPLATE_kPrf2_CXXFLAGS.linux += -O3
|
---|
61 | TEMPLATE_kPrf2_CXXFLAGS.os2 += -O3
|
---|
62 | TEMPLATE_kPrf2_CXXFLAGS.win += -O2b2
|
---|
63 | endif
|
---|
64 |
|
---|
65 | TEMPLATE_kPrf2_ASFLAGS.freebsd = -f elf
|
---|
66 | TEMPLATE_kPrf2_ASFLAGS.linux = -f elf
|
---|
67 | TEMPLATE_kPrf2_ASFLAGS.os2 = -f omf
|
---|
68 | TEMPLATE_kPrf2_ASFLAGS.win.x86 = -f win32 -g cv8
|
---|
69 | TEMPLATE_kPrf2_ASFLAGS.win.amd64 = -f win64 -g cv8
|
---|
70 |
|
---|
71 | TEMPLATE_kPrf2_INCS = \
|
---|
72 | ../include
|
---|
73 |
|
---|
74 | TEMPLATE_kPrf2_LDFLAGS.freebsd = -g
|
---|
75 | TEMPLATE_kPrf2_LDFLAGS.linux = -g
|
---|
76 | TEMPLATE_kPrf2_LDFLAGS.os2 = -g
|
---|
77 | TEMPLATE_kPrf2_LDFLAGS.win = /DEBUG
|
---|
78 |
|
---|
79 | TEMPLATE_kPrf2_LIBS.freebsd =
|
---|
80 | TEMPLATE_kPrf2_LIBS.linux =
|
---|
81 | TEMPLATE_kPrf2_LIBS.os2 =
|
---|
82 | TEMPLATE_kPrf2_LIBS.win = \
|
---|
83 | $(PATH_SDK_WINPSDK_LIB)/psapi.Lib
|
---|
84 | TEMPLATE_kPrf2_LIBS.win.x86 = \
|
---|
85 | $(PATH_TOOL_VCC70_LIB)/libcmt.lib \
|
---|
86 | $(PATH_TOOL_VCC70_LIB)/oldnames.lib
|
---|
87 | TEMPLATE_kPrf2_LIBS.win.amd64 = \
|
---|
88 | $(PATH_TOOL_VCC80AMD64_LIB)/oldnames.lib \
|
---|
89 | $(PATH_TOOL_VCC80AMD64_LIB)/libcmt.lib
|
---|
90 | endif
|
---|
91 |
|
---|
92 |
|
---|
93 | #
|
---|
94 | # kPrf2 - The profiler module.
|
---|
95 | #
|
---|
96 | kPrf2_TEMPLATE = kPrf2
|
---|
97 | kPrf2_DEFS.x86 = KPRF_BITS=32
|
---|
98 | kPrf2_DEFS.amd64 = KPRF_BITS=64
|
---|
99 | kPrf2_LDFLAGS.win.amd64 = -Entry:DllMain
|
---|
100 |
|
---|
101 | kPrf2_SOURCES = \
|
---|
102 | kProfileR3.cpp
|
---|
103 | # kProfileGC.cpp
|
---|
104 | # kProfileR0.cpp
|
---|
105 |
|
---|
106 | kPrf2_SOURCES.win = \
|
---|
107 | dllmain-win.cpp \
|
---|
108 | kPrf2WinApiWrapperHlp.c \
|
---|
109 | prf$(BUILD_TARGET_ARCH)msc.asm \
|
---|
110 | kPrf2-win-$(BUILD_TARGET_ARCH).def
|
---|
111 | prfx86msc.asm_DEFS.win.x86 = \
|
---|
112 | KPRF_ENTER=_KPrfEnter \
|
---|
113 | KPRF_LEAVE=_KPrfLeave
|
---|
114 | prfamd64msc.asm_DEFS.win.amd64 = \
|
---|
115 | KPRF_ENTER=KPrfEnter \
|
---|
116 | KPRF_LEAVE=KPrfLeave
|
---|
117 |
|
---|
118 | #
|
---|
119 | # kPrf2Read - The read & producer of statistics.
|
---|
120 | #
|
---|
121 | kPrf2Read_TEMPLATE = kStuffEXE
|
---|
122 | kPrf2Read_SOURCES = \
|
---|
123 | kPrf2Read.cpp
|
---|
124 | kPrf2Read_LIBS = \
|
---|
125 | $(PATH_LIB)/kDbgStatic$(SUFF_LIB) \
|
---|
126 | $(PATH_LIB)/kRdrStatic$(SUFF_LIB) \
|
---|
127 | $(PATH_LIB)/kHlpCRTStatic$(SUFF_LIB)
|
---|
128 |
|
---|
129 | #
|
---|
130 | # kPrf2WinApiWrappers
|
---|
131 | #
|
---|
132 | IMPORT_LIBS.win += kPrf2WinApiWrappersImp
|
---|
133 | kPrf2WinApiWrappersImp_TEMPLATE = kStuffEXE
|
---|
134 | kPrf2WinApiWrappersImp_SOURCES.x86 = kPrf2WinApiWrappersImp-x86.def
|
---|
135 | kPrf2WinApiWrappersImp_SOURCES.amd64 = kPrf2WinApiWrappersImp-amd64.def
|
---|
136 |
|
---|
137 | DLLS.win += kPrf2WinApiWrappers
|
---|
138 | kPrf2WinApiWrappers_TEMPLATE = kPrf2
|
---|
139 | kPrf2WinApiWrappers_CFLAGS = -GH -Gh
|
---|
140 | kPrf2WinApiWrappers_LDFLAGS.win.x86 = -Entry:DllMain@12
|
---|
141 | kPrf2WinApiWrappers_LDFLAGS.win.amd64 = -Entry:DllMain
|
---|
142 | kPrf2WinApiWrappers_SOURCES = \
|
---|
143 | kPrf2WinApiWrappers.c \
|
---|
144 | kPrf2WinApiWrappersImp-$(BUILD_TARGET_ARCH).def
|
---|
145 | kPrf2WinApiWrappers_LIBS = \
|
---|
146 | $(PATH_kPrf2)/kPrf2.lib
|
---|
147 |
|
---|
148 | ifeq (0,1)
|
---|
149 | kPrf2WinApiWrappers-kernel32.h:
|
---|
150 | $(SED) -f kPrf2WinApi-pre.sed --output $@.tmp \
|
---|
151 | $(PATH_SDK_WINPSDK_INC)/WinBase.h \
|
---|
152 | $(PATH_SDK_WINPSDK_INC)/WinCon.h \
|
---|
153 | $(PATH_SDK_WINPSDK_INC)/WinNLS.h \
|
---|
154 | $(PATH_SDK_WINPSDK_INC)/WinVer.h \
|
---|
155 | $(PATH_SDK_WINPSDK_INC)/WinNT.h \
|
---|
156 | $(PATH_SDK_WINPSDK_INC)/TlHelp32.h
|
---|
157 | $(APPEND) $@.tmp 'BOOL WINAPI ReplaceFile( LPCSTR lpReplacedFileName, LPCSTR lpReplacementFileName, LPCSTR lpBackupFileName, DWORD dwReplaceFlags, LPVOID lpExclude, LPVOID lpReserved );'
|
---|
158 | $(APPEND) $@.tmp 'BOOL WINAPI SetConsoleCursor( PVOID pvUnknown1, PVOID pvUnknown2 );'
|
---|
159 | $(APPEND) $@.tmp 'LPCH WINAPI GetEnvironmentStringsA( VOID );'
|
---|
160 | $(APPEND) $@.tmp 'BOOL WINAPI GetBinaryType( LPCSTR lpApplicationName, LPDWORD lpBinaryType );'
|
---|
161 | $(APPEND) $@.tmp 'WORD NTAPI RtlCaptureStackBackTrace( DWORD FramesToSkip, DWORD FramesToCapture, PVOID * BackTrace, PDWORD BackTraceHash );'
|
---|
162 | $(APPEND) $@.tmp 'PVOID RtlFillMemory( PVOID pv, int ch, SIZE_T cb );'
|
---|
163 | $(APPEND) $@.tmp 'PVOID RtlZeroMemory( PVOID pv, SIZE_T cb );'
|
---|
164 | $(APPEND) $@.tmp 'PVOID RtlMoveMemory( PVOID pvDst, PVOID pvSrc, SIZE_T cb );'
|
---|
165 | $(APPEND) $@.tmp 'VOID NTAPI RtlUnwind( PVOID TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue );'
|
---|
166 | $(APPEND) $@.tmp 'VOID NTAPI RtlUnwindEx( FRAME_POINTERS TargetFrame, PVOID TargetIp, PEXCEPTION_RECORD ExceptionRecord, PVOID ReturnValue, PCONTEXT ContextRecord, PUNWIND_HISTORY_TABLE HistoryTable );'
|
---|
167 | $(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 );'
|
---|
168 | $(APPEND) $@.tmp 'PVOID WINAPI RtlPcToFileHeader( PVOID PcValue, PVOID * BaseOfImage );'
|
---|
169 | $(APPEND) $@.tmp 'PVOID WINAPI RtlLookupFunctionEntry( ULONGLONG ControlPC, PULONGLONG ImageBase, PULONGLONG TargetGp );'
|
---|
170 | $(APPEND) $@.tmp 'void WINAPI RtlRaiseException(PEXCEPTION_RECORD pXcpRec);'
|
---|
171 | $(APPEND) $@.tmp 'int WINAPI uaw_lstrcmpW( LPCUWSTR lpString1, LPCUWSTR lpString2 );'
|
---|
172 | $(APPEND) $@.tmp 'int WINAPI uaw_lstrcmpiW( LPCUWSTR lpString1, LPCUWSTR lpString2 );'
|
---|
173 | $(APPEND) $@.tmp 'int WINAPI uaw_lstrlenW( LPCUWSTR lpString );'
|
---|
174 | $(APPEND) $@.tmp 'LPUWSTR WINAPI uaw_wcschr( LPCUWSTR lpString, WCHAR wc );'
|
---|
175 | $(APPEND) $@.tmp 'LPUWSTR WINAPI uaw_wcscpy( LPUWSTR lpDst, LPCUWSTR lpSrc );'
|
---|
176 | $(APPEND) $@.tmp 'int WINAPI uaw_wcsicmp( LPCUWSTR lp1, LPCUWSTR lp2 );'
|
---|
177 | $(APPEND) $@.tmp 'SIZE_T WINAPI uaw_wcslen( LPCUWSTR lp1 );'
|
---|
178 | $(APPEND) $@.tmp 'LPUWSTR WINAPI uaw_wcsrchr( LPCUWSTR lpString, WCHAR wc );'
|
---|
179 | $(APPEND) $@.tmp 'LPSTR WINAPI lstrcat( LPSTR lpString1, LPCSTR lpString2 );'
|
---|
180 | $(APPEND) $@.tmp 'int WINAPI lstrcmp( LPCSTR lpString1, LPCSTR lpString2 );'
|
---|
181 | $(APPEND) $@.tmp 'int WINAPI lstrcmpi( LPCSTR lpString1, LPCSTR lpString2 );'
|
---|
182 | $(APPEND) $@.tmp 'LPSTR WINAPI lstrcpy( LPSTR lpString1, LPCSTR lpString2 );'
|
---|
183 | $(APPEND) $@.tmp 'LPSTR WINAPI lstrcpyn( LPSTR lpString1, LPCSTR lpString2, int iMaxLength );'
|
---|
184 | $(APPEND) $@.tmp 'int WINAPI lstrlen( LPCSTR lpString );'
|
---|
185 | $(SED) -f kPrf2WinApi-gencode.sed --output $@ $@.tmp
|
---|
186 | $(RM) -f $@.tmp
|
---|
187 |
|
---|
188 | kPrf2WinApiWrappersImp-$(KBUILD_TARGET_ARCH).def:
|
---|
189 | $(RM) -f $@
|
---|
190 | $(PATH_TOOL_$(TEMPLATE_kStuff_TOOL.win.$(BUILD_TARGET_ARCH))_BIN)/dumpbin.exe /EXPORTS /OUT:$@.tmp $(PATH_SDK_WINPSDK_LIB)/Kernel32.lib
|
---|
191 | $(SED) -f kPrf2WinApi-dumpbin.sed --output $@.tmp2 $@.tmp
|
---|
192 | $(APPEND) $@ 'LIBRARY kPrf2WinApiWrappers'
|
---|
193 | $(APPEND) $@ 'EXPORTS'
|
---|
194 | $(SED) -f kPrf2WinApi-genimp.sed --append $@ $@.tmp2
|
---|
195 | $(RM) -f $@.tmp $@.tmp2
|
---|
196 | endif
|
---|
197 |
|
---|
198 | #
|
---|
199 | # A simple testcase.
|
---|
200 | #
|
---|
201 | PROGRAMS.win.x86 += tst
|
---|
202 | tst_TOOL = VCC70
|
---|
203 | tst_SDKS = WINPSDK
|
---|
204 | tst_CFLAGS = -GH -Gh -Zi -Zl -GR- -GX- -GF- -W3 -wd4244
|
---|
205 | tst_SOURCES = tst.c
|
---|
206 | tst.c_CFLAGS = -Od
|
---|
207 | tst_LDFLAGS = /DEBUG
|
---|
208 | tst_LIBS = \
|
---|
209 | $(PATH_TOOL_VCC70_LIB)/msvcrt.lib \
|
---|
210 | $(PATH_TOOL_VCC70_LIB)/msvcprt.lib \
|
---|
211 | $(PATH_TOOL_VCC70_LIB)/oldnames.lib \
|
---|
212 | $(PATH_kPrf2)/kPrf2.lib
|
---|
213 |
|
---|
214 | PROGRAMS += tstlongjmp
|
---|
215 | tstlongjmp_TEMPLATE = kStuffEXE
|
---|
216 | tstlongjmp_CFLAGS.win = -GH -Gh -Zi
|
---|
217 | tstlongjmp_SOURCES = tstlongjmp.c
|
---|
218 | tstlongjmp_LIBS = \
|
---|
219 | $(PATH_kPrf2)/kPrf2.lib
|
---|
220 |
|
---|
221 | # Generate the rules
|
---|
222 | include $(PATH_KBUILD)/subfooter.kmk
|
---|
223 |
|
---|
224 |
|
---|
225 | #
|
---|
226 | # Aliases for .cpp.h files so we can more easily do syntax checking from the editor.
|
---|
227 | #
|
---|
228 | CORE := $(wildcard *core*.cpp.h *core*.h.h)
|
---|
229 | $(CORE:.h=.o) $(CORE:.h=.obj) : kProfileR3.o
|
---|
230 |
|
---|
231 | READ := $(wildcard *read*.cpp.h *read*.h.h)
|
---|
232 | $(READ:.h=.o) $(READ:.h=.obj) : kPrf2Read.o
|
---|
233 |
|
---|