-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (37 loc) · 1.19 KB
/
Makefile
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
OBJECTS = patchmem.o
CFLAGS := -m32 -Wall -Werror -O0 -ggdb -MMD -MP -fno-strict-aliasing -masm=intel $(CFLAGS)
CFLAGS += -fPIC
LDFLAGS := -m32 $(LDFLAGS)
$(shell mkdir -p build &>/dev/null)
ifeq ($(OS),Windows_NT)
LIB_TARGET ?= patchmem.dll
OBJECTS += os_win.o rc.o
CFLAGS += -D_WIN32_WINNT=0x501
else
OBJECTS += os_linux.o
LIB_TARGET ?= libpatchmem.so
CFLAGS += -pthread
LDFLAGS += -pthread -ldl
endif
all: build/$(LIB_TARGET)
.PHONY: clean test tests
clean:
rm -f $(OBJECTS:%.o=build/%.o) $(OBJECTS:%.o=build/%.d) build/patchmem.dll build/libpatchmem.so tests/build/*
install: all
@if [ ! -d "${CONFIG_INSTALL_PATH}" ]; then \
echo "CONFIG_INSTALL_PATH invalid or not defined"; exit 1; \
fi
cp build/$(LIB_TARGET) $(CONFIG_INSTALL_PATH:/=)/$(LIB_TARGET)
tests: all
@$(MAKE) -C tests test
# just an alias
test: tests
build/patchmem.dll: $(OBJECTS:%.o=build/%.o)
gcc $(LDFLAGS) -o $@ -shared $(filter %.o,$^) -lkeystone -Wl,--subsystem,windows -static-libgcc
build/libpatchmem.so: $(OBJECTS:%.o=build/%.o)
gcc -o $@ -shared $(filter %.o,$^) -lkeystone $(LDFLAGS)
build/%.o: %.c
gcc $(CFLAGS) -c -o $@ $<
build/rc.o: patchmem.rc
windres -i $< -o $@
-include $(OBJECTS:%.o=build/%.d)