Skip to content

Commit d507c27

Browse files
committed
chore: improve Makefile for minimal POSIX shell compatibility
When the shell used for `sh` is `dash`, which is common on Debian and its derivatives, the output of the Makefile is incorrect. This patch resolves the issue by using `bash` as the shell when it's available. Additionally, I refactored the `push` target to reuse the code that executes the push command for a specific directory. Lastly, the default action when you run `make` without any arguments is now to build all the extensions. Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 2a798f7 commit d507c27

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
.SUFFIXES:
22

3+
# Use bash if available, otherwise fall back to default shell
4+
SHELL := $(shell which bash 2>/dev/null || echo /bin/sh)
5+
36
# Find all directories containing metadata.hcl
47
FILES := $(shell find . -type f -name metadata.hcl)
58
DIRS := $(patsubst %/,%,$(patsubst ./%,%,$(dir $(FILES))))
69

7-
.PHONY: all clean check prereqs $(DIRS)
10+
.PHONY: all check prereqs push $(DIRS)
811

912
# Colours
1013
GREEN := \033[0;32m
@@ -15,6 +18,8 @@ NC := \033[0m
1518
# Dry run flag
1619
DRY_RUN ?= false
1720

21+
default: all
22+
1823
# --------------------------
1924
# Prerequisite checks
2025
# --------------------------
@@ -41,14 +46,7 @@ check: prereqs
4146
# --------------------------
4247
push: all
4348
@echo -e "$(BLUE)Performing bake --push for all projects...$(NC)"
44-
@$(foreach dir,$(DIRS), \
45-
echo -e "$(BLUE)[PUSH] $dir$(NC)"; \
46-
if [ "$(DRY_RUN)" = "true" ]; then \
47-
echo -e "$(GREEN)[DRY RUN] docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --push$(NC)"; \
48-
else \
49-
docker buildx bake -f $(dir)/metadata.hcl -f docker-bake.hcl --push; \
50-
fi; \
51-
)
49+
@$(foreach dir,$(DIRS), $(MAKE) push-$(dir) DRY_RUN=$(DRY_RUN);)
5250

5351
# --------------------------
5452
# Generic per-project push

0 commit comments

Comments
 (0)