~eda-qa/dhlib/main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
## Use mindepth 2 to exlclude this file in the packaged version
ALLMK=${shell find . -mindepth 2 -name "makefile"}
ALLDOC=${shell find doc -name "makefile"}
SUBMAKE=${MAKE}  -I ${abspath .} DHLIB_ROOT=${abspath .}

## all will do all makefile "all" targets in all subdirectories
all: SUBTARGET=all
all: $(ALLMK) swftest

.PHONY: help
help:
	@echo -e \
		all: Build all targets \\n\
		test: Run all tests \\n\
		swftest: Build HTML SWF test page \\n\
		doc: Build documentation \\n\
		distrib-package: Distribution package \\n\
		distrib-haxelib: haxelib distributions \\n\
	
## test will do all makefile "test" targets in all subdirectories
## These are assumed to be command-line tests which have a 
## success or fail return value
.PHONY: test
test: SUBTARGET=test 
test: EXTRAFLAGS=--silent --no-print-directory
test: $(ALLMK) 

## Test will do all makefile "doc" targets
.PHONY: doc
doc: SUBTARGET=doc
doc: EXTRAFLAGS=--silent --no-print-directory
doc: $(ALLDOC)

.PHONY: $(ALLMK)
$(ALLMK):
	@$(SUBMAKE) $(EXTRAFLAGS) -C ${dir $@} $(SUBTARGET)
	
swftest: swftestleft.html
swftestleft.html: create_swfindex.sh ${shell find . -name "*.swf"}
	./create_swfindex.sh

## subtarget can be used to build a specific target in a given makefile
## HDIR=directory containing makefile
## HTARGET=target in that file to execute
## This expects that make will be executed in the directory of this file
subtarget: 
	$(SUBMAKE) -C ${HDIR} ${HTARGET}

CLEAN=rm -f `find -name "*~"` && \
		rm -fr `find -name ".svn"` && \
		rm -fr restricted && \
		rm -f remove_license_from.sh
PNAME=dhlib
PDIR=../$(PNAME)
THISFILE=$(lastword $(MAKEFILE_LIST))
distrib-package:
	$(MAKE) -f $(THISFILE) all
	$(MAKE) -f $(THISFILE) swftest
	$(MAKE) -f $(THISFILE) doc
	rm -fr $(PDIR)
	cp -R . $(PDIR)
	cd $(PDIR) && mv -f makefile_flash makefile && $(CLEAN)
	tar czf ../$(PNAME).tgz $(PDIR)
	echo Package at ../$(PNAME).tgz

HXLIBNAME=hxlib
HXLIBDIR=../$(HXLIBNAME)
HXZIP=../$(HXLIBNAME).zip
distrib-haxelib:
	#I really only need to do the precomposition stage, don't need final SWFs, but may need libs, and extra HX files... hmmm
	$(MAKE) -f $(THISFILE) all
	rm -fr $(HXLIBDIR)
	cp -R lib/ $(HXLIBDIR)
	cd $(HXLIBDIR) && $(CLEAN)
	rm -fr $(HXZIP) && zip -qr $(HXZIP) $(HXLIBDIR)
	haxelib submit $(HXZIP)