-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·137 lines (111 loc) · 3.49 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
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
#
# Copyright 2007, 2008 Nicolas Maingot
#
# This file is part of CSSMatch.
#
# CSSMatch is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# CSSMatch is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with CSSMatch; if not, see <http://www.gnu.org/licenses>.
#
# Additional permission under GNU GPL version 3 section 7
#
# If you modify CSSMatch, or any covered work, by linking or combining
# it with "Source SDK" (or a modified version of that SDK), containing
# parts covered by the terms of Source SDK licence, the licensors of
# CSSMatch grant you additional permission to convey the resulting work.
#
# Dossier de travail
BASE_DIR = ../hl2sdk-ob
# Compilateur
#CXX = g++-3.4 # maximise la compatibilité
CXX = g++
# Nom du fichier binaire de sortie
BINARY_NAME = cssmatch.so
# Dossier de sortie du fichier binaire
BINARY_DIR = zip/addons
# Code source du SDK de VALVE
SDK_SRC_DIR = $(BASE_DIR)
SDK_PUBLIC_DIR = $(SDK_SRC_DIR)/public
SDK_TIER0_DIR = $(SDK_SRC_DIR)/public/tier0
SDK_TIER1_DIR = $(SDK_SRC_DIR)/tier1
# Dossiers de sortie
RELEASE_DIR = Release/linux
DEBUG_DIR = Debug/linux
# Dossier contenant les librairies dynamiques
SRCDS_BIN_DIR = bin
# Dossier contenant les librairies statiques
SRCDS_A_DIR = $(SDK_SRC_DIR)/lib/linux
# Paramètres du compilateur
ARCH_CFLAGS = -mtune=i686 -march=pentium -mmmx
USER_CFLAGS = -DTIXML_USE_TICPP -pthread
BASE_CFLAGS = -msse \
-fpermissive \
-D_LINUX \
-DNDEBUG \
-Dstricmp=strcasecmp \
-D_stricmp=strcasecmp \
-D_strnicmp=strncasecmp \
-Dstrnicmp=strncasecmp \
-D_snprintf=snprintf \
-D_vsnprintf=vsnprintf \
-D_alloca=alloca \
-Dstrcmpi=strcasecmp \
-fPIC \
-Wno-deprecated \
-m32
OPT_FLAGS = -O3 -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3 -O0 -D_DEBUG
# Fichiers à compiler
SRC= $(wildcard *.cpp) $(wildcard */*.cpp) $(wildcard */*/*.cpp)
# Fichiers à lier
LINK_SO = $(SRCDS_BIN_DIR)/libtier0_srv.so
LINK_A = $(SRCDS_A_DIR)/tier1_i486.a
LINK = -lm -ldl $(LINK_A) $(LINK_SO)
# Dossiers des fichiers inclus
INCLUDE = -I. \
-I$(SDK_PUBLIC_DIR) \
-I$(SDK_PUBLIC_DIR)/engine \
-I$(SDK_PUBLIC_DIR)/tier0 \
-I$(SDK_PUBLIC_DIR)/tier1 \
-I$(SDK_PUBLIC_DIR)/vstdlib \
-I$(SDK_PUBLIC_DIR)/game/server \
-I$(SDK_SRC_DIR)/tier1 \
-I$(SDK_SRC_DIR)/game \
-I$(SDK_SRC_DIR)/game/server \
-I$(SDK_SRC_DIR)/game/shared
# Règles de compilation
ifeq "$(DEBUG)" "false"
BIN_DIR = $(RELEASE_DIR)
CFLAGS = $(OPT_FLAGS)
else
BIN_DIR = $(DEBUG_DIR)
CFLAGS = $(DEBUG_FLAGS)
endif
CFLAGS += $(USER_CFLAGS) $(BASE_CFLAGS) $(ARCH_CFLAGS)
OBJECTS := $(SRC:%.cpp=$(BIN_DIR)/%.o)
compile_object = \
@mkdir -p $(2); \
echo "$(1) => $(3)"; \
$(CXX) $(INCLUDE) $(CFLAGS) -o $(3) -c $(1);
$(BIN_DIR)/%.o: %.cpp %.h
$(call compile_object, $<, $(@D), $@)
$(BIN_DIR)/%.o: %.cpp
$(call compile_object, $<, $(@D), $@)
all: $(OBJECTS)
@$(CXX) $(INCLUDE) $(CFLAGS) $(OBJECTS) $(LINK) -shared -o $(BINARY_DIR)/$(BINARY_NAME)
release:
@$(MAKE) all DEBUG=false
clean:
@rm -rf $(RELEASE_DIR)
@rm -rf $(DEBUG_DIR)
@rm -rf $(BINARY_DIR)/$(BINARY_NAME)
.PHONY: clean