diff --git a/libjs.make b/libjs.make index da8f17d3..e3a24c98 100644 --- a/libjs.make +++ b/libjs.make @@ -1,8 +1,14 @@ # # This makefile is used to build the Javascript dependency for Oolite # -# It can be used to make both a release Javascript library and a -# debug library. +# This Makefile is used to download and build the Javascript library +# for use by Oolite. +# Depending on invocation, a debug or release (default) version of the +# library will be built. +# +# To use: +# $ make -f libjs.make debug=(yes|no) + include config.make LIBJS_SRC_DIR = deps/Cross-platform-deps/mozilla/js/src @@ -13,7 +19,7 @@ ifeq ($(OO_JAVASCRIPT_TRACE),yes) LIBJS_CONFIG_FLAGS += --enable-trace-jscalls endif ifeq ($(debug),yes) - LIBJS_BUILD_DIR=$(LIBJS_SRC_DIR)/build-debug + LIBJS_BUILD_DIR = $(LIBJS_SRC_DIR)/build-debug LIBJS_CONFIG_FLAGS += --enable-debug LIBJS_CONFIG_FLAGS += --disable-optimize LIBJS_BUILD_FLAGS = @@ -22,20 +28,46 @@ else LIBJS_BUILD_FLAGS = endif LIBJS = $(LIBJS_BUILD_DIR)/libjs_static.a +LIBJS_BUILD_STAMP = $(LIBJS_BUILD_DIR)/build_stamp +LIBJS_CONFIG = $(LIBJS_BUILD_DIR)/config.status +LIBJS_CONFIG_STAMP = $(LIBJS_BUILD_DIR)/config_stamp -$(LIBJS): LIBJS_SRC + +.PHONY: all +all: LIBJS_SRC $(LIBJS) + +$(LIBJS): $(LIBJS_BUILD_STAMP) + +$(LIBJS_BUILD_STAMP): $(LIBJS_CONFIG_STAMP) @echo @echo "Building Javascript library..." @echo - cd $(LIBJS_BUILD_DIR) && ../configure $(LIBJS_CONFIG_FLAGS) make -C $(LIBJS_BUILD_DIR) $(LIBJS_BUILD_FLAGS) + touch $@ + +$(LIBJS_CONFIG_STAMP): + @echo + @echo "Configuring Javascript library..." + @echo + cd $(LIBJS_BUILD_DIR) && ../configure $(LIBJS_CONFIG_FLAGS) + touch $@ .PHONY: LIBJS_SRC LIBJS_SRC: - echo "Updating Javascript sources..." + @echo + @echo "Updating Javascript sources..." + @echo cd deps/Cocoa-deps/scripts && ./update-mozilla.sh mkdir -p $(LIBJS_BUILD_DIR) .PHONY: clean clean: -make -C $(LIBJS_BUILD_DIR) clean + -rm -f $(LIBJS_BUILD_STAMP) + +# This target also removes the configuration status, forcing +# a reconfiguration. Use this after changing LIBJS_CONFIG_FLAGS +.PHONY: distclean +distclean: + -make -C $(LIBJS_BUILD_DIR) distclean + -rm -f $(LIBJS_CONFIG_STAMP)