-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
126 lines (97 loc) · 3.5 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
# general Makefile for compiling Sourcemod plugins
# copyright (c) 2021 https://github.com/CrimsonTautology
SHELL=/bin/bash
# directories
override scripting_dir=addons/sourcemod/scripting
override include_dir=addons/sourcemod/scripting/include
override plugins_dir=addons/sourcemod/plugins
override configs_dir=addons/sourcemod/configs
override extensions_dir=addons/sourcemod/extensions
override gamedata_dir=addons/sourcemod/gamedata
override translations_dir=addons/sourcemod/translations
# spcomp
SPCOMP=spcomp
INC=-i$(include_dir)
SPFLAGS=
DEBUG=
# other programs
CTAGS=ctags
DOS2UNIX=dos2unix
ZIP=zip
# files
override sourcefiles=$(wildcard $(scripting_dir)/*.sp)
override includefiles=$(shell find $(include_dir) -name '*.inc' 2>/dev/null)
override plugins=\
$(patsubst $(scripting_dir)/%.sp, $(plugins_dir)/%.smx, $(sourcefiles))
override configs=\
$(shell find $(configs_dir) -name '*' -type f 2>/dev/null)
override extensions=\
$(shell find $(extensions_dir) -name '*.so' -type f 2>/dev/null)
override gamedata=\
$(shell find $(gamedata_dir) -name '*.txt' -type f 2>/dev/null)
override translations=\
$(shell find $(translations_dir) -name '*.phrases.txt' -type f 2>/dev/null)
override release_files=README.md LICENSE Makefile addons cfg materials
# installation
SRCDS=/tmp
override disabled=$(addprefix $(plugins_dir)/,\
$(notdir $(wildcard $(SRCDS)/$(plugins_dir)/disabled/*.smx)))
vpath %.sp $(scripting_dir)
ifeq ($(DEBUG), 1)
SPFLAGS+=DEBUG=1
endif
all: clean compile tags
$(plugins_dir)/%.smx: %.sp | $(plugins_dir)
$(SPCOMP) $^ -o$@ $(INC) $(SPFLAGS)
$(plugins_dir)/%.asm: %.sp | $(plugins_dir)
$(SPCOMP) $^ -o$@ $(INC) $(SPFLAGS) -a
$(plugins_dir)%.lst: %.sp | $(plugins_dir)
$(SPCOMP) $^ -o$@ $(INC) $(SPFLAGS) -l
$(plugins_dir):
mkdir -p $@
clean:
$(RM) $(plugins_dir)/*.smx $(plugins_dir)/*.asm $(plugins_dir)/*.lst
compile: $(plugins)
tags:
-$(CTAGS) --langmap=c:+.sp,c:+.inc --recurse
dos2unix:
$(DOS2UNIX) $(sourcefiles) $(includefiles) $(configs) $(gamedata) $(translations)
list:
@printf 'plugins:\n'
@printf '%s\n' $(plugins)
@printf '\ndisabled plugins on install server:\n'
@printf '%s\n' $(disabled)
@printf '\nsource files:\n'
@printf '%s\n' $(sourcefiles)
@printf '\ninclude files:\n'
@printf '%s\n' $(includefiles)
@printf '\nconfigs:\n'
@printf '%s\n' $(configs)
@printf '\ngamedata:\n'
@printf '%s\n' $(gamedata)
@printf '\nextensions:\n'
@printf '%s\n' $(extensions)
@printf '\ntranslation:\n'
@printf '%s\n' $(translations)
install:
@# install only plugins that are not in the 'disabled' folder
@$(foreach file, $(filter-out $(disabled), $(plugins)),\
cp --parents $(file) -t $(SRCDS);)
@if [ -n "$(plugins)" ]; then cp -n --parents $(plugins) -t $(SRCDS); fi
@if [ -n "$(configs)" ]; then cp -n --parents $(configs) -t $(SRCDS); fi
@if [ -n "$(extensions)" ]; then cp -n --parents $(extensions) -t $(SRCDS); fi
@if [ -n "$(gamedata)" ]; then cp --parents $(gamedata) -t $(SRCDS); fi
@if [ -n "$(translations)" ]; then cp --parents $(translations) -t $(SRCDS); fi
@echo "install $(notdir $(filter-out $(disabled), $(plugins)) $(extensions)) to $(SRCDS)"
uninstall:
@$(RM) \
$(addprefix $(SRCDS)/, $(plugins)) \
$(addprefix $(SRCDS)/, $(configs)) \
$(addprefix $(SRCDS)/, $(gamedata)) \
$(addprefix $(SRCDS)/, $(translations))
@echo "uninstall $(notdir $(plugins)) from $(SRCDS)"
release.tar.gz: compile
tar cvzf $@ $(release_files) --ignore-failed-read
release.zip: compile
$(ZIP) -r $@ $(release_files)
.PHONY: all clean compile tags dos2unix list install uninstall