Reputation:
My compressed audio cafs, which should be copied by the 4th rule below, are being processed prematurely by the second rule because Assets/Audio/Compressed/Blah.caf matches the second rule (but I only want files in Assets/Audio (no deeper) to be handled by this rule). Ideas? I don't really want to simply change the rule order (as I think there may be other issues with that):
$(ASSETS_TARGET_PATH)/$(AUDIO_DIR):
mkdir -p $(ASSETS_TARGET_PATH)/$(AUDIO_DIR)
$(ASSETS_TARGET_PATH)/$(AUDIO_DIR)/%.caf: $(BUILD_DIR)/$(ASSETS_DIR)/$(AUDIO_DIR)/%.caf
cp '$<' $(ASSETS_TARGET_PATH)/$(AUDIO_DIR)
$(ASSETS_TARGET_PATH)/$(AUDIO_DIR)/$(AUDIO_COMPRESSED_DIR):
mkdir -p $(ASSETS_TARGET_PATH)/$(AUDIO_DIR)/$(AUDIO_COMPRESSED_DIR)
$(ASSETS_TARGET_PATH)/$(AUDIO_DIR)/$(AUDIO_COMPRESSED_DIR)/%.caf: $(BUILD_DIR)/$(ASSETS_DIR)/$(AUDIO_DIR)/$(AUDIO_COMPRESSED_DIR)/%.caf
cp '$<' $(ASSETS_TARGET_PATH)/$(AUDIO_DIR)/$(AUDIO_COMPRESSED_DIR)
Upvotes: 1
Views: 490
Reputation: 44804
Part of the problem is that you are abusing pattern rules. They are really intended for more global situations, like telling make how to create *.o's from *.c's. Mundane things like directories shouldn't matter to them.
I would suggest you create a comprehensive list of targets using globbing on your root directory. Then you can use string substitutions to get targets for the higher rules.
CAF_ASSETS := $(notdir $(wildcard $(BUILD_DIR)/$(ASSETS_DIR)/$(AUDIO_DIR)/*.caf))
Once you have this, you can either transform it with make functions into a parallel list of targets, or you can use a static pattern rule like so:
CAF_TARGETS := $(addprefix $(ASSETS_TARGET_PATH)/$(AUDIO_DIR)/, $(CAF_ASSETS))
$(CAF_TARGETS) : $(ASSETS_TARGET_PATH)/$(AUDIO_DIR)/%.caf : $(BUILD_DIR)/$(ASSETS_DIR)/$(AUDIO_DIR)/%.caf
cp '$<' '$@'
The advantage of the static pattern rule is that it limits the pattern rule to just the listed files.
Upvotes: 2
Reputation: 13450
I have a feeling this is overdoing Makefiles.
Why don't you write a simple script to process the files?
find . -type f -name *.caf -exec ProcessScript <args> {} \;
ProcessScript
should convert each file passed to it as the last argument,
where the {}
is written in the above line.
You have <args>
for any other arguments to the script you may want to pass.
Upvotes: 0