Your Name | 8324a3a | 2017-05-12 10:47:21 +0000 | [diff] [blame] | 1 | DESTDIR=/ |
| 2 | SALTENVDIR=/usr/share/salt-formulas/env |
| 3 | RECLASSDIR=/usr/share/salt-formulas/reclass |
| 4 | FORMULANAME=$(shell grep name: metadata.yml|head -1|cut -d : -f 2|grep -Eo '[a-z0-9\-\_]*') |
| 5 | |
| 6 | MAKE_PID := $(shell echo $$PPID) |
| 7 | JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)"))) |
| 8 | |
| 9 | ifneq ($(subst -j,,$(JOB_FLAG)),) |
| 10 | JOBS := $(subst -j,,$(JOB_FLAG)) |
| 11 | else |
| 12 | JOBS := 1 |
| 13 | endif |
| 14 | |
| 15 | all: |
| 16 | @echo "make install - Install into DESTDIR" |
| 17 | @echo "make test - Run tests" |
| 18 | @echo "make clean - Cleanup after tests run" |
| 19 | |
| 20 | install: |
| 21 | # Formula |
| 22 | [ -d $(DESTDIR)/$(SALTENVDIR) ] || mkdir -p $(DESTDIR)/$(SALTENVDIR) |
| 23 | cp -a $(FORMULANAME) $(DESTDIR)/$(SALTENVDIR)/ |
| 24 | [ ! -d _modules ] || cp -a _modules $(DESTDIR)/$(SALTENVDIR)/ |
| 25 | [ ! -d _states ] || cp -a _states $(DESTDIR)/$(SALTENVDIR)/ || true |
| 26 | # Metadata |
| 27 | [ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) |
| 28 | cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) |
| 29 | |
| 30 | test: |
| 31 | [ ! -d tests ] || (cd tests; ./run_tests.sh) |
| 32 | |
| 33 | clean: |
| 34 | [ ! -d tests/build ] || rm -rf tests/build |
| 35 | [ ! -d build ] || rm -rf build |