-
Notifications
You must be signed in to change notification settings - Fork 4
/
makefile.gcc
100 lines (78 loc) · 2.41 KB
/
makefile.gcc
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
# Makefile for Errout.
# Jason Hood, 29 June, 2011. Updated 13 November, 2013.
#
# Tested with:
# * MinGW/gcc 4.7.2;
# * tdm-gcc-4.8.1-3;
# * tdm64-gcc-4.8.1-3;
# * MinGW-builds x64-4.8.1-release-posix-seh-rev1.
#
# Commands are hidden by default, add "V=1" to show them (or change var below).
CC = gcc
CFLAGS = -O2 -Wall
#ARCH = 32
#ARCH = 64
#ARCH = multi
ifndef ARCH
# Use the machine to distinguish between MinGW and MinGW-w64.
ifeq (,$(findstring 64,$(shell gcc -dumpmachine)))
ARCH = 32
else
# It's 64-bit, if it's multi the lib name will be different.
ifeq ($(shell gcc -m32 -print-libgcc-file-name),$(shell gcc -m64 -print-libgcc-file-name))
ARCH = 64
else
ARCH = multi
endif
endif
endif
# Determine the appropriate separator to run multiple commands - ";" for sh.exe
# and "&" for CMD.EXE. $(SHELL) is initially defined to "sh.exe" - if it
# actually exists, it becomes the full path.
ifneq ($(wildcard $(SHELL)),)
SEP = ;
else
SEP = &
endif
V ?= 0
ifeq ($(V),0)
CCmsg = @echo $<$(SEP)
RCmsg = $(CCmsg)
LDmsg = @echo $@$(SEP)
endif
x86/%.o: %.c errout.h
$(CCmsg)$(CC) -m32 -c $(CFLAGS) $< -o $@
x86/%v.o: %.rc
$(RCmsg)windres -U _WIN64 -F pe-i386 $< $@
x64/%.o: %.c errout.h
$(CCmsg)$(CC) -m64 -c $(CFLAGS) $< -o $@
x64/%v.o: %.rc
$(RCmsg)windres -F pe-x86-64 $< $@
x64/%32.o: %.c
$(CCmsg)$(CC) -m32 -DW32ON64 $(CFLAGS) $< -c -o $@
ifeq ($(ARCH),multi)
all: errout32 errout64
else
all: errout$(ARCH)
endif
errout32: x86 x86/errout32.dll x86/errout.exe x64 x64/errout32.dll
errout64: x64 x64/errout64.dll x64/errout.exe
x86:
cmd /c "mkdir x86"
x86/errout.exe: x86/errout.o x86/erroutv.o
$(LDmsg)$(CC) -m32 $+ -s -o $@ x86/errout32.a
x86/errout32.dll: x86/errouthk.o x86/proctype.o x86/injdll32.o x86/erroutv.o
$(LDmsg)$(CC) -m32 $+ -s -o $@ -mdll -Wl,-shared,--out-implib,x86/errout32.a,--image-base,0xE00000
x64:
cmd /c "mkdir x64"
x64/errout.exe: x64/errout.o x64/erroutv.o
$(LDmsg)$(CC) -m64 $+ -s -o $@ x64/errout64.a
x64/errout64.dll: x64/errouthk.o x64/proctype.o x64/injdll64.o x64/injdll32.o x64/erroutv.o
$(LDmsg)$(CC) -m64 $+ -s -o $@ -mdll -Wl,-shared,--out-implib,x64/errout64.a,--image-base,0xE0000000
x64/errout32.dll: x64/errouthk32.o x64/proctype32.o x86/injdll32.o x86/erroutv.o
$(LDmsg)$(CC) -m32 $+ -s -o $@ -mdll -Wl,-shared,--image-base,0xE00000
# Need two commands, because if the directory doesn't exist, it won't delete
# anything at all.
clean:
-cmd /c "del x86\*.o 2>nul"
-cmd /c "del x64\*.o 2>nul"