aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/tracebld/Makefile
blob: 182655d1a17792a87e72948a65468e440f06c384 (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
##############################################################################
##
##  Utility to registry and file access APIs.
##
##  Microsoft Research Detours Package
##
##  Copyright (c) Microsoft Corporation.  All rights reserved.
##

!include ..\common.mak

LIBS=$(LIBS) kernel32.lib

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

all: dirs \
    $(BIND)\trcbld$(DETOURS_BITS).dll \
    $(BIND)\tracebld.exe \
    \
!IF $(DETOURS_SOURCE_BROWSING)==1
    $(OBJD)\trcbld$(DETOURS_BITS).bsc    \
    $(OBJD)\tracebld.bsc    \
!ENDIF
    option

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

clean:
    -del *~ test.txt log.*.xml 2>nul
    -del $(BIND)\tracebld.* $(BIND)\trcbld*.* 2>nul
    -rmdir /q /s $(OBJD) 2>nul

realclean: clean
    -rmdir /q /s $(OBJDS) 2>nul

dirs:
    @if not exist $(BIND) mkdir $(BIND) && echo.   Created $(BIND)
    @if not exist $(OBJD) mkdir $(OBJD) && echo.   Created $(OBJD)

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

$(OBJD)\trcbld.obj : trcbld.cpp
$(OBJD)\trcbld.res : trcbld.rc
$(BIND)\trcbld$(DETOURS_BITS).dll : $(OBJD)\trcbld.obj $(OBJD)\trcbld.res $(DEPS)
    cl /LD $(CFLAGS) /Fe$@ /Fd$(@R).pdb \
        $(OBJD)\trcbld.obj $(OBJD)\trcbld.res \
        /link $(LINKFLAGS) /release /subsystem:console \
        /export:DetourFinishHelperProcess,@1,NONAME \
        $(LIBS)

$(OBJD)\trcbld$(DETOURS_BITS).bsc : $(OBJD)\trcbld.obj
    bscmake /v /n /o $@ $(OBJD)\trcbld.sbr

$(OBJD)\tracebld.obj : tracebld.cpp

$(BIND)\tracebld.exe : $(OBJD)\tracebld.obj $(DEPS)
    cl $(CFLAGS) /Fe$@ /Fd$(@R).pdb $(OBJD)\tracebld.obj \
        /link $(LINKFLAGS) $(LIBS) \
        /subsystem:console /fixed:no

$(OBJD)\tracebld.bsc : $(OBJD)\tracebld.obj
    bscmake /v /n /o $@ $(OBJD)\tracebld.sbr

############################################### Install non-bit-size binaries.

!IF "$(DETOURS_OPTION_PROCESSOR)" != ""

$(OPTD)\trcbld$(DETOURS_OPTION_BITS).dll:
$(OPTD)\trcbld$(DETOURS_OPTION_BITS).pdb:

$(BIND)\trcbld$(DETOURS_OPTION_BITS).dll : $(OPTD)\trcbld$(DETOURS_OPTION_BITS).dll
    @if exist $? copy /y $? $(BIND) >nul && echo $@ copied from $(DETOURS_OPTION_PROCESSOR).
$(BIND)\trcbld$(DETOURS_OPTION_BITS).pdb : $(OPTD)\trcbld$(DETOURS_OPTION_BITS).pdb
    @if exist $? copy /y $? $(BIND) >nul && echo $@ copied from $(DETOURS_OPTION_PROCESSOR).

option: \
    $(BIND)\trcbld$(DETOURS_OPTION_BITS).dll \
    $(BIND)\trcbld$(DETOURS_OPTION_BITS).pdb \

!ELSE

option:

!ENDIF

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

test: all
    -del log.*.xml 2>nul
    $(BIND)\tracebld.exe /o:log %COMSPEC% /c dir
    @echo -------- Log from log.00000000 ---------------------
    type log.00000000.xml

test0: all
    -del log.*.xml 2>nul
    $(BIND)\tracebld.exe /o:log %COMSPEC% /c xx.cmd
    @echo -------- Log from log.00000000 ---------------------
    type log.00000000.xml
    @echo -------- Log from log.00000001 ---------------------
    type log.00000001.xml

test1: all
    set FooBAR=1
    -del log.*.xml 2>nul
    @echo -------- Logging output to log ------------
    -rmdir /q /s obj 2>nul
    $(BIND)\tracebld.exe /o:log nmake.exe test2
    @echo -------- Log from log.00000000 ---------------------
    type log.00000000.xml | findstr /c:"t:Line"
    type log.00000002.xml | findstr /c:"t:Line"

test1d: all
    -del log.*.xml 2>nul
    @echo -------- Logging output to log ------------
    -rmdir /q /s obj 2>nul
    windbg -g -G -o $(BIND)\tracebld.exe /o:log nmake.exe test2
    @echo -------- Log from log.00000000 ---------------------
    type log.00000000.xml | findstr /c:"t:Line"
    type log.00000002.xml | findstr /c:"t:Line"


test2: all
    -del foo.txt
    echo foo1 >> foo.txt
    echo foo2 >> foo.txt
    echo foo3 >> foo.txt
    -del log.foo.xml
    -mkdir obj
    cmd.exe /c "set Foo=BAR&&cmd.exe /c echo. FOO=%Foo%"
    cl /LD $(CFLAGS) /Tp<< @<<obj\response.txt > log.foo.xml
#include <windows.h>
<<
/Feobj\tbtest.exe /Fd$(@R).pdb $(DET_SRC)
/link $(LINKFLAGS) /subsystem:console
/export:DetourFinishHelperProcess,@1 
<<NOKEEP
    type $(BIND)\trcbld.cpp | findstr CreateFile
    echo int main() { return 0; } > obj\test.cpp
    cl /c /Foobj\test.obj obj\test.cpp
    -del tbtest.* 2>nul

test3: all
    -del log.*.xml 2>nul
    @echo -------- Logging output to log ------------
    -rmdir /q /s foo
    $(BIND)\tracebld.exe /o:log xcopy.exe $(BIND)\trcbld.cpp foo\ /y
    @echo -------- Log from log.00000000 ---------------------
    type log.00000000.xml

test4: all
    -del log.*.xml 2>nul
    echo int main() { return 0; } > obj\test.cpp
    $(BIND)\tracebld.exe /o:log cl /c /Foobj\test.obj obj\test.cpp
    @echo -------- Log from log.00000000 ---------------------
    type log.00000000.xml

################################################################# End of File.