TARGETS := all dist clean

#SUBDIRS := $(wildcard */.)
SUBDIRS = src src/contrib

SUBDIRGOALS := all

SUBDIRSCLEAN=$(addsuffix clean,$(SUBDIRS))



all: $(SUBDIRS) dist

$(TARGETS): $(SUBDIRS)

$(SUBDIRS):
	$(MAKE) -C $@

dist:
	mkdir -p dist/opt/radangel
	cp -p src/radangel dist/opt/radangel/radangel
	strip -s dist/opt/radangel/radangel
	mkdir -p dist/opt/websockify
	cp -p src/contrib/websockify dist/opt/websockify/websockify
	strip -s dist/opt/websockify/websockify
	mkdir -p dist/etc/systemd/system
	cp -p service/*.service dist/etc/systemd/system/
	mkdir -p dist/var/www/html/gamma
	cp -rp html/. dist/var/www/html/gamma/
	mkdir -p dist/etc/nginx/sites-available
	cp -p config/nginx*.conf dist/etc/nginx/sites-available/

%clean: %
	$(MAKE) -C $< clean

cleanproj:
	rm -rf dist

clean: $(SUBDIRSCLEAN) cleanproj

.PHONY: $(TARGETS) $(SUBDIRS)


