Skip to content

Commit

Permalink
Makefiles improvements and cleanup
Browse files Browse the repository at this point in the history
This should resolve #138 (please reopen or comment on it if it's not the
case). Special thanks to Takkun for helping to reproduce the issue.

Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
MishimaHaruna committed Sep 18, 2013
1 parent 78c7c6b commit babdf60
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 222 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/libconfig/Makefile.in
Expand Up @@ -8,7 +8,7 @@ CC = @CC@
export CC

#####################################################################
.PHONY : all clean help
.PHONY: all clean help

all: $(LIBCONFIG_OBJ)

Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/mt19937ar/Makefile.in
Expand Up @@ -8,7 +8,7 @@ CC = @CC@
export CC

#####################################################################
.PHONY : all clean help
.PHONY: all clean help

all: $(MT19937AR_OBJ)

Expand Down
92 changes: 53 additions & 39 deletions Makefile.in
Expand Up @@ -2,14 +2,13 @@

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
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
CONVERTERS_DEPENDS=common_sql
else
ALL_DEPENDS=needs_mysql
SQL_DEPENDS=needs_mysql
Expand Down Expand Up @@ -49,30 +48,39 @@ all: $(ALL_DEPENDS)
sql: $(SQL_DEPENDS)

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

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

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

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

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

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

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

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

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

import:
Expand All @@ -93,22 +101,29 @@ clean:
@$(MAKE) -C src/tool $@
@$(MAKE) -C src/test $@

distclean: clean
@-rm -f Makefile src/common/Makefile 3rdparty/mt19937ar/Makefile \
3rdparty/libconfig/Makefile src/char/Makefile src/login/Makefile \
src/map/Makefile src/plugins/Makefile src/tool/Makefile \
src/test/Makefile

help:
@echo "most common targets are 'all' 'sql' 'conf' 'clean' 'help'"
@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 (SQL version)"
@echo "'char_sql' - builds char server (SQL version)"
@echo "'map_sql' - builds map server (SQL version)"
@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 "'test' - builds tests"
@echo "'clean' - cleans builds and objects"
@echo "'distclean' - cleans files generated by ./configure"
@echo "'help' - outputs this message"

#####################################################################
Expand All @@ -124,35 +139,34 @@ no_plugins:
#####################################################################
# 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/rathena/bin/)
$(shell mkdir -p /opt/rathena/etc/rathena/)
$(shell mkdir -p /opt/rathena/var/log/rathena/)
$(shell mv save /opt/rathena/etc/rathena/save)
$(shell mv db /opt/rathena/etc/rathena/db)
$(shell mv conf /opt/rathena/etc/rathena/conf)
$(shell mv npc /opt/rathena/etc/rathena/npc)
$(shell mv log/* /opt/rathena/var/log/rathena/)
$(shell cp *-server* /opt/rathena/bin/)
$(shell ln -s /opt/rathena/etc/rathena/save/ /opt/rathena/bin/)
$(shell ln -s /opt/rathena/etc/rathena/db/ /opt/rathena/bin/)
$(shell ln -s /opt/rathena/etc/rathena/conf/ /opt/rathena/bin/)
$(shell ln -s /opt/rathena/etc/rathena/npc/ /opt/rathena/bin/)
$(shell ln -s /opt/rathena/var/log/rathena/ /opt/rathena/bin/log)

bin-clean:
$(shell rm /opt/rathena/bin/login-server*)
$(shell rm /opt/rathena/bin/char-server*)
$(shell rm /opt/rathena/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/rathena/bin/save)
$(shell rm /opt/rathena/bin/db)
$(shell rm /opt/rathena/bin/conf)
$(shell rm /opt/rathena/bin/npc)
$(shell rm /opt/rathena/bin/log)
$(shell rm -rf /opt/rathena/etc/rathena)
$(shell rm -rf /opt/rathena/var/log/rathena)
#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
76 changes: 45 additions & 31 deletions src/char/Makefile.in
@@ -1,27 +1,29 @@

COMMON_H = $(shell ls ../common/*.h)

MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar

LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig

COMMON_SQL_OBJ = ../common/obj_sql/sql.o
COMMON_H = ../common/sql.h

CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \
obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o obj_sql/int_elemental.o obj_sql/pincode.o
CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h int_elemental.h pincode.h
CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h)

MT19937AR_D = ../../3rdparty/mt19937ar
MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
MT19937AR_INCLUDE = -I$(MT19937AR_D)

LIBCONFIG_D = ../../3rdparty/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
scanner.o strbuf.o)
LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
scanctx.h scanner.h strbuf.h wincompat.h)
LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)

CHAR_OBJ = $(addprefix obj_sql/, char.o inter.o int_auction.o int_elemental.o \
int_guild.o int_homun.o int_mail.o int_mercenary.o int_party.o \
int_pet.o int_quest.o int_storage.o pincode.o)
CHAR_H = char.h inter.h int_auction.h int_elemental.h int_guild.h int_homun.h \
int_mail.h int_mercenary.h int_party.h int_pet.h int_quest.h \
int_storage.h pincode.h

HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ)
CHAR_SERVER_SQL_DEPENDS=$(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ)
else
CHAR_SERVER_SQL_DEPENDS=needs_mysql
endif
Expand All @@ -32,48 +34,60 @@ CC = @CC@
export CC

#####################################################################
.PHONY : all char-server clean help
.PHONY: all sql char-server clean help

all: char-server
all: sql

char-server: $(CHAR_SERVER_SQL_DEPENDS)
@echo " LD $@"
@$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
sql: char-server

clean:
@echo " CLEAN char"
@rm -rf *.o obj_sql ../../char-server@EXEEXT@

help:
@echo "possible targets are 'char-server' 'all' 'clean' 'help'"
@echo "'char-server' - char server (SQL version)"
@echo "'all' - builds all above targets"
@echo "'clean' - cleans builds and objects"
@echo "'help' - outputs this message"
@echo "'char-server' - char server"
@echo "'all' - builds all above targets"
@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

# object directories

obj_sql:
@echo " MKDIR obj_sql"
@-mkdir obj_sql

obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) $(LIBCONFIG_H)
# executables

char-server: $(CHAR_SERVER_SQL_DEPENDS)
@echo " LD $@"
@$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@

# char object files

obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<

# missing object files
../common/obj_all/common.a:
@echo " MAKE $@"
@$(MAKE) -C ../common sql

../common/obj_sql/common_sql.a:
@echo " MAKE $@"
@$(MAKE) -C ../common sql

$(MT19937AR_OBJ):
@$(MAKE) -C ../../3rdparty/mt19937ar
@echo " MAKE $@"
@$(MAKE) -C $(MT19937AR_D)

$(LIBCONFIG_OBJ):
@$(MAKE) -C ../../3rdparty/libconfig
@echo " MAKE $@"
@$(MAKE) -C $(LIBCONFIG_D)

0 comments on commit babdf60

Please sign in to comment.