From: Junio C Hamano Date: Thu, 02 Jul 2026 01:35:44 GMT Subject: Re: [PATCH v2] Makefile: link osxkeychain & support universal Rust Message-ID: In-Reply-To: "Shardul Natu via GitGitGadget" writes: > From: Shnatu > Signed-off-by: Shardul Natu You'd want to make sure these two match. > To implement this cleanly without complex shell scripting in recipes: > 1. We introduce a declarative Make pattern rule (target/%/...) to > compile each target-specific library slice (e.g., > target/aarch64-apple-darwin/...). > 2. We update the $(RUST_LIB) recipe to depend on the list of > compiled target-specific member libraries ($(RUST_MEMBER_LIBS)). > 3. On macOS, if multiple targets are specified, we use lipo to > combine them into a single Universal static library at > target/release/libgitcore.a. > 4. If only one target is specified, we copy it to the standard > path. > 5. We enforce that building for multiple targets requires macOS > (as lipo is only available there), raising a clear make error > on other platforms. > > This is a highly elegant and native Makefile solution that avoids > complex shell scripting in recipes and fully supports macOS Universal > Binaries. You're the second person on this list I saw who calls their own creation "elegant" ;-). > +$(RUST_LIB): $(RUST_MEMBER_LIBS) > + $(QUIET_GEN)\ > + if [ $(words $(RUST_TARGETS)) -gt 1 ]; then \ > + lipo -create $^ -output $@; \ > + else \ > + cp $< $@; \ > + fi > +endif Do we know that leading directories to $(RUST_LIB) target has already been created at this point? If not, we may want to have $(RUST_LIB): $(RUST_MEMBER_LIBS) + $(call mkdir_p_parent_template) $(QUIET_GEN)\ if [ $(words $(RUST_TARGETS)) -gt 1 ]; then \ lipo -create $^ -output $@; \ on top. Thanks for making the build procedure better.