-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmakefile
More file actions
93 lines (74 loc) · 2.29 KB
/
Copy pathmakefile
File metadata and controls
93 lines (74 loc) · 2.29 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
##############################################
# Name of your plugin. #
# (output file: lib<PLUGIN_NAME>.so or .dll) #
##############################################
PLUGIN_NAME=cod4x_mysql
#######################################################
# Header files include directory for Windows and UNIX #
#######################################################
INCLUDEDIR_UNIX=-Imysql/unix/include
INCLUDEDIR_WIN32=-Imysql/windows/include
#################################################
# Additional static libraries needs to be added #
#################################################
ADDITIONALLIBS_UNIX=mysql/unix/lib/libmysqlclient.a
ADDITIONALLIBS_WIN32=mysql/windows/lib/libmysql.lib
#################################
# Common definitions #
# (rarely needed to be changed) #
#################################
CC=g++
# Noteworthy: server compiled against libgcc and libstdc++ statically, so
# dynamic linking will cause crash at exit.
CFLAGS=-m32 -O3 -Wall -s --pedantic -std=c++11 -static-libgcc -static-libstdc++
C_MODULES=$(wildcard *.c)
CPP_MODULES=$(wildcard *.cpp)
C_OBJECTS=$(patsubst %.c,obj/%.o,$(C_MODULES))
CPP_OBJECTS=$(patsubst %.cpp,obj/%.o,$(CPP_MODULES))
OBJECTS=$(C_OBJECTS) $(CPP_OBJECTS)
TARGET_OS = $(shell $(CC) -dumpmachine)
ifeq ($(TARGET_OS),mingw32)
INCLUDEDIR=$(INCLUDEDIR_WIN32)
ADDITIONALLIBS=$(ADDITIONALLIBS_WIN32)
else ifeq ($(TARGET_OS),cygwin)
else
CFLAGS += -fPIC
INCLUDEDIR=$(INCLUDEDIR_UNIX)
ADDITIONALLIBS=$(ADDITIONALLIBS_UNIX)
endif
############
# Recipies #
############
ifeq ($(TARGET_OS),mingw32)
all: win32
else
all: unix
endif
@echo Done
obj/%.o: %.cpp
@echo $(CC) "$^ -> $@"
@$(CC) $(CFLAGS) $(INCLUDEDIR) -o $@ -c $<
ifeq ($(TARGET_OS),mingw32)
clean: clean_win32
else
clean: clean_unix
endif
@echo Clean done
#####################
# Recipies: Windows #
#####################
win32: bin/lib$(PLUGIN_NAME).dll
bin/lib$(PLUGIN_NAME).dll: $(OBJECTS)
@echo $(CC) "$@"
@$(CC) -shared $(CFLAGS) -o $@ $^ ../libcom_plugin.a $(ADDITIONALLIBS)
clean_win32:
@del $(subst /,\\,$(OBJECTS))
##################
# Recipies: UNIX #
##################
unix: bin/lib$(PLUGIN_NAME).so
bin/lib$(PLUGIN_NAME).so: $(OBJECTS)
@echo $(CC) "$@"
@$(CC) -shared $(CFLAGS) -o $@ $^ $(ADDITIONALLIBS)
clean_unix:
@rm -r $(OBJECTS)