r/mercury•
avanov

How to instruct mmc to lookup the main file/module in a specific non-current directory?

Subj. I'm looking for a way to integrate mmc into my exisitng Makefile pipelines that reside separate to mercury source code files. I can provide an absolute path to the location where souce files and modules could be found, but unfortunately the current mmc --help output is not very informative on whether that's possible at all. So far I'm getting this error:

/Users/user/projects/mercury-playground/src/main.m
/nix/store/781y33icqqb7cs02r6qymlk8rbbsis82-mercury-20.06.1/bin/mkinit: error opening output file `Mercury/cs//Users/user/projects/mercury-playground/.local/x86_64-darwin/build/main-exe_init.c.tmp': No such file or directory
make: *** [Makefile:33: /Users/user/projects/mercury-playground/.local/x86_64-darwin/build/main-exe] Error 1

Here's the build template:

$(BUILD_DIR):
	install -dm0755 $(BUILD_DIR)

$(BUILD_NAME): $(BUILD_DIR)
	mmc	--output-file	$(BUILD_NAME) \
		--use-subdirs \
		$(SRC_DIR)/main.m

UPD: seems like the error progressed to another one, as soon as I added --use-subdirs. I updated the post.

Posted Oct 6, 2021, 10:04 PM UTC · edited

31
avanovOP•

OK, I managed to fix it with the following:

$(BUILD_DIR):
	install -dm0755 $(BUILD_DIR)

$(DIST_DIR):
	install -dm0755 $(DIST_DIR)

$(BUILD_NAME): $(BUILD_DIR)
	cd $(BUILD_DIR) && \
	mmc	--output-file	$(BUILD_NAME)	\
		$(SRC_DIR)/main.m

.PHONY: build
build: $(BUILD_NAME)

.PHONY: run
run: $(BUILD_NAME)
	$(BUILD_NAME)

My next question is why it doesn't work without explicit cd and when --use-subdirs is provided.

3