| 1 |
# When building with 0compile, these will get overridden. |
| 2 |
SRCDIR = $(abspath .) |
| 3 |
DISTDIR = $(abspath dist) |
| 4 |
|
| 5 |
# Using PROFILE=dev makes warnings fatal and makes the build faster by doing fewer optimisations |
| 6 |
PROFILE ?= release |
| 7 |
|
| 8 |
# Only build the 0install-gtk GUI package if lablgtk3 is available. |
| 9 |
PACKAGES = 0install,0install-solver$(shell ocamlfind query -format ,0install-gtk lablgtk3 2> /dev/null) |
| 10 |
|
| 11 |
# There are several things you might want to do: |
| 12 |
# |
| 13 |
# 1. a traditional install (e.g. under /usr/local or ~) |
| 14 |
# 2. build a library for other 0install tools (e.g. 0compile) |
| 15 |
# 3. for testing, in place (during development) |
| 16 |
# |
| 17 |
# New users and distribution packagers will want to do (1). |
| 18 |
# |
| 19 |
# When you do a plain "make", $DISTDIR ends up with a complete distribution |
| 20 |
# suitable for publishing or registering with 0install. $DISTDIR contains: |
| 21 |
# |
| 22 |
# - The compiled binaries |
| 23 |
# - A 0install binary feed, which can be registered with "0install add" |
| 24 |
# |
| 25 |
# To install as a normal package: make && sudo make install |
| 26 |
# To test without installing: make && ./dist/bin/0install |
| 27 |
# To use as a library with other tools: 0compile build && 0compile register |
| 28 |
# To publish a release on 0install.net: use 0release |
| 29 |
|
| 30 |
default: all test |
| 31 |
|
| 32 |
%.html: %.md |
| 33 |
redcarpet $< > $@ || (rm -f $@; false) |
| 34 |
|
| 35 |
clean: |
| 36 |
dune clean --root=. --profile=${PROFILE} |
| 37 |
rm -rf build dist static/dist.tgz |
| 38 |
|
| 39 |
DOCS = README.md COPYING |
| 40 |
MANPAGES = 0launch.1 0store-secure-add.1 0store.1 0desktop.1 0install.1 |
| 41 |
|
| 42 |
OS = $(shell uname -s) |
| 43 |
MACHINE = $(shell uname -m) |
| 44 |
VERSION = $(shell sed -n 's/let version = "\(.*\)"/\1/p' ${SRCDIR}/src/zeroinstall/about.ml) |
| 45 |
|
| 46 |
all: |
| 47 |
dune build --root=. --profile=${PROFILE} --only-packages=${PACKAGES} @install |
| 48 |
install -d "${DISTDIR}" |
| 49 |
install -d "${DISTDIR}/files" |
| 50 |
install -d "${DISTDIR}/files/gui_gtk" |
| 51 |
install -d "${DISTDIR}/files/share" |
| 52 |
(cd "${SRCDIR}" && cp ${DOCS} "${DISTDIR}/") |
| 53 |
-install _build/install/default/lib/0install-gtk/gui_gtk.cma "${DISTDIR}/files/gui_gtk/" |
| 54 |
-install _build/install/default/lib/0install-gtk/gui_gtk.cmxs "${DISTDIR}/files/gui_gtk/" |
| 55 |
install _build/install/default/bin/0install "${DISTDIR}/files/0install" |
| 56 |
ln -f "${DISTDIR}/files/0install" "${DISTDIR}/files/0launch" |
| 57 |
ln -f "${DISTDIR}/files/0install" "${DISTDIR}/files/0store" |
| 58 |
ln -f "${DISTDIR}/files/0install" "${DISTDIR}/files/0store-secure-add" |
| 59 |
ln -f "${DISTDIR}/files/0install" "${DISTDIR}/files/0desktop" |
| 60 |
ln -f "${DISTDIR}/files/0install" "${DISTDIR}/files/0alias" |
| 61 |
(cd "${SRCDIR}/src" && cp ${MANPAGES} "${DISTDIR}/files") |
| 62 |
install "${SRCDIR}/install.sh.src" "${DISTDIR}/install.sh" |
| 63 |
(cd "${SRCDIR}" && cp -r share/0install.net share/applications share/metainfo share/bash-completion share/fish share/icons share/zsh "${DISTDIR}/files/share/") |
| 64 |
install -d "${DISTDIR}/0install" |
| 65 |
[ -f "${DISTDIR}/0install/build-environment.xml" ] || sed 's/@ARCH@/${OS}-${MACHINE}/;s/@VERSION@/${VERSION}/' "${SRCDIR}/binary-feed.xml.in" > "${DISTDIR}/0install/feed.xml" |
| 66 |
|
| 67 |
test: |
| 68 |
dune runtest --root=. --profile=${PROFILE} --only-packages=${PACKAGES} |
| 69 |
|
| 70 |
doc: |
| 71 |
dune build --root=. --profile=${PROFILE} --only-packages=${PACKAGES} @doc |
| 72 |
|
| 73 |
install: install_local |
| 74 |
|
| 75 |
install_home: |
| 76 |
(cd "${DISTDIR}" && ./install.sh home) |
| 77 |
|
| 78 |
install_system: |
| 79 |
(cd "${DISTDIR}" && ./install.sh system) |
| 80 |
|
| 81 |
install_local: |
| 82 |
(cd "${DISTDIR}" && ./install.sh local) |
| 83 |
|
| 84 |
.PHONY: all install test |
| 85 |
|
| 86 |
.PHONY: clean default |
| 87 |
|
| 88 |
.PHONY: static-test |
| 89 |
|
| 90 |
static/dist.tgz: static/Dockerfile |
| 91 |
docker build -t talex5/0install-static-build -f static/Dockerfile . |
| 92 |
docker run talex5/0install-static-build tar czf - dist > static/dist.tgz |
| 93 |
|
| 94 |
static-test-%: static/Dockerfile-test-% static/dist.tgz |
| 95 |
docker build -f $< ./static -t 0install-test |
| 96 |
docker run --rm -it -v "${SRCDIR}/static:/mnt:ro" 0install-test /mnt/run-tests.sh |
| 97 |
|
| 98 |
static-test: static-test-debian-11 static-test-fedora-36 |