VirtualBox

source: kStuff/trunk/kProfiler2/Makefile.kmk@ 13

Last change on this file since 13 was 13, checked in by bird, 17 years ago

Made it (winapi wrapping) work.

  • Property svn:keywords set to Id Revision
File size: 8.4 KB
Line 
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
27DEPTH ?= ..
28SUB_DEPTH = ..
29include $(PATH_KBUILD)/subheader.kmk
30
31#LIBRARIES += kPrf2GC kPrf2R0
32DLLS += kPrf2
33PROGRAMS += kPrf2Read
34
35
36#
37# Our template.
38#
39TEMPLATE_kPrf2 = kProfiler Template
40if1of ($(BUILD_TARGET), win)
41TEMPLATE_kPrf2_EXTENDS = kStuff
42
43else # Eliminate these
44TEMPLATE_kPrf2_TOOL = GCC3
45TEMPLATE_kPrf2_TOOL.os2 = GCC3OMF
46TEMPLATE_kPrf2_TOOL.win.x86 = VCC70
47TEMPLATE_kPrf2_TOOL.win.amd64 = VCC80AMD64
48TEMPLATE_kPrf2_ASTOOL = YASM
49TEMPLATE_kPrf2_ASTOOL.os2 = NASM
50
51TEMPLATE_kPrf2_SDKS.win = WINPSDK
52
53TEMPLATE_kPrf2_CXXFLAGS.freebsd = -g
54TEMPLATE_kPrf2_CXXFLAGS.linux = -g
55TEMPLATE_kPrf2_CXXFLAGS.os2 = -g
56TEMPLATE_kPrf2_CXXFLAGS.win = -Zi -Zl -W3 -GF -GR-
57TEMPLATE_kPrf2_CXXFLAGS.win.amd64 = -GS- #-FAcs
58ifneq ($(BUILD_TYPE),debug)
59TEMPLATE_kPrf2_CXXFLAGS.freebsd+= -O3
60TEMPLATE_kPrf2_CXXFLAGS.linux += -O3
61TEMPLATE_kPrf2_CXXFLAGS.os2 += -O3
62TEMPLATE_kPrf2_CXXFLAGS.win += -O2b2
63endif
64
65TEMPLATE_kPrf2_ASFLAGS.freebsd = -f elf
66TEMPLATE_kPrf2_ASFLAGS.linux = -f elf
67TEMPLATE_kPrf2_ASFLAGS.os2 = -f omf
68TEMPLATE_kPrf2_ASFLAGS.win.x86 = -f win32 -g cv8
69TEMPLATE_kPrf2_ASFLAGS.win.amd64 = -f win64 -g cv8
70
71TEMPLATE_kPrf2_INCS = \
72 ../include
73
74TEMPLATE_kPrf2_LDFLAGS.freebsd = -g
75TEMPLATE_kPrf2_LDFLAGS.linux = -g
76TEMPLATE_kPrf2_LDFLAGS.os2 = -g
77TEMPLATE_kPrf2_LDFLAGS.win = /DEBUG
78
79TEMPLATE_kPrf2_LIBS.freebsd =
80TEMPLATE_kPrf2_LIBS.linux =
81TEMPLATE_kPrf2_LIBS.os2 =
82TEMPLATE_kPrf2_LIBS.win = \
83 $(PATH_SDK_WINPSDK_LIB)/psapi.Lib
84TEMPLATE_kPrf2_LIBS.win.x86 = \
85 $(PATH_TOOL_VCC70_LIB)/libcmt.lib \
86 $(PATH_TOOL_VCC70_LIB)/oldnames.lib
87TEMPLATE_kPrf2_LIBS.win.amd64 = \
88 $(PATH_TOOL_VCC80AMD64_LIB)/oldnames.lib \
89 $(PATH_TOOL_VCC80AMD64_LIB)/libcmt.lib
90endif
91
92
93#
94# kPrf2 - The profiler module.
95#
96kPrf2_TEMPLATE = kPrf2
97kPrf2_DEFS.x86 = KPRF_BITS=32
98kPrf2_DEFS.amd64 = KPRF_BITS=64
99kPrf2_LDFLAGS.win.amd64 = -Entry:DllMain
100
101kPrf2_SOURCES = \
102 kProfileR3.cpp
103# kProfileGC.cpp
104# kProfileR0.cpp
105
106kPrf2_SOURCES.win = \
107 dllmain-win.cpp \
108 kPrf2WinApiWrapperHlp.c \
109 prf$(BUILD_TARGET_ARCH)msc.asm \
110 kPrf2-win-$(BUILD_TARGET_ARCH).def
111prfx86msc.asm_DEFS.win.x86 = \
112 KPRF_ENTER=_KPrfEnter \
113 KPRF_LEAVE=_KPrfLeave
114prfamd64msc.asm_DEFS.win.amd64 = \
115 KPRF_ENTER=KPrfEnter \
116 KPRF_LEAVE=KPrfLeave
117
118#
119# kPrf2Read - The read & producer of statistics.
120#
121kPrf2Read_TEMPLATE = kStuffEXE
122kPrf2Read_SOURCES = \
123 kPrf2Read.cpp
124kPrf2Read_LIBS = \
125 $(PATH_LIB)/kDbgStatic$(SUFF_LIB) \
126 $(PATH_LIB)/kRdrStatic$(SUFF_LIB) \
127 $(PATH_LIB)/kHlpCRTStatic$(SUFF_LIB)
128
129#
130# kPrf2WinApiWrappers
131#
132IMPORT_LIBS.win += kPrf2WinApiWrappersImp
133kPrf2WinApiWrappersImp_TEMPLATE = kStuffEXE
134kPrf2WinApiWrappersImp_SOURCES.x86 = kPrf2WinApiWrappersImp-x86.def
135kPrf2WinApiWrappersImp_SOURCES.amd64 = kPrf2WinApiWrappersImp-amd64.def
136
137DLLS.win += kPrf2WinApiWrappers
138kPrf2WinApiWrappers_TEMPLATE = kPrf2
139kPrf2WinApiWrappers_CFLAGS = -GH -Gh
140kPrf2WinApiWrappers_LDFLAGS.win.x86 = -Entry:DllMain@12
141kPrf2WinApiWrappers_LDFLAGS.win.amd64 = -Entry:DllMain
142kPrf2WinApiWrappers_SOURCES = \
143 kPrf2WinApiWrappers.c \
144 kPrf2WinApiWrappersImp-$(BUILD_TARGET_ARCH).def
145kPrf2WinApiWrappers_LIBS = \
146 $(PATH_kPrf2)/kPrf2.lib
147
148ifeq (0,1)
149kPrf2WinApiWrappers-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
188kPrf2WinApiWrappersImp-$(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
196endif
197
198#
199# A simple testcase.
200#
201PROGRAMS.win.x86 += tst
202tst_TOOL = VCC70
203tst_SDKS = WINPSDK
204tst_CFLAGS = -GH -Gh -Zi -Zl -GR- -GX- -GF- -W3 -wd4244
205tst_SOURCES = tst.c
206tst.c_CFLAGS = -Od
207tst_LDFLAGS = /DEBUG
208tst_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
214PROGRAMS += tstlongjmp
215tstlongjmp_TEMPLATE = kStuffEXE
216tstlongjmp_CFLAGS.win = -GH -Gh -Zi
217tstlongjmp_SOURCES = tstlongjmp.c
218tstlongjmp_LIBS = \
219 $(PATH_kPrf2)/kPrf2.lib
220
221# Generate the rules
222include $(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#
228CORE := $(wildcard *core*.cpp.h *core*.h.h)
229$(CORE:.h=.o) $(CORE:.h=.obj) : kProfileR3.o
230
231READ := $(wildcard *read*.cpp.h *read*.h.h)
232$(READ:.h=.o) $(READ:.h=.obj) : kPrf2Read.o
233
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette