-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (110 loc) · 4.49 KB
/
Copy pathMakefile
File metadata and controls
153 lines (110 loc) · 4.49 KB
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
CFLAGS = -I. -Wall -Wextra
ifeq ($(DEBUG),1)
CFLAGS += -O0 -ggdb
else
CFLAGS += -O3
endif
VERSION = 0x010300
SRC = src/libvinput.c
PREFIX ?= /usr/local
# Linux/X11/uinput+evdev
ifeq ($(shell uname), Linux)
all: wordlogger test_emu test_echo
ifeq ($(OS), MINGW)
all: wordlogger.exe test_emu.exe libvinput.dll
SRC += \
src/windows_emu.c \
src/windows.c
libvinput.dll: $(SRC)
x86_64-w64-mingw32-gcc $(CFLAGS) -DVERSION=$(VERSION) -shared -o $@ $^ -DWINVER=0x0600 -luser32 -lkernel32
wordlogger.exe: wordlogger.c libvinput.dll
x86_64-w64-mingw32-gcc $(CFLAGS) -o $@ wordlogger.c -L. -lvinput -DWINVER=0x0600 -luser32 -lkernel32
test_emu.exe: test_emu.c libvinput.dll
x86_64-w64-mingw32-gcc $(CFLAGS) -o $@ test_emu.c -L. -lvinput -DWINVER=0x0600 -luser32 -lkernel32
test_echo.exe: test_echo.c libvinput.dll
x86_64-w64-mingw32-gcc $(CFLAGS) -o $@ test_echo.c -L. -lvinput -DWINVER=0x0600 -luser32 -lkernel32
clean:
rm -f wordlogger.exe
rm -f libvinput.dll
else
SRC += \
src/linux_emu.c \
src/linux.c \
src/linux_x11.c \
src/linux_emu_x11.c \
src/linux_evdev.c \
src/linux_uinput_emu.c
libvinput.so: $(SRC)
$(CC) $(CFLAGS) -DVERSION=$(VERSION) -fPIC -o $@ -shared $^ -lm -lX11 -lXtst $(shell pkg-config --cflags --libs libevdev xkbcommon) -I/usr/local/include -Isrc -L/usr/local/lib -lxdo
wordlogger: wordlogger.c libvinput.so
$(CC) $(CFLAGS) wordlogger.c -o $@ -L. -lvinput -lX11 -lXtst -levdev -I/usr/local/include -Isrc -L/usr/local/lib -lxdo
test_emu: test_emu.c libvinput.so
$(CC) $(CFLAGS) test_emu.c -o $@ -L. -lvinput -lX11 -lXtst -levdev -I/usr/local/include -Isrc -L/usr/local/lib -lxdo
test_echo: test_echo.c libvinput.so
$(CC) $(CFLAGS) test_echo.c -o $@ -L. -lvinput -lX11 -lXtst -levdev -I/usr/local/include -Isrc -L/usr/local/lib -lxdo
install: libvinput.so
rm -f $(PREFIX)/lib/libvinput.* && \
mkdir -p $(PREFIX)/include $(PREFIX)/lib && \
install -m 755 libvinput.so $(PREFIX)/lib && \
mv $(PREFIX)/lib/libvinput.so $(PREFIX)/lib/libvinput.so.$(VERSION) && \
ln -s $(PREFIX)/lib/libvinput.so.$(VERSION) $(PREFIX)/lib/libvinput.so
install -m 644 src/libvinput.h $(PREFIX)/include
install -m 644 libvinput.pc $(PREFIX)/lib/pkgconfig
clean:
rm -f wordlogger
rm -f test_emu
rm -f libvinput.so
endif
endif
# MacOS
ifeq ($(shell uname), Darwin)
all: wordlogger_mac test_emu_mac
SRC += \
src/macos_emu.c \
src/macos.c
libvinput.dylib: $(SRC)
$(CC) $(CFLAGS) -DVERSION=$(VERSION) -arch arm64 -arch x86_64 -fPIC -framework ApplicationServices -framework Carbon -o $@ -shared $^
wordlogger_mac: wordlogger.c libvinput.dylib
$(CC) $(CFLAGS) wordlogger.c -o $@ -Isrc -L. -lvinput -Wl,-rpath,@loader_path/.
test_emu_mac: test_emu.c libvinput.dylib
$(CC) $(CFLAGS) test_emu.c -o $@ -Isrc -L. -lvinput -Wl,-rpath,@loader_path/.
test_echo: test_echo.c libvinput.dylib
$(CC) $(CFLAGS) test_echo.c -o $@ -Isrc -L. -lvinput -Wl,-rpath,@loader_path/.
install: libvinput.dylib
rm -f $(PREFIX)/lib/libvinput.* && \
mkdir -p $(PREFIX)/include $(PREFIX)/lib && \
install -m 755 libvinput.dylib $(PREFIX)/lib && \
mv $(PREFIX)/lib/libvinput.dylib $(PREFIX)/lib/libvinput.dylib.$(VERSION) && \
ln -s $(PREFIX)/lib/libvinput.dylib.$(VERSION) $(PREFIX)/lib/libvinput.dylib
install -m 644 src/libvinput.h $(PREFIX)/include
install -m 644 libvinput.pc $(PREFIX)/lib/pkgconfig
clean:
rm -f wordlogger_mac
rm -f test_emu_mac
rm -f libvinput.dylib
endif
# Windows/WINAPI
ifeq ($(OS), Windows_NT)
all: wordlogger.exe test_emu.exe test_echo.exe libvinput.dll vinput.lib
libvinput.dll: libvinput.obj windows_emu.obj windows.obj
link /DLL /OUT:$@ $^ User32.lib Kernel32.lib
libvinput.obj: src/libvinput.c
cl /DVERSION=$(VERSION) /I src /DBUILDING_VINPUT /Fo:$@ /c $<
windows_emu.obj: src/windows_emu.c
cl /DVERSION=$(VERSION) /I src /DBUILDING_VINPUT /Fo:$@ /c $<
windows.obj: src/windows.c
cl /DVERSION=$(VERSION) /I src /DBUILDING_VINPUT /Fo:$@ /c $<
vinput.lib: libvinput.obj windows_emu.obj windows.obj
lib /OUT:$@ $^
wordlogger.exe: wordlogger.c vinput.lib
cl /I src /Fo:wordlogger.obj /Fe:$@ $^ User32.lib Kernel32.lib
test_emu.exe: test_emu.c vinput.lib
cl /I src /Fo:test_emu.obj /Fe:$@ $^ User32.lib Kernel32.lib
test_echo.exe: test_echo.c vinput.lib
cl /I src /Fo:test_echo.obj /Fe:$@ $^ User32.lib Kernel32.lib
clean:
del /F /Q libvinput.dll vinput.lib *.obj wordlogger.exe test_emu.exe test_echo.exe
endif
cppcheck:
cppcheck --enable=warning --check-level=exhaustive --inconclusive --std=c99 --force --quiet -i src/ext/vec.c $(SRC) wordlogger.c test_emu.c
.PHONY: all clean cppcheck install