summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: d61a885b49c8388502c55b44d9c77fdab454cc1b (plain) (blame)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
@SET_MAKE@

HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
	ALL_DEPENDS=common_sql login_sql char_sql map_sql tools | import
	SQL_DEPENDS=common_sql login_sql char_sql map_sql | import
	COMMON_SQL_DEPENDS=mt19937ar libconfig
	LOGIN_SQL_DEPENDS=mt19937ar libconfig common_sql
	CHAR_SQL_DEPENDS=mt19937ar libconfig common_sql
	MAP_SQL_DEPENDS=mt19937ar libconfig common_sql
	TOOLS_DEPENDS=mt19937ar libconfig common_sql
else
	ALL_DEPENDS=needs_mysql
	SQL_DEPENDS=needs_mysql
	COMMON_SQL_DEPENDS=needs_mysql
	LOGIN_SQL_DEPENDS=needs_mysql
	CHAR_SQL_DEPENDS=needs_mysql
	MAP_SQL_DEPENDS=needs_mysql
	TOOLS_DEPENDS=needs_mysql
endif

WITH_PLUGINS=@WITH_PLUGINS@
ifeq ($(WITH_PLUGINS),yes)
	ALL_DEPENDS+=plugins
	PLUGIN_DEPENDS=common_sql
else
	PLUGIN_DEPENDS=no_plugins
endif

HAVE_PERL=@HAVE_PERL@
HAVE_DOXYGEN=@HAVE_DOXYGEN@

MF_TARGETS = Makefile $(addsuffix /Makefile, src/common 3rdparty/mt19937ar \
             3rdparty/libconfig src/char src/login src/map src/plugins \
             src/tool src/test tools/HPMHookGen)

CC = @CC@
export CC

#####################################################################
.PHONY: sql  \
	common_sql \
	mt19937ar \
	login_sql \
	char_sql \
	map_sql \
	tools \
	plugins \
	import \
	test \
	clean \
	buildclean \
	distclean \
	hooks \
	help

all: $(ALL_DEPENDS)

sql: $(SQL_DEPENDS)

$(MF_TARGETS): %: %.in
	@echo "	CONFIGURE"
	@if [ -x config.status ]; then \
		echo "Reconfiguring with options: $$(./config.status --config)"; \
		./config.status; \
	else \
		echo "Unable to find a previous config.status.  ./configure will be re-run with the default options."; \
		echo "If you want to use custom options, please press CTRL-C and run ./configure yourself"; \
		for i in 1 2 3 4 5 6 7 8 9 10; do \
			printf "\a. "; \
			sleep 1; \
		done; \
		echo ""; \
		./configure; \
	fi;

common_sql: $(COMMON_SQL_DEPENDS) src/common/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/common sql

mt19937ar: 3rdparty/mt19937ar/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C 3rdparty/mt19937ar

libconfig: 3rdparty/libconfig/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C 3rdparty/libconfig

login_sql: $(LOGIN_SQL_DEPENDS) src/login/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/login sql

char_sql: $(CHAR_SQL_DEPENDS) src/char/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/char

map_sql: $(MAP_SQL_DEPENDS) src/map/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/map sql

tools: $(TOOLS_DEPENDS) src/tool/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/tool

test: src/test/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/test

plugins: $(PLUGIN_DEPENDS) src/plugins/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/plugins

plugin.%: $(PLUGIN_DEPENDS) src/plugins/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C src/plugins $(patsubst plugin.%,%,$@)

hooks: tools/HPMHookGen/Makefile
	@echo "	MAKE	$@"
	@$(MAKE) -C tools/HPMHookGen

import: Makefile
	@# 1) create conf/import folder
	@# 2) add missing files
	@echo "building conf/import folder..."
	@if test ! -d conf/import ; then mkdir conf/import ; fi
	@for f in $$(ls conf/import-tmpl) ; do if test ! -e conf/import/$$f ; then cp conf/import-tmpl/$$f conf/import ; fi ; done

clean buildclean: $(MF_TARGETS)
	@$(MAKE) -C src/common $@
	@$(MAKE) -C 3rdparty/mt19937ar $@
	@$(MAKE) -C 3rdparty/libconfig $@
	@$(MAKE) -C src/login $@
	@$(MAKE) -C src/char $@
	@$(MAKE) -C src/map $@
	@$(MAKE) -C src/plugins $@
	@$(MAKE) -C src/tool $@
	@$(MAKE) -C src/test $@
	@$(MAKE) -C tools/HPMHookGen $@

distclean: clean
	@-rm -f $(MF_TARGETS) config.status config.log

help: Makefile
	@echo "most common targets are 'all' 'sql' 'clean' 'plugins' 'help'"
	@echo "possible targets are:"
	@echo "'common_sql'  - builds object files used in SQL servers"
	@echo "'mt19937ar'   - builds object file of Mersenne Twister MT19937"
	@echo "'libconfig'   - builds object files of libconfig"
	@echo "'login_sql'   - builds login server"
	@echo "'char_sql'    - builds char server"
	@echo "'map_sql'     - builds map server"
	@echo "'tools'       - builds all the tools in src/tools"
	@echo "'import'      - builds conf/import folder from the template conf/import-tmpl"
	@echo "'all'         - builds all the above targets"
	@echo "'sql'         - builds sql servers (targets 'common_sql' 'login_sql' 'char_sql'"
	@echo "                'map_sql' and 'import')"
	@echo "'plugins'     - builds all available plugins"
	@echo "'plugin.Name' - builds plugin named 'Name'"
	@echo "'test'        - builds tests"
	@echo "'clean'       - cleans executables and objects"
	@echo "'buildclean'  - cleans build temporary (object) files, without deleting the"
	@echo "                executables"
	@echo "'distclean'   - cleans files generated by ./configure"
ifeq ($(HAVE_PERL)$(HAVE_DOXYGEN),yesyes)
	@echo "'hooks'       - re-generates the definitions for the HPM Hooking plugin"
endif
	@echo "'help'        - outputs this message"

#####################################################################

needs_mysql:
	@echo "MySQL not found or disabled by the configure script"
	@exit 1

no_plugins:
	@echo "Plugins disabled by the configure script"
	@exit 1

#####################################################################
# TODO

#install: conf/%.conf conf/%.txt
#	@read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue."
#	@mkdir -p /opt/hercules/bin/
#	@mkdir -p /opt/hercules/etc/hercules/
#	@mkdir -p /opt/hercules/var/log/hercules/
#	@mv save /opt/hercules/etc/hercules/save
#	@mv db /opt/hercules/etc/hercules/db
#	@mv conf /opt/hercules/etc/hercules/conf
#	@mv npc /opt/hercules/etc/hercules/npc
#	@mv log/* /opt/hercules/var/log/hercules/
#	@cp *-server /opt/hercules/bin/
#	@ln -s /opt/hercules/etc/hercules/save/ /opt/hercules/bin/
#	@ln -s /opt/hercules/etc/hercules/db/ /opt/hercules/bin/
#	@ln -s /opt/hercules/etc/hercules/conf/ /opt/hercules/bin/
#	@ln -s /opt/hercules/etc/hercules/npc/ /opt/hercules/bin/
#	@ln -s /opt/hercules/var/log/hercules/ /opt/hercules/bin/log

#bin-clean:
#	@rm /opt/hercules/bin/login-server
#	@rm /opt/hercules/bin/char-server
#	@rm /opt/hercules/bin/map-server

#uninstall: bin-clean
#	@read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue."
#	@rm /opt/hercules/bin/save
#	@rm /opt/hercules/bin/db
#	@rm /opt/hercules/bin/conf
#	@rm /opt/hercules/bin/npc
#	@rm /opt/hercules/bin/log
#	@rm -rf /opt/hercules/etc/hercules
#	@rm -rf /opt/hercules/var/log/hercules