-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
138 lines (118 loc) · 4.77 KB
/
Makefile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
PRJ:=$(shell (cat PACKAGES 2>/dev/null || echo "") | grep -v '^\#')
PRJ:=$(shell for p in $(PRJ) ; do ls -d $$p* | head -1 ; done)
LIQ:=$(shell ls -d liquidsoap* | head -1)
LIQDIR:=$(shell ls -d liquidsoap* | head -1)
SED:=$(shell which gsed || which sed)
PWD:=$(shell pwd)
SPACE := $(subst ,, )
OCAMLPATH=$(subst $(SPACE),:,$(PRJ:%=$(PWD)/%/_build/install/default/lib))
default: all
all:
@export OCAMLPATH="$(OCAMLPATH)"; \
for i in $(PRJ); do \
echo "Building $$i.."; \
if [ -f $$i/dune-project ]; then \
cd $$i && dune build @install && cd ..; \
export OCAMLPATH="`cd $$p && pwd`/_build/install/default/lib:$$OCAMLPATH"; \
else \
$(MAKE) -C $$i || exit 1; \
fi; \
done
clean:
@for i in $(PRJ); do \
echo "Cleaning up $$i.."; \
if [ -f $$i/dune-project ]; then \
cd $$i && dune $@ && cd ..; \
else \
$(MAKE) -C $$i $@ || exit 1; \
fi; \
done
doc:
$(MAKE) -C $(LIQ) doc
install:
$(MAKE) -C $(LIQ) install
# Display current version numbers of all components
versions:
@for i in ocaml-* liquidsoap ; do \
n=`echo $$i | sed -e 's#ocaml-##'` ; \
v=`cat $$i/$$n.opam | grep '^version' | cut -d'"' -f 2`; \
echo $$i-$$v ; \
done
PKGS:=$(shell grep '^\#\?\s*ocaml-[a-z0-9]\+$$' PACKAGES.default | $(SED) -e 's/\#//')
VERSION:=`cat liquidsoap/VERSION | head -n 1`
FULL:=liquidsoap-$(VERSION)-full
# $i = package name
# $v = version
# wget $(HTTP)/$$i/releases/download/$$v/$$i-$$v.tar.gz
HTTP=https://github.com/savonet
download_latest:
mkdir -p latest
@cd latest ; \
for i in $(PKGS) ; do \
n=`echo $$i | sed -e 's#ocaml-##'` ; \
v=`cat ../$$i/$$n.opam | grep '^version' | cut -d'"' -f 2`; \
if test ! -s $$i-$$v.tar.gz; then \
echo wget $(HTTP)/$$i/releases/download/$$v/$$i-$$v.tar.gz -O $$i-$$v.tar.gz --tries=2; \
wget $(HTTP)/$$i/releases/download/$$v/$$i-$$v.tar.gz -O $$i-$$v.tar.gz --tries=2 || rm -f $$i-$$v.tar.gz; \
fi \
done
full: bootstrap makefiles
@rm -rf $(FULL) ; mkdir $(FULL)
@cp bootstrap configure Makefile PACKAGES.default PACKAGES.minimal \
README.md LICENSE INSTALL $(FULL)
@echo Did you run \"make download_latest\" to get official tarballs?
@for i in $(PKGS) ; do \
n=`echo $$i | sed -e 's#ocaml-##'` ; \
v=`cat $$i/$$n.opam | grep '^version' | cut -d'"' -f 2`; \
if [ -f latest/$$i-$$v.tar.gz ] ; then \
cp latest/$$i-$$v.tar.gz $(FULL) ; else \
echo " *** Latest tarball not found for $$i-$$v: building it..." ; \
make -C $$i dist > /dev/null ; \
if [ -f $$i-$$v.tar.gz ] ; then \
mv $$i-$$v.tar.gz $(FULL) ; else \
mv $$i/$$i-$$v.tar.gz $(FULL) ; \
fi ; \
fi ; \
done
@if [ -f latest/liquidsoap-$(VERSION).tar.bz2 ] ; then \
cp latest/liquidsoap-$(VERSION).tar.bz2 $(FULL) ; else \
echo " *** Latest tarball not found for liquidsoap-$(VERSION): building..." ; \
make -C liquidsoap tarball > /dev/null && \
mv liquidsoap/liquidsoap-$(VERSION).tar.bz2 $(FULL) ; \
fi
@cd $(FULL) ; for a in *tar.gz ; do tar zxf $$a && rm $$a ; done ; \
tar jxf liquidsoap*tar.bz2 && rm liquidsoap*tar.bz2
@tar cjf $(FULL).tar.bz2 $(FULL)
@echo Full release ready in subdirectory $(FULL)
check-init:
@if [ ! -e $(LIQDIR)/configure.ac ] ; then \
echo "Liquidsoap directory seems empty. I assume that submodules were not downloaded. Hold on, I'm doing it for you!"; \
$(MAKE) init; \
fi
# The bootstrap target creates/updates */configure as needed
# It is more efficient than ./bootstrap, avoiding to regenerate
# everything when only one configure.ac was changed. However,
# it also bootstraps libraries which are commented out in PACKAGES.
# We use PKGDIRS and LIQDIRS which have -$(version) prefixes,
# so that the target will work in -full archives.
.PHONY: bootstrap check-init
PKGDIRS:=$(shell for p in $(PKGS) ; do ls -d $$p* | head -1 ; done)
CONFIGURES:=$(shell for p in $(PKGDIRS) liquidsoap; do if [ -f $$p/configure.ac ]; then echo $$p/configure; fi; done)
bootstrap: check-init $(CONFIGURES)
%/configure: %/configure.ac
@echo "*** bootstrapping `dirname $@`"
@cd `dirname $@` ; ./bootstrap
# Generate each PKG/Makefile by running configure script
# This may fail for some packages because specific configure options are
# needed, in which case they should simply be ran manually
makefiles: $(PKGDIRS:=/Makefile) $(LIQDIR)/Makefile.defs
%/Makefile:
@echo "*** configuring `dirname $@`"
@cd `dirname $@` ; ./configure --with-ogg-dir=../ocaml-ogg/src --with-ladspa-dir=../ocaml-ladspa/src > /dev/null || \
echo "Skipping failed configure..."
liquidsoap/Makefile.defs: liquidsoap/configure
@echo "*** configuring `dirname $@`"
@cd `dirname $@` ; `cat configure-with-options` > /dev/null || \
echo "Skipping failed configure..."
.PHONY: install
-include Makefile.git