Makefile: copy files with a rule

I am trying to copy files using my rule, but my rule does not start:

BUILDDIR = build COPY_FILES = code/xml/schema/schema.xsd config.txt all: $(BUILDDIR) $(COPY_FILES) copy $(BUILDDIR): mkdir -p $@ $(COPY_FILES): cp -f $@ $(BUILDDIR) copy: cp -f $(COPY_FILES) $(BUILDDIR) 

I am trying to use $ (COPY_FILES), but it does not start, although $ (BUILDDIR) and a copy are running. I am not sure what is wrong with my Makefile. I would like to get the rule $ (COPY_FILES) to work, if possible (and delete the copy). Anyone please know?

+6
source share
1 answer

The problem with the $(COPY_FILES) rule is that the purpose of this rule is two files that already exist, namely code/xml/schema/schema.xsd and config.txt . Make does not see the reason for the rule. I'm not sure why Make does not comply with the copy rule, but I suspect that a file called copy confuses the question. In any case, [copying] is a bad rule.

Try the following:

 COPY_FILES = $(BUILD_DIR)/schema.xsd $(BUILD_DIR)/config.txt all: $(COPY_FILES) $(BUILD_DIR)/schema.xsd: code/xml/schema/schema.xsd $(BUILD_DIR)/config.txt: config.txt $(BUILD_DIR)/%: cp -f $< $@ 
+12
source

Source: https://habr.com/ru/post/951171/


All Articles