2021-02-09 17:05:00 +01:00
|
|
|
##
|
2021-06-09 00:44:36 +02:00
|
|
|
# COMMON
|
|
|
|
|
2022-11-02 17:42:39 +01:00
|
|
|
# target $(APP): Call app-update
|
2021-06-09 00:44:36 +02:00
|
|
|
.PHONY: $(APP)
|
|
|
|
$(APP): APP_DIR := $(RELATIVE)$(APP)
|
2022-05-07 15:04:44 +02:00
|
|
|
$(APP): myos-user
|
2022-11-02 17:42:39 +01:00
|
|
|
$(call app-update)
|
|
|
|
|
|
|
|
# target app-%: Call app-$(command) for APP in APP_DIR
|
|
|
|
## it splits % on dashes and extracts app from the beginning and command from the last part of %
|
|
|
|
## ex: app-foo-build will call app-build for app foo in ../foo
|
|
|
|
.PHONY: app-%
|
|
|
|
app-%:
|
|
|
|
$(eval app := $(subst -$(lastword $(subst -, ,$*)),,$*))
|
|
|
|
$(eval command := $(lastword $(subst -, ,$*)))
|
2022-11-16 09:46:00 +01:00
|
|
|
$(if $(wildcard $(RELATIVE)$(app)), \
|
|
|
|
$(if $(filter app-$(command),$(.VARIABLES)), \
|
|
|
|
$(call app-bootstrap,$(app)) \
|
|
|
|
$(call app-$(command)) \
|
|
|
|
, \
|
|
|
|
$(if $(wildcard $(RELATIVE)$*), \
|
|
|
|
$(call app-bootstrap,$*) \
|
|
|
|
, \
|
|
|
|
$(call WARNING,Unable to find app command,$(command)) \
|
|
|
|
) \
|
|
|
|
) \
|
2022-11-06 00:27:14 +01:00
|
|
|
, \
|
2022-11-16 09:46:00 +01:00
|
|
|
$(call WARNING,Unable to find app,$(app),in dir,$(RELATIVE)$(app)) \
|
2022-11-02 17:42:39 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# target app-required-install: Call app-install for each APP_REQUIRED
|
|
|
|
.PHONY: app-required-install
|
2022-11-06 00:27:14 +01:00
|
|
|
app-required-install:
|
2022-11-02 17:42:39 +01:00
|
|
|
$(foreach url,$(APP_REQUIRED),$(call app-install,$(url)))
|
|
|
|
|
|
|
|
# target apps-build: Call app-build for each APPS
|
|
|
|
.PHONY: apps-build
|
2022-11-06 00:27:14 +01:00
|
|
|
apps-build:
|
2022-11-02 17:42:39 +01:00
|
|
|
$(foreach app,$(APPS),$(call app-build,$(RELATIVE)$(app)))
|
2021-06-09 00:44:36 +02:00
|
|
|
|
2022-11-02 17:42:39 +01:00
|
|
|
# target apps-install install-app: Call app-install for each ARGS
|
|
|
|
.PHONY: apps-install install-app
|
2022-11-06 00:27:14 +01:00
|
|
|
apps-install install-app: app-required-install
|
2022-11-02 17:42:39 +01:00
|
|
|
$(foreach url,$(ARGS),$(call app-install,$(url)))
|
2021-06-07 22:39:57 +02:00
|
|
|
|
2022-11-02 17:42:39 +01:00
|
|
|
# target apps-update: Call app-update target for each APPS
|
|
|
|
.PHONY: apps-update
|
|
|
|
apps-update:
|
|
|
|
$(foreach app,$(APPS),$(call make,update-app APP_NAME=$(app)))
|
|
|
|
|
|
|
|
# target debug: Print more informations
|
|
|
|
.PHONY: debug
|
|
|
|
debug:
|
|
|
|
$(MAKE) help profile DEBUG=true
|
|
|
|
|
|
|
|
# target debug-%: Print value of %
|
|
|
|
.PHONY: debug-%
|
|
|
|
debug-%: $(if $(DEBUG),context-%) ;
|
2021-06-09 00:44:36 +02:00
|
|
|
|
2022-11-11 23:37:27 +01:00
|
|
|
# target install-bin-%; Install package % when bin % is not available
|
2021-06-16 13:19:52 +02:00
|
|
|
.PHONY: install-bin-%
|
|
|
|
install-bin-%:;
|
2022-11-11 23:37:27 +01:00
|
|
|
$(if $(shell type $* 2>/dev/null),,$(RUN) $(INSTALL) $*)
|
2021-06-16 13:19:52 +02:00
|
|
|
|
2022-11-02 17:42:39 +01:00
|
|
|
# target profile: Print timing informations
|
|
|
|
.PHONY: profile
|
|
|
|
profile: context-ELAPSED_TIME
|
2021-05-31 22:29:12 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target update-app: Fire update-app-% for APP_NAME
|
2021-06-01 00:52:21 +02:00
|
|
|
.PHONY: update-app
|
2021-06-02 00:54:33 +02:00
|
|
|
update-app: update-app-$(APP_NAME) ;
|
2021-06-01 00:52:21 +02:00
|
|
|
|
2021-06-09 00:44:36 +02:00
|
|
|
# target update-app-%: Fire %
|
2021-06-01 00:52:21 +02:00
|
|
|
.PHONY: update-app-%
|
2021-06-09 00:44:36 +02:00
|
|
|
update-app-%: % ;
|
2021-06-01 00:52:21 +02:00
|
|
|
|
2021-06-09 03:41:47 +02:00
|
|
|
# target update-config: Update config files
|
2021-06-09 00:44:36 +02:00
|
|
|
.PHONY: update-config
|
2022-11-06 00:27:14 +01:00
|
|
|
update-config:
|
2022-11-02 17:42:39 +01:00
|
|
|
$(call app-update,$(CONFIG_REPOSITORY),$(CONFIG))
|
2021-05-31 22:29:12 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target update-hosts: Update /etc/hosts
|
|
|
|
# on local host
|
|
|
|
## it reads .env files to extract applications hostnames and add it to /etc/hosts
|
2021-02-09 17:05:00 +01:00
|
|
|
.PHONY: update-hosts
|
|
|
|
update-hosts:
|
2021-06-14 12:52:48 +02:00
|
|
|
ifneq (,$(filter $(ENV),local))
|
2021-06-16 13:19:52 +02:00
|
|
|
cat .env */.env 2>/dev/null |grep -Eo 'urlprefix-[^/]+' |sed 's/urlprefix-//' |while read host; do \
|
|
|
|
grep $$host /etc/hosts >/dev/null 2>&1 || { \
|
|
|
|
printf "Adding $$host to /etc/hosts\n"; \
|
|
|
|
printf "127.0.0.1 $$host\n" |$(RUN) sudo tee -a /etc/hosts >/dev/null; \
|
|
|
|
}; \
|
|
|
|
done
|
2021-02-09 17:05:00 +01:00
|
|
|
endif
|
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target update-remote-%: fetch git remote %
|
2021-02-09 17:05:00 +01:00
|
|
|
.PHONY: update-remote-%
|
2022-05-07 15:04:44 +02:00
|
|
|
update-remote-%: myos-user
|
2021-06-16 13:19:52 +02:00
|
|
|
$(RUN) git fetch --prune --tags $*
|
2021-02-09 17:05:00 +01:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target update-remotes: fetch all git remotes
|
2021-05-31 22:29:12 +02:00
|
|
|
.PHONY: update-remotes
|
2022-05-07 15:04:44 +02:00
|
|
|
update-remotes: myos-user
|
2021-06-16 13:19:52 +02:00
|
|
|
$(RUN) git fetch --all --prune --tags
|
2021-05-31 22:29:12 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target update-upstream: fetch git remote upstream
|
2021-02-09 17:05:00 +01:00
|
|
|
.PHONY: update-upstream
|
2022-05-07 15:04:44 +02:00
|
|
|
update-upstream: myos-user .git/refs/remotes/upstream/master
|
2021-06-16 13:19:52 +02:00
|
|
|
$(RUN) git fetch --prune --tags upstream
|
2021-02-09 17:05:00 +01:00
|
|
|
|
2021-06-16 13:19:52 +02:00
|
|
|
# target .git/refs/remotes/upstream/master: add git upstream APP_UPSTREAM_REPOSITORY
|
2021-06-09 00:44:36 +02:00
|
|
|
.git/refs/remotes/upstream/master:
|
2021-06-16 13:19:52 +02:00
|
|
|
$(RUN) git remote add upstream $(APP_UPSTREAM_REPOSITORY)
|
2021-06-01 01:50:11 +02:00
|
|
|
|
2021-06-02 00:54:33 +02:00
|
|
|
# target shared: Fire SHARED
|
2021-06-01 01:50:11 +02:00
|
|
|
.PHONY: update-shared
|
|
|
|
update-shared: $(SHARED)
|
2022-11-02 17:42:39 +01:00
|
|
|
|
|
|
|
# target $(SHARED): Create SHARED folder
|
|
|
|
$(SHARED):
|
|
|
|
$(RUN) mkdir -p $(SHARED)
|