summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 667b79fbce67b005a65328146e52e39c71b81338 (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
@SET_MAKE@

HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
	ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql tools converters import save
	SQL_DEPENDS=common_sql login_sql char_sql map_sql import save
	COMMON_SQL_DEPENDS=
	LOGIN_SQL_DEPENDS=common_sql
	CHAR_SQL_DEPENDS=common_sql
	MAP_SQL_DEPENDS=common_sql
	CONVERTERS_DEPENDS=common_sql
else
	ALL_DEPENDS=common login char map tools import save
	SQL_DEPENDS=needs_mysql
	COMMON_SQL_DEPENDS=needs_mysql
	LOGIN_SQL_DEPENDS=needs_mysql
	CHAR_SQL_DEPENDS=needs_mysql
	MAP_SQL_DEPENDS=needs_mysql
	CONVERTERS_DEPENDS=needs_mysql
endif

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

#####################################################################
.PHONY: txt sql conf \
	common common_sql \
	login login_sql \
	char char_sql \
	map map_sql \
	tools converters plugins addons import save \
	clean help

all: $(ALL_DEPENDS)

txt: common login char map import save

sql: $(SQL_DEPENDS)

conf: import save

common:
	@$(MAKE) -C src/common txt

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

login: common
	@$(MAKE) -C src/login txt

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

char: common
	@$(MAKE) -C src/char

char_sql: $(CHAR_SQL_DEPENDS)
	@$(MAKE) -C src/char_sql

map: common
	@$(MAKE) -C src/map txt

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

tools:
	@$(MAKE) -C src/tool

converters: $(CONVERTERS_DEPENDS)
	@$(MAKE) -C src/txt-converter

plugins addons: $(PLUGIN_DEPENDS)
	@$(MAKE) -C src/plugins

import:
# 1) create conf/import folder
# 2) add missing files
# 3) remove remaining .svn folder
	@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
	@rm -rf conf/import/.svn

save:
# 1) create save folder
# 2) add missing files
# 3) remove remaining .svn folder
	@echo "building save folder..."
	@if test ! -d save ; then mkdir save ; fi
	@for f in $$(ls save-tmpl) ; do if test ! -e save/$$f ; then cp save-tmpl/$$f save ; fi ; done
	@rm -rf save/.svn

clean:
	@$(MAKE) -C src/common $@
	@$(MAKE) -C src/login $@
	@$(MAKE) -C src/char $@
	@$(MAKE) -C src/char_sql $@
	@$(MAKE) -C src/map $@
	@$(MAKE) -C src/plugins $@
	@$(MAKE) -C src/tool $@
	@$(MAKE) -C src/txt-converter $@

help:
	@echo "most common targets are 'all' 'txt' 'sql' 'conf' 'clean' 'help'"
	@echo "possible targets are:"
	@echo "'common'      - builds object files used in TXT servers"
	@echo "'common_sql'  - builds object files used in SQL servers"
	@echo "'login'       - builds login server (TXT version)"
	@echo "'login_sql'   - builds login server (SQL version)"
	@echo "'char'        - builds char server (TXT version)"
	@echo "'char_sql'    - builds char server (SQL version)"
	@echo "'map'         - builds map server (TXT version)"
	@echo "'map_sql'     - builds map server (SQL version)"
	@echo "'tools'       - builds all the tools in src/tools"
	@echo "'converters'  - builds the login/char converters"
	@echo "'plugins'     - builds all the plugins in src/plugins"
	@echo "'addons'"
	@echo "'import'      - builds conf/import folder from the template conf/import-tmpl"
	@echo "'save'        - builds save folder from the template save-tmpl"
	@echo "'all'         - builds all the above targets"
	@echo "'txt'         - builds txt servers (targets 'common' 'login' 'char' 'map'"
	@echo "                'import' and 'save')"
	@echo "'sql'         - builds sql servers (targets 'common_sql' 'login_sql' 'char_sql'"
	@echo "                'map_sql' 'import' and 'save')"
	@echo "'conf'        - builds templated folders/files (targets 'import' and 'save')"
	@echo "'clean'       - cleans builds and objects"
	@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
	$(shell read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue.")
	$(shell mkdir -p /opt/eathena/bin/)
	$(shell mkdir -p /opt/eathena/etc/eathena/)
	$(shell mkdir -p /opt/eathena/var/log/eathena/)
	$(shell mv save /opt/eathena/etc/eathena/save)
	$(shell mv db /opt/eathena/etc/eathena/db)
	$(shell mv conf /opt/eathena/etc/eathena/conf)
	$(shell mv npc /opt/eathena/etc/eathena/npc)
	$(shell mv log/* /opt/eathena/var/log/eathena/)
	$(shell cp *-server* /opt/eathena/bin/)
	$(shell ln -s /opt/eathena/etc/eathena/save/ /opt/eathena/bin/)
	$(shell ln -s /opt/eathena/etc/eathena/db/ /opt/eathena/bin/)
	$(shell ln -s /opt/eathena/etc/eathena/conf/ /opt/eathena/bin/)
	$(shell ln -s /opt/eathena/etc/eathena/npc/ /opt/eathena/bin/)
	$(shell ln -s /opt/eathena/var/log/eathena/ /opt/eathena/bin/log)

bin-clean:
	$(shell rm /opt/eathena/bin/login-server*)
	$(shell rm /opt/eathena/bin/char-server*)
	$(shell rm /opt/eathena/bin/map-server*)

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