Skip to content

Commit

Permalink
Added Makefile.in change detection (and auto-rebuild) capabilities
Browse files Browse the repository at this point in the history
- If a Makefile.in is changed, ./config.status (or ./configure in case
  it's not available) will be automatically run to update the Makefiles.
- Special thanks to Yommy for the idea.

Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
MishimaHaruna committed Sep 21, 2013
1 parent 0d12201 commit beaf3a2
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 32 deletions.
5 changes: 4 additions & 1 deletion 3rdparty/libconfig/Makefile.in
Expand Up @@ -24,6 +24,9 @@ help:

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

%.o: %.c $(LIBCONFIG_H)
Makefile: Makefile.in
@$(MAKE) -C ../.. 3rdparty/libconfig/Makefile

%.o: %.c $(LIBCONFIG_H) Makefile
@echo " CC $<"
@$(CC) @CFLAGS@ @DEFS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
4 changes: 4 additions & 0 deletions 3rdparty/mt19937ar/Makefile.in
Expand Up @@ -24,6 +24,10 @@ help:

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

Makefile: Makefile.in
@$(MAKE) -C ../.. 3rdparty/mt19937ar/Makefile

%.o: %.c $(LIBCONFIG_H) Makefile
%.o: %.c $(MT19937AR_H)
@echo " CC $<"
@$(CC) @CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
52 changes: 35 additions & 17 deletions Makefile.in
Expand Up @@ -27,6 +27,10 @@ else
PLUGIN_DEPENDS=no_plugins
endif

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

CC = @CC@
export CC

Expand All @@ -41,56 +45,73 @@ export CC
plugins \
import \
test \
clean help
clean \
help

all: $(ALL_DEPENDS)

sql: $(SQL_DEPENDS)

common_sql: $(COMMON_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:
mt19937ar: 3rdparty/mt19937ar/Makefile
@echo " MAKE $@"
@$(MAKE) -C 3rdparty/mt19937ar

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

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

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

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

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

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

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

import:
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:
clean: $(MF_TARGETS)
@$(MAKE) -C src/common $@
@$(MAKE) -C 3rdparty/mt19937ar $@
@$(MAKE) -C 3rdparty/libconfig $@
Expand All @@ -102,12 +123,9 @@ clean:
@$(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
@-rm -f $(MF_TARGETS) config.status config.log

help:
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"
Expand Down
5 changes: 4 additions & 1 deletion src/char/Makefile.in
Expand Up @@ -57,6 +57,9 @@ needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1

Makefile: Makefile.in
@$(MAKE) -C ../.. src/char/Makefile

# object directories

obj_sql:
Expand All @@ -65,7 +68,7 @@ obj_sql:

# executables

char-server: $(CHAR_SERVER_SQL_DEPENDS)
char-server: $(CHAR_SERVER_SQL_DEPENDS) Makefile
@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@

Expand Down
15 changes: 9 additions & 6 deletions src/common/Makefile.in
Expand Up @@ -59,6 +59,9 @@ help:

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

Makefile: Makefile.in
@$(MAKE) -C ../.. src/common/Makefile

needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1
Expand All @@ -73,23 +76,23 @@ obj_sql:
@echo " MKDIR obj_sql"
@-mkdir obj_sql

obj_all/common.a: $(COMMON_OBJ)
obj_all/common.a: $(COMMON_OBJ) Makefile
@echo " AR $@"
@@AR@ rcs obj_all/common.a $(COMMON_OBJ)

obj_all/common_mini.a: $(COMMON_MINI_OBJ)
obj_all/common_mini.a: $(COMMON_MINI_OBJ) Makefile
@echo " AR $@"
@@AR@ rcs obj_all/common_mini.a $(COMMON_MINI_OBJ)

obj_sql/common_sql.a: $(COMMON_SQL_OBJ)
obj_sql/common_sql.a: $(COMMON_SQL_OBJ) Makefile
@echo " AR $@"
@@AR@ rcs obj_sql/common_sql.a $(COMMON_SQL_OBJ)

common: $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a
common: $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a Makefile

common_mini: $(COMMON_MINI_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common_mini.a
common_mini: $(COMMON_MINI_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common_mini.a Makefile

common_sql: $(COMMON_SQL_OBJ) obj_sql/common_sql.a
common_sql: $(COMMON_SQL_OBJ) obj_sql/common_sql.a Makefile

obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_all
@echo " CC $<"
Expand Down
5 changes: 4 additions & 1 deletion src/login/Makefile.in
Expand Up @@ -50,6 +50,9 @@ help:

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

Makefile: Makefile.in
@$(MAKE) -C ../.. src/login/Makefile

needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1
Expand All @@ -62,7 +65,7 @@ obj_sql:

# executables

login-server: $(LOGIN_SERVER_SQL_DEPENDS)
login-server: $(LOGIN_SERVER_SQL_DEPENDS) Makefile
@echo " LD $@"
@$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@

Expand Down
5 changes: 4 additions & 1 deletion src/map/Makefile.in
Expand Up @@ -66,6 +66,9 @@ help:

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

Makefile: Makefile.in
@$(MAKE) -C ../.. src/map/Makefile

needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1
Expand All @@ -78,7 +81,7 @@ obj_sql:

# executables

map-server: $(MAP_SERVER_SQL_DEPENDS)
map-server: $(MAP_SERVER_SQL_DEPENDS) Makefile
@echo " LD $@"
@$(CC) @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@

Expand Down
5 changes: 4 additions & 1 deletion src/plugins/Makefile.in
Expand Up @@ -11,7 +11,7 @@ export CC
#####################################################################
.PHONY: all $(PLUGINS) sample db2sql clean help

all: $(PLUGINS)
all: $(PLUGINS) Makefile

sample: sample@DLLEXT@

Expand All @@ -28,6 +28,9 @@ help:

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

Makefile: Makefile.in
@$(MAKE) -C ../.. src/plugins/Makefile

%@DLLEXT@: %.c $(COMMON_H)
@echo " CC $<"
@$(CC) @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o ../../plugins/$@ $<
7 changes: 5 additions & 2 deletions src/test/Makefile.in
Expand Up @@ -26,14 +26,17 @@ export CC
#####################################################################
.PHONY: all test_spinlock

all: test_spinlock
all: test_spinlock Makefile

clean:
@echo " CLEAN test"
@rm -rf *.o obj ../../test_spinlock@EXEEXT@

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

Makefile: Makefile.in
@$(MAKE) -C ../.. src/test/Makefile

# object directories

obj:
Expand All @@ -42,7 +45,7 @@ obj:

#executables

test_spinlock: $(TEST_SPINLOCK_DEPENDS)
test_spinlock: $(TEST_SPINLOCK_DEPENDS) Makefile
@echo " LD $@"
@$(CC) @LDFLAGS@ -o ../../test_spinlock@EXEEXT@ $(TEST_SPINLOCK_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@

Expand Down
7 changes: 5 additions & 2 deletions src/tool/Makefile.in
Expand Up @@ -24,9 +24,9 @@ export CC
#####################################################################
.PHONY: all mapcache clean help

all: mapcache
all: mapcache Makefile

mapcache: $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ)
mapcache: $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) Makefile
@echo " LD $@"
@$(CC) @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@

Expand All @@ -43,6 +43,9 @@ help:

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

Makefile: Makefile.in
@$(MAKE) -C ../.. src/tool/Makefile

obj_all:
@echo " MKDIR obj_all"
@-mkdir obj_all
Expand Down

0 comments on commit beaf3a2

Please sign in to comment.