udrone/Makefile

84 lines
2.2 KiB
Makefile
Raw Permalink Normal View History

2022-09-22 23:18:43 +03:00
APP_NAME = UDrone
APP_PATH = $(pwd)
SHELL ?= /bin/bash
ARGS = $(filter-out $@,$(MAKECMDGOALS))
BUILD_ID ?= $(shell /bin/date "+%Y%m%d-%H%M%S")
.SILENT: ; # no need for @
.ONESHELL: ; # recipes execute in same shell
.NOTPARALLEL: ; # wait for this target to finish
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
Makefile: ; # skip prerequisite discovery
.DEFAULT_GOAL = help
ifneq ("$(wildcard ./VERSION)","")
VERSION ?= $(shell cat ./VERSION | head -n 1)
else
VERSION ?= 1.0.0
endif
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
LIGHTRED='\033[1;31m'
LIGHTGREEN='\033[1;32m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTPURPLE='\033[1;35m'
LIGHTCYAN='\033[1;36m'
WHITE='\033[1;37m'
%.env:
cp $@.dist $@
.PHONY: .title
.title:
$(info $(APP_NAME) v$(VERSION))
2022-09-23 13:22:14 +03:00
.PHONY: install
install: ## Install all deps
2022-09-22 23:18:43 +03:00
npm install
2022-09-23 13:22:14 +03:00
$(info Building Browser MQTT library)
2022-09-22 23:18:43 +03:00
cd node_modules/mqtt
npm install
webpack ./mqtt.js --output-library mqtt
2022-09-23 13:22:14 +03:00
.PHONY: build
build: ## Build frontend (default: env=dev)
ifeq ($(env), prod)
$(info Building frontend for production)
npm run build:prod
else
$(info Building frontend for development)
npm run build:dev
endif
2022-09-22 23:18:43 +03:00
# Public targets
.PHONY: test
test: ## Start test webserver
python3 server.py
.PHONY: help
help: .title ## Show this help and exit (default target)
echo ''
printf " %s: \033[94m%s\033[0m \033[90m[%s] [%s]\033[0m\n" "Usage" "make" "target" "ENV_VARIABLE=ENV_VALUE ..."
echo ''
echo ' Available targets:'
echo ' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
grep -hE '^[a-zA-Z. 0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## " }; {printf "\033[36m%+15s\033[0m: %s\n", $$1, $$2}'
echo ' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
echo ''
%:
@: