From: Michal Sojka Date: Tue, 30 Dec 2008 12:45:14 +0000 (+0100) Subject: Working version of test rules X-Git-Url: http://rtime.felk.cvut.cz/gitweb/omk.git/commitdiff_plain/6d5cd0765c44cd5c8becee8922f644b0fb7e0acb Working version of test rules --- diff --git a/snippets/Makefile.rules.test b/snippets/Makefile.rules.test index d8d708e..30e1bb3 100644 --- a/snippets/Makefile.rules.test +++ b/snippets/Makefile.rules.test @@ -1,3 +1,4 @@ +# -*- makefile-gmake -*- include base #omkbuild USER_INCLUDE_DIR := $(OUTPUT_DIR)/$(COMPILED_DIR_NAME)/include @@ -11,7 +12,6 @@ LINK_BUILD_DIR := $(OUTPUT_DIR)/$(BUILD_DIR_NAME)/link # Avoid double slash at the end in the top-level directory USER_OBJS_DIR = $(USER_BUILD_DIR)$(RELATIVE_DIR:%=/%) KERN_OBJS_DIR = $(KERN_BUILD_DIR)$(RELATIVE_DIR:%=/%) -OMK_WORK_DIR = $(USER_OBJS_DIR) ############ # Programs # @@ -46,14 +46,14 @@ $(1)_OBJS := $$(addprefix $(USER_OBJS_DIR)/,$$(sort $$($(1)_OBJS:%/=%))) USER_OBJS += $$($(1)_OBJS) USER_SOURCES += $$($(1)_SOURCES) -$(call prepare_rule_goal,\ +$$(eval $$(call prepare_rule_goal,\ $(USER_BIN_DIR)/$(1)$(EXE_SUFFIX),\ - $$($(1)_OBJS) $$($(1)_LIBS),\ + $$($(1)_OBJS),\ "LINK ",\ - $(program_cmd)) + $$(call program_cmd,$(1)))) endef -program_cmd = $(if $(filter %.cc,$$($(1)_SOURCES)),$(CXX),$(CC)) \ +program_cmd = $(if $(filter %.cc,$($(1)_SOURCES)),$(CXX),$(CC)) \ $($(1)_OBJS) $($(1)_LIBS:%=-l%) $(LOADLIBES) $(LDFLAGS) -Wl,-rpath-link,$(USER_LIB_DIR) \ -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $$@ @@ -72,14 +72,6 @@ $(eval $(call prepare_rule_goal,\ "CC ",\ $(c_o_cmd))) -# OUTPUT_DIR is not defined in Makefile.build so we has to pass it on -# command-line. After this file will be merged with Makefile.rules, it -# will not be necessary to pass it. -default: check-dir prepare-pass - -$(MAKE) -qp -f $(MAKERULES_DIR)/Makefile.rules build > make.db.build-pseudo-pass; - +@echo "make[omk]: build" - @$(MAKE) $(NO_PRINT_DIRECTORY) -f $(MAKERULES_DIR)/Makefile.rules build - check-dir:: @$(call mkdir_def,$(USER_BUILD_DIR)) @$(call mkdir_def,$(USER_INCLUDE_DIR)) diff --git a/snippets/base b/snippets/base index d39f493..4e7709c 100644 --- a/snippets/base +++ b/snippets/base @@ -33,7 +33,7 @@ ifndef OUTPUT_DIR OUTPUT_DIR := $(MAKERULES_DIR) endif -.PHONY: all default check-make-ver omkize +.PHONY: all default check-make-ver omkize prepare build ifdef W ifeq ("$(origin W)", "command line") @@ -45,8 +45,19 @@ ifndef OMK_WHOLE_TREE endif ifneq ($(OMK_WHOLE_TREE),1) -all: check-make-ver default + ifndef omk_prereq_checked + omk_checks=check-make-ver check-dir + export omk_prereq_checked=1 + endif +all: build + +prepare: $(omk_checks) prepare-pass +build: prepare + +@echo "make[omk]: build" + @$(MAKE) $(NO_PRINT_DIRECTORY) -f $(MAKERULES_DIR)/Makefile.rules build-pseudo-pass @echo "Compilation finished" + +prepare-pass: $(omk_checks) else # Run make in the top-level directory all: @@ -180,6 +191,7 @@ endif OMK_INCLUDED := 1 endif + check-make-ver: @GOOD_MAKE_VERSION=`echo $(MAKE_VERSION) | sed -n -e 's/^[4-9]\..*\|^3\.9[0-9].*\|^3\.8[1-9].*/y/p'` ; \ if [ x$$GOOD_MAKE_VERSION != xy ] ; then \ diff --git a/snippets/build b/snippets/build index 038cd9e..17ba0a4 100644 --- a/snippets/build +++ b/snippets/build @@ -2,9 +2,7 @@ ##################### -*- makefile-gmake -*- # Build pseudo-pass # ##################### -ifneq (,$(filter build,$(MAKECMDGOALS))) -all: build-pseudo-pass - +ifneq (,$(filter build-pseudo-pass,$(MAKECMDGOALS))) rule_targets = $(value $(1)_targets) rule_deps = $(value $(1)_deps) rule_msg = $(value $(1)_msg) @@ -18,11 +16,13 @@ $(rule_targets): $(rule_deps) #$(omk_inc_file) endef # TODO: Include __goals.omk.inc only in the subtree --include $(shell true; find $(USER_BUILD_DIR) -name '*.omk.inc') # `true' is a hack for MinGW +-include $(shell true; find $(BUILD_OMK_DIR) -name '*.omk.inc') # `true' is a hack for MinGW # FIXME: Disable automatic remake of included files $(foreach rule,$(prepared_rules),$(eval $(call build_rule,$(rule)))) -.PHONY: build -build: $(foreach target,$(omk_goals),$(target)) +.PHONY: build build-msg all-targets + +build-pseudo-pass: $(foreach target,$(omk_goals),$(target)) + endif # (,$(filter build,$(MAKECMDGOALS))) diff --git a/snippets/prepare b/snippets/prepare index 1886955..8284577 100644 --- a/snippets/prepare +++ b/snippets/prepare @@ -29,7 +29,8 @@ subst-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(1)))) define prepare_rule prepare-pass-local: $(omk_inc_file) -$(omk_inc_file): FORCE +.PHONY: $(omk_inc_file) +$(omk_inc_file): #TODO remove the next line @echo " PREP "$$(call strip_out,$$@); \ echo 'prepared_rules += $(omk_inc_rule)' > $$@.tmp; \ @@ -51,7 +52,7 @@ endef prepare-pass-local: $(OMK_WORK_DIR)/__goals.omk.inc $(OMK_WORK_DIR)/__goals.omk.inc: FORCE - $(Q)echo 'omk_goals += $(prepared_goals)' > $@.tmp; \ + @echo 'omk_goals += $(prepared_goals)' > $@.tmp; \ if cmp -s $@.tmp $@; then rm $@.tmp; else mv $@.tmp $@; fi