-
Notifications
You must be signed in to change notification settings - Fork 271
/
GNUmakefile
88 lines (68 loc) · 2.44 KB
/
GNUmakefile
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
CC=cl.exe
RC=rc.exe
MSBUILD=msbuild.exe
CMAKE=cmake.exe
RFLAGS=/nologo
CFLAGS=/nologo /Zi /Od /MD /FS
LFLAGS=/nologo /machine:x86
VFLAGS=-no_logo
MFLAGS=/p:Configuration=Release /nologo /m /v:q
CXXFLAGS=/nologo /Zi /Od /EHsc /MD /FS
LDLIBS=user32 ole32 edit advapi32 peparse shlwapi imm32 shell32
LDFLAGS=/MD
LINKFLAGS=/ignore:4099
VSDEVCMD=cmd.exe /c vsdevcmd.bat
# Commands for arch specific compiler.
ifeq ($(OS),Windows_NT)
CC64=$(VSDEVCMD) $(VFLAGS) -arch=amd64 ^& cl
CC32=$(VSDEVCMD) $(VFLAGS) -arch=x86 ^& cl
else
CC64=$(VSDEVCMD) $(VFLAGS) -arch=amd64 "&" cl
CC32=$(VSDEVCMD) $(VFLAGS) -arch=x86 "&" cl
endif
.PHONY: clean distclean
all: ctftool.exe payload32.dll payload64.dll
release: ctftool.zip ctftool-src.zip
%.res: %.rc
$(RC) $(RFLAGS) $<
%.obj: %.cc
$(CC) $(CXXFLAGS) /c /Fo:$@ $<
%.obj: %.c
$(CC) $(CFLAGS) /c /Fo:$@ $<
%.exe: %.obj
$(CC) $(CFLAGS) $(LDFLAGS) /Fe:$@ $^ /link $(LINKFLAGS) $(LDLIBS:=.lib)
%.dll: %.obj
$(CC) $(CFLAGS) $(LDFLAGS) /LD /Fe:$@ $^ /link $(LINKFLAGS)
%64.obj: %.c
$(CC) $(CFLAGS) /c /Fd:$(@:.obj=.pdb) /Fo:$@ $<
%32.obj: %.c
$(CC) $(CFLAGS) /c /Fd:$(@:.obj=.pdb) /Fo:$@ $<
%64.dll: CC=$(CC64)
%64.dll: %64.obj version.res
$(CC) $(CFLAGS) $(LDFLAGS) /LD /Fd:$(@:.dll=.pdb) /Fe:$@ $^ /link $(LINKFLAGS)
%32.dll: CC=$(CC32)
%32.dll: %32.obj version.res
$(CC) $(CFLAGS) $(LDFLAGS) /LD /Fd:$(@:.dll=.pdb) /Fe:$@ $^ /link $(LINKFLAGS)
peparse.lib:
$(CMAKE) -S pe-parse -B build-$@
$(MSBUILD) $(MFLAGS) build-$@/pe-parse.sln
cmd.exe /c copy build-$@\\pe-parser-library\\Release\\pe-parser-library.lib $@
edit.lib:
$(CMAKE) -S wineditline -B build-$@
$(MSBUILD) $(MFLAGS) build-$@/WinEditLine.sln
cmd.exe /c copy build-$@\\src\\Release\\edit_a.lib $@
ctftool.exe: command.obj ctftool.obj winmsg.obj marshal.obj \
util.obj module.obj version.res peproc.obj \
messages.obj winutil.obj \
| edit.lib peparse.lib
clean:
-cmd.exe /c del /q /f *.exp *.exe *.obj *.pdb *.ilk *.xml *.res *.ipdb *.iobj *.dll *.tmp
-cmd.exe /c rmdir /q /s $(wildcard build-*.*)
# These are slow to rebuild and I dont change them often.
distclean: clean
-cmd.exe /c del /q /f edit.lib peparse.lib
-cmd.exe /c del /q /f ctftool.zip ctftool-src.zip
ctftool.zip: README.md ctftool.exe payload32.dll payload64.dll scripts docs
(cd .. && zip -r ctftool/$@ $(patsubst %,ctftool/%,$^))
ctftool-src.zip:
(cd .. && zip -x@ctftool/.zipignore -r ctftool/$@ ctftool)