-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
67 lines (56 loc) · 2 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
CFLAGS += -m64 -fPIC
SOURCES = HDE/hde64.c
SOURCES_NOPY = HDE/hde64.c
SUFFIX = .x64
else
CFLAGS += -m32 -fPIC
SOURCES = HDE/hde32.c
SOURCES_NOPY = HDE/hde32.c
SUFFIX = .x86
endif
BINDIR = bin
CC = gcc
CFLAGS += -shared -std=gnu11
LDFLAGS_NOPY += -ldl
LDFLAGS += $(shell (python3-config --libs --embed || python3-config --libs) | grep lpython)
SOURCES_NOPY += dllmain.c commands.c simple_hook.c hooks.c misc.c maps_parser.c trampoline.c patches.c
SOURCES += dllmain.c commands.c python_embed.c python_dispatchers.c simple_hook.c hooks.c misc.c maps_parser.c trampoline.c patches.c
OBJS = $(SOURCES:.c=.o)
OBJS_NOPY = $(SOURCES_NOPY:.c=.o)
OUTPUT = $(BINDIR)/minqlx$(SUFFIX).so
OUTPUT_NOPY = $(BINDIR)/minqlx_nopy.so
PYMODULE = $(BINDIR)/minqlx.zip
PYFILES = $(wildcard python/minqlx/*.py)
.PHONY: depend clean
all: CFLAGS += $(shell python3-config --includes)
all: VERSION := MINQLX_VERSION=\"$(shell python3 python/version.py)\"
all: $(OUTPUT) $(PYMODULE)
@echo Done!
debug: CFLAGS += $(shell python3-config --includes) -gdwarf-2 -Wall -O0 -fvar-tracking
debug: VERSION := MINQLX_VERSION=\"$(shell python3 python/version.py -d)\"
debug: $(OUTPUT) $(PYMODULE)
@echo Done!
nopy: CFLAGS += -Wall -DNOPY
nopy: VERSION := MINQLX_VERSION=\"$(shell git describe --long --tags --dirty --always)-nopy\"
nopy: $(OUTPUT_NOPY)
@echo Done!
nopy_debug: CFLAGS += -gdwarf-2 -Wall -O0 -DNOPY
nopy_debug: VERSION := MINQLX_VERSION=\"$(shell git describe --long --tags --dirty --always)-nopy\"
nopy_debug: $(OUTPUT_NOPY)
@echo Done!
$(OUTPUT): $(OBJS)
$(CC) $(CFLAGS) -D$(VERSION) -o $(OUTPUT) $(OBJS) $(LDFLAGS)
$(OUTPUT_NOPY): $(OBJS_NOPY)
$(CC) $(CFLAGS) -D$(VERSION) -o $(OUTPUT_NOPY) $(OBJS_NOPY) $(LDFLAGS_NOPY)
$(PYMODULE): $(PYFILES)
@python3 -m zipfile -c $(PYMODULE) python/minqlx
.c.o:
$(CC) $(CFLAGS) -D$(VERSION) -c $< -o $@
clean:
@echo Cleaning...
@$(RM) *.o *~ $(OUTPUT) $(OUTPUT_NOPY)
@$(RM) HDE/*.o HDE/*~ $(OUTPUT) $(OUTPUT_NOPY)
@$(RM) $(PYMODULE)
@echo Done!