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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
|
#!/usr/bin/make -f
include /usr/share/quilt/quilt.make
PACKAGE := ocaml
ALL_PACKAGES := $(shell sed -ne 's/^Package: //p' debian/control)
OCAMLMAJOR := 3.11
OCAMLMINOR := 2
# Build cache (for Debian debugging)
BUILDCACHE := $(wildcard ../ocaml.cache)
# These are defined here to avoid definition of them in ocamlvars.mk
OCAML_ABI := $(OCAMLMAJOR).$(OCAMLMINOR)
OCAML_STDLIB_DIR := /usr/lib/ocaml
OCAML_NATIVE_ARCHS := $(shell cat debian/native-archs)
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
OCAML_OPT_ARCH := $(findstring $(DEB_BUILD_ARCH),$(OCAML_NATIVE_ARCHS))
OCAML_HAVE_OCAMLOPT := $(if $(OCAML_OPT_ARCH),yes,no)
OCAML_OCAMLDOC_DESTDIR_HTML =
# dh_ocamlinit cannot be used for ocaml itself
include debian/ocamlinit.mk
MD5SUMSDIR = /var/lib/ocaml/md5sums
INSTDIR = $(CURDIR)/debian/tmp/usr
DISTDIR = $(PACKAGE)-$(OCAML_ABI)
SRCTARBALL = $(PACKAGE)-source-$(OCAML_ABI).tar.bz2
# Environment variable for dh_ocaml
OCAMLBYTEINFO = boot/ocamlrun debian/ocamlbyteinfo/ocamlbyteinfo
OCAMLPLUGININFO = debian/ocamlbyteinfo/ocamlplugininfo
OCAMLDUMPAPPROX = boot/ocamlrun tools/dumpapprox
OCAMLOBJINFO = boot/ocamlrun tools/objinfo
export OCAMLBYTEINFO
export OCAMLPLUGININFO
export OCAMLDUMPAPPROX
export OCAMLOBJINFO
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DH_OPTIONS
ifeq ($(OCAML_OPT_ARCH),)
DH_OPTIONS += -Nocaml-native-compilers
endif
# This has to be exported to make gen_modules work
export OCAML_OPT_ARCH
export OCAML_STDLIB_DIR
CONFIGURE_OPTS := \
--with-pthread -prefix /usr \
-libdir $(OCAML_STDLIB_DIR) \
-mandir /usr/share/man \
-tkdefs "-I/usr/include/tcl8.5" \
-tklibs "-L/usr/lib -ltk8.5 -ltcl8.5"
CONFIGURE_SED := \
-e "s%MANDIR=.*$$%MANDIR=\$$(PREFIX)/share/man%g" \
-e "s%LIBDIR=.*$$%LIBDIR=\$$(PREFIX)/lib/ocaml%g" \
-e "s%STUBLIBDIR=.*$$%STUBLIBDIR=\$$(PREFIX)/lib/ocaml/stublibs%g"
$(QUILT_STAMPFN): debian/$(SRCTARBALL)
ocamlinit-stamp: debian/$(SRCTARBALL)
# Generate ocaml-native-compilers' Architecture field.
# Should never be called automatically.
.PHONY: debian/control
debian/control:
sed -e 's/@OCamlNativeArchs@/$(OCAML_NATIVE_ARCHS)/g' debian/control.in > $@
pre-config-stamp: debian/$(SRCTARBALL)
chmod +x debian/gen_modules.pl
# Backup upstream config.{sub,guess}, and use most up-to-date ones
for ext in sub guess; do \
if [ -f /usr/share/misc/config.$$ext ] && \
! [ -f debian/config.orig.$$ext ]; then \
mv config/gnu/config.$$ext debian/config.orig.$$ext; \
cp -f /usr/share/misc/config.$$ext config/gnu/config.$$ext; \
fi; \
done
touch $@
debian/$(SRCTARBALL):
ln -fs . $(DISTDIR) # beware of the symlink recursion!
tar --anchored -chjf $@ \
--exclude=$(DISTDIR)/$(DISTDIR) \
--exclude-from=debian/ocaml-source.exclude \
$(DISTDIR)/
rm -f $(DISTDIR)
config-stamp: pre-config-stamp $(QUILT_STAMPFN) ocamlinit-stamp
dh build --before dh_auto_configure
./configure $(CONFIGURE_OPTS)
sed -i $(CONFIGURE_SED) config/Makefile
if test -z "`grep "OTHERLIBRARIES.*labltk" config/Makefile`"; then \
echo "Error, labltk library was not detected"; \
echo "Check your tcl/tk development packages"; \
echo "Aborting."; \
exit 1; \
fi
touch $@
$(QUILT_STAMPFN): ocamlinit-stamp
build: build-stamp
build-stamp: config-stamp
if test ! -d boot.debian; then \
cp -xa boot boot.debian; \
fi
rm -Rf debian/examples && mkdir debian/examples
cp -a otherlibs/labltk/examples_labltk debian/examples/labltk
find debian/examples/labltk -name .cvsignore -delete
ifeq ($(BUILDCACHE),)
$(MAKE) world
$(MAKE) bootstrap
$(MAKE) -C tools objinfo dumpobj
ifeq (,$(OCAML_OPT_ARCH))
# As of 3.11.0, manpages are made only in `make opt.opt'
make -C ocamldoc manpages \
OCAMLDOC_RUN="../boot/ocamlrun -I ../otherlibs/unix -I ../otherlibs/str ./ocamldoc"
$(MAKE) -f debian/ocamlbyteinfo/Makefile ocamlbyteinfo
else
@echo "Building native compilers"
$(MAKE) opt opt.opt
$(MAKE) -C tools dumpapprox
$(MAKE) -f debian/ocamlbyteinfo/Makefile
touch opt-built-stamp
endif
else
@echo "===> WARNING: $(BUILDCACHE) detected, compilation skipped! <==="
rsync -a --exclude=debian --exclude=.git $(BUILDCACHE)/ .
rsync -a $(BUILDCACHE)/debian/ocamlbyteinfo/ debian/ocamlbyteinfo/
rm -f build-stamp install-stamp
endif
dh build --after dh_auto_test
touch $@
clean: unpatch ocamlinit-clean
dh clean --before dh_auto_clean
ifneq ($(wildcard $(CURDIR)/config/Makefile),)
$(MAKE) clean
$(MAKE) -C emacs clean
endif
# Restore files altered by the build process
if test -d boot.debian; then \
rm -Rf boot; \
mv boot.debian boot; \
fi
for ext in sub guess; do \
if [ -f debian/config.orig.$$ext ] ; then \
mv -f debian/config.orig.$$ext config/gnu/config.$$ext; \
fi; \
done
if head -n 1 emacs/ocamltags.in | grep -q '^#!/bin/sh'; then \
sed -i 1d emacs/ocamltags.in; \
fi
# Remaining stuff
-rm -Rf debian/$(SRCTARBALL) debian/examples
$(MAKE) -f debian/ocamlbyteinfo/Makefile clean
dh clean --after dh_auto_clean
install: install-stamp
install-stamp:
dh install --before dh_auto_install
# Install Emacs files
$(MAKE) -C emacs \
EMACSDIR=$(CURDIR)/debian/ocaml-mode/usr/share/emacs/site-lisp/ocaml-mode \
NOCOMPILE=true simple-install
if ! head -n 1 emacs/ocamltags.in | grep -q '^#!/bin/sh'; then \
sed -i -e '1 i #!/bin/sh' emacs/ocamltags.in; \
fi
$(MAKE) -C emacs SCRIPTDIR=$(CURDIR)/debian/ocaml-mode/usr/bin install-ocamltags
# Install OCaml
sed -e 's|PREFIX=\"/.*\"|PREFIX=\"$(INSTDIR)"|' < config/config.sh > config/config.debian.install.sh
$(MAKE) install PREFIX=$(INSTDIR)
# To avoid erroneous dh_install warnings
rm -f $(INSTDIR)/share/man/man1/ocamlopt.opt.1 $(INSTDIR)/share/man/man1/ocamlc.opt.1
# Dispatch files with dh_install
cd debian && \
for u in ocaml ocaml-nox; do \
DESTDIR=tmp ./gen_modules.pl $$u.install > $$u.install.new; \
mv $$u.install.new $$u.install; \
done
if ! dh_install --list-missing; then \
echo "===> dh_install has failed <==="; \
find debian/tmp; \
exit 1; \
fi
# Install additional files not handled by dh_install
# Beware: dh_install does not handle renamings, please pay attention
cp otherlibs/labltk/README debian/ocaml/usr/share/doc/ocaml/README.labltk
for u in dumpobj objinfo dumpapprox; do \
if [ -f tools/$$u ]; then \
cp tools/$$u debian/ocaml-nox/usr/bin/ocaml$$u; \
fi \
done
for u in ocamlbyteinfo ocamlplugininfo; do \
if [ -f debian/ocamlbyteinfo/$$u ]; then \
cp debian/ocamlbyteinfo/$$u debian/ocaml-nox/usr/bin/$$u; \
fi \
done
for mli in `find camlp4 -name '*.mli'` ; do \
cp --parents $$mli debian/camlp4$(OCAML_STDLIB_DIR); \
done
for pkg in ocaml ocaml-nox ocaml-base; do ( \
cd debian/$$pkg/usr/share/doc/$$pkg && \
ln -sf ../ocaml-base-nox/Changes.gz . && \
ln -sf ../ocaml-base-nox/README.gz . && \
ln -sf ../ocaml-base-nox/README.Debian .; \
); done
# Remove empty directory
rmdir $(CURDIR)/debian/ocaml-nox$(OCAML_STDLIB_DIR)/ocamldoc/custom
# Remaining stuff
dh install --after dh_install --before dh_compress
dh_compress -Xexamples/labltk
dh install --after dh_compress
touch $@
binary-stamp: install-stamp
dh binary --before dh_gencontrol
for u in $(ALL_PACKAGES); do \
echo 'F:OCamlABI=$(OCAML_ABI)' >> debian/$$u.substvars; \
done
ifeq (,$(OCAML_OPT_ARCH))
echo 'F:BestProvides=ocaml-best-compilers' >> debian/ocaml-nox.substvars
else
echo 'F:BestProvides=' >> debian/ocaml-nox.substvars
endif
# Create .md5sums files and compute dependencies. Use
# $(OCAML_ABI) because we know that OCaml ABI represents
# best dependencies for OCaml package.
dh_ocaml -Xcompiler-libs -Xcamlp4-extra \
--runtime-map ocaml-nox:ocaml-base-nox,ocaml:ocaml-base,camlp4 \
--checksum $(OCAML_ABI)
dh_gencontrol
# Check that OCAML_ABI is correct
if [ "$(OCAML_ABI)" != "$(shell boot/ocamlrun ocamlc -version)" ]; then \
echo "Please adjust OCAML_ABI in debian/rules"; \
exit 2; \
fi
dh binary --after dh_gencontrol
touch $@
binary: binary-arch binary-indep
binary-arch: binary-stamp
binary-indep: binary-stamp
.PHONY: build clean binary-indep binary-arch binary install build ocamlinit
.PHONY: redo-patches
redo-patches:
rm -f debian/patches/*
git format-patch -N -o debian/patches upstream...patch-queue | \
sed -e 's%debian/patches/%%' > debian/patches/series
sed -i -e 1d debian/patches/*.patch
|