Skip to content

Makefile: run the cd commands in a subshell#5073

Closed
konimex wants to merge 1 commit intocurl:masterfrom
konimex:bmake
Closed

Makefile: run the cd commands in a subshell#5073
konimex wants to merge 1 commit intocurl:masterfrom
konimex:bmake

Conversation

@konimex
Copy link
Copy Markdown
Contributor

@konimex konimex commented Mar 11, 2020

In bmake, if the directory is changed (with cd or anything else), bmake won't return to the "root directory" on the next command (in the same Makefile rule). This commit runs the cd command in a subshell so it would work in bmake. This has been applied in

tidy:
so I don't see why it shouldn't apply anywhere else.

Logs:
Before my commit
After my commit

In bmake, if the directory is changed (with cd or anything else), bmake
won't return to the "root directory"  on the next command (in the same
Makefile rule). This commit runs the cd command in a subshell so it
would work in bmake.
@bagder
Copy link
Copy Markdown
Member

bagder commented Mar 11, 2020

Only one question: should we prefer $(MAKE) -C $dir to (cd $dir && $(MAKE)) ? Looking at our current makefile set, we use a mix all over...

@bagder bagder added the build label Mar 11, 2020
@konimex
Copy link
Copy Markdown
Contributor Author

konimex commented Mar 11, 2020

If POSIX is of any concern, then the latter. However, both GNU make and BSD make support -C, so I don't know if there are any more make(1) implementations that don't implement -C.

@bagder
Copy link
Copy Markdown
Member

bagder commented Mar 11, 2020

Thanks! So let's go with the cd approach. Will merge!

@bagder bagder closed this in 0cc66ff Mar 11, 2020
@konimex konimex deleted the bmake branch March 11, 2020 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants