Skip to content

Commit

Permalink
Merge pull request #1424 from OCamlPro/1.1-build-backport
Browse files Browse the repository at this point in the history
1.1 build backport
  • Loading branch information
AltGr committed Jun 6, 2014
2 parents 56cdfb5 + 28995d0 commit 02863c9
Show file tree
Hide file tree
Showing 32 changed files with 4,046 additions and 992 deletions.
35 changes: 26 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ src_ext/cudf/
src_ext/dose/
src_ext/cmdliner/
src_ext/extlib/
src_ext/ocaml-re/
src_ext/ocamlgraph/
src_ext/ocaml-arg/
src_ext/re/
src_ext/graph/
src_ext/*.stamp
src_ext/*.tbz
src/lexer.ml
src/linelexer.ml
src/parser.ml
src/parser.mli
src_ext/*.tar.gz
*.tar.bz2
*.annot
*.tar.gz
Expand All @@ -24,6 +20,15 @@ ocp-get
ocp-get-server
ocp-build.root.old.old
# Generated files:
*.cmo
*.cmx
*.cmi
*.cmt
*.cmti
*.cma
*.cmxa
*.a
*.o
META
Makefile.config
config.log
Expand All @@ -32,5 +37,17 @@ doc/man-ext/opam-check.md
src/core/opamGitVersion.ml
src/core/opamScript.ml
src/core/opamVersion.ml
src/globals.ml
src_ext/depends.ocp
src/core/opamLexer.ml
src/core/opamLineLexer.ml
src/core/opamParser.ml
src/core/opamParser.mli
src/opam
src/opam-admin
src/opam-installer
src/opam-check
src/opamlfind
._d
._ncdi
._bcdi
aclocal.m4
autom4te.cache
12 changes: 6 additions & 6 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ if [ "$OPAM_TEST" = "1" ]; then
sudo apt-get install opam aspcud
opam init
eval `opam config env`
opam install lwt cohttp ssl cmdliner ocamlgraph dose cudf re
opam install ocamlfind lwt cohttp ssl cmdliner ocamlgraph dose.3.1.2 cudf re
./configure
make prepare
make compile
make
# overwrite the previous install of OPAM with the new binary
# and libraries
sudo make install
make libinstall
# Compile and run opam-rt
wget https://github.com/ocaml/opam-rt/archive/master.tar.gz
tar xvfz master.tar.gz
cd opam-rt-master
wget https://github.com/ocaml/opam-rt/archive/1.1.tar.gz
tar xvfz 1.1.tar.gz
cd opam-rt-1.1
make
make KINDS="local git" run
else
# Compile OPAM from sources and run the basic tests
./configure
make lib-ext
make
make tests > tests.log 2>&1 || (tail -1000 tests.log && exit 1)
# Let's see basic tasks works
Expand Down
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.1.1-2
* Backport the new OCamlMakefile-based build system from 1.2

1.1.1
* Fix `opam-admin make <packages> -r` (#990)
* Explicitly prettyprint list of lists, to fix `opam-admin depexts` (#997)
Expand Down
270 changes: 78 additions & 192 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,211 +1,97 @@
-include Makefile.config

LOCAL_OCPBUILD=./ocp-build/ocp-build -no-use-ocamlfind
OCPBUILD ?= $(LOCAL_OCPBUILD)
SRC_EXT=src_ext
TARGETS = opam opam-admin opam-installer

.PHONY: all

all: $(LOCAL_OCPBUILD) META
$(MAKE) clone
$(MAKE) compile

cold:
./shell/bootstrap-ocaml.sh
env PATH=$$PATH:`pwd`/bootstrap/ocaml/bin ./configure
env PATH=$$PATH:`pwd`/bootstrap/ocaml/bin $(MAKE)

scan: $(LOCAL_OCPBUILD)
$(OCPBUILD) -scan
sanitize: $(LOCAL_OCPBUILD)
$(OCPBUILD)
byte: $(LOCAL_OCPBUILD)
$(OCPBUILD) -byte
opt: $(LOCAL_OCPBUILD)
$(OCPBUILD) -asm

OCAMLBUILD_FLAGS=\
-Is src/core,src/client,src/repositories,src/solver,src/scripts \
-use-ocamlfind -pkgs re.glob,re.pcre,re.str,re.perl,ocamlgraph,cmdliner,cudf,dose3 \
-classic-display
with-ocamlbuild: autogen
@for i in core repositories solver client; do\
echo Compiling opam-$$i;\
find src/$$i -type f \( -not -name opamMain.ml \) \
\( -name \*.ml -or -name \*.mly -or -name \*.mll \)\
| xargs -n 1 basename\
| awk -F. "{ print (toupper(substr(\$$1,0,1)) substr(\$$1,2)) }"\
> src/$$i/opam-$$i.mllib &&\
ocamlbuild $(OCAMLBUILD_FLAGS) opam-$$i.cma opam-$$i.cmxa;\
done;\
ocamlbuild $(OCAMLBUILD_FLAGS) opamMain.native opam_admin.native &&\
ln -sf _build/src/client/opamMain.native opam &&\
ln -sf _build/src/scripts/opam_admin.native opam-admin

$(LOCAL_OCPBUILD): ocp-build/ocp-build.boot ocp-build/win32_c.c
$(MAKE) -C ocp-build

OCAMLFIND_DIR=$(shell ocamlfind printconf destdir)
prepare: depends.ocp.in
sed "s|%{lib}%|$(OCAMLFIND_DIR)|g" depends.ocp.in > depends.ocp

autogen: src/core/opamGitVersion.ml src/core/opamScript.ml src/core/opamVersion.ml

compile: $(LOCAL_OCPBUILD) autogen
$(OCPBUILD) -init -scan $(TARGET)

clone: src/core/opamVersion.ml
$(MAKE) -C $(SRC_EXT)

clean:
rm -rf _obuild
rm -f *.annot src/*.annot
rm -f ocp-build.*
rm -rf _build
rm -rf config.log config.status META Makefile.config
$(MAKE) -C $(SRC_EXT) clean
$(MAKE) -C ocp-build clean
rm -f $(OPAM_FULL_TARGZ)

distclean: clean
$(MAKE) -C $(SRC_EXT) distclean
rm -f META Makefile.config config.log config.status
rm -f src/core/opamVersion.ml src/core/opamGitVersion.ml src/core/opamScript.ml

.PHONY: tests

tests:
$(MAKE) -C tests all
all: opam-lib opam opam-admin opam-installer
@

tests-local:
$(MAKE) -C tests local

tests-git:
$(MAKE) -C tests git

%-install:
@if [ -e _obuild/$*/$*.asm ]; then \
echo "install _obuild/$*/$*.asm" && \
cp _obuild/$*/$*.asm $(DESTDIR)$(prefix)/bin/$*; \
else \
echo "install _obuild/$*/$*.byte" && \
cp _obuild/$*/$*.byte $(DESTDIR)$(prefix)/bin/$*; \
fi

%-install-with-ocamlbuild:
@if [ -e $* ]; then\
echo "install $*" && cp $* $(DESTDIR)$(prefix)/bin/$*;\
fi

META: META.in
sed 's/@VERSION@/$(version)/g' < $< > $@

src/core/opamVersion.ml:
@echo
@echo " ERROR: you need to run ./configure."
@echo
@exit 1

.PHONY: src/core/opamGitVersion.ml
src/core/opamGitVersion.ml:
ocaml shell/get-git-id.ml $@

src/core/opamScript.ml: shell/ src/core/opamVersion.ml
ocaml shell/crunch.ml "complete" < shell/opam_completion.sh > $@
ocaml shell/crunch.ml "complete_zsh" < shell/opam_completion_zsh.sh >> $@
ocaml shell/crunch.ml "switch_eval" < shell/opam_switch_eval.sh >> $@

.PHONY: uninstall install install-with-ocamlbuild
install:
mkdir -p $(DESTDIR)$(prefix)/bin
$(MAKE) $(TARGETS:%=%-install)
mkdir -p $(DESTDIR)$(mandir)/man1 && cp doc/man/* $(DESTDIR)$(mandir)/man1
install-with-ocamlbuild:
mkdir -p $(DESTDIR)$(prefix)/bin
$(MAKE) $(TARGETS:%=%-install-with-ocamlbuild)
mkdir -p $(DESTDIR)$(mandir)/man1 && cp doc/man/* $(DESTDIR)$(mandir)/man1
uninstall:
rm -f $(prefix)/bin/opam*
rm -f $(mandir)/man1/opam*

CORE_LIB = opam-core
REPO_LIB = opam-repositories
SOLVER_LIB = opam-solver
CLIENT_LIB = opam-client

CORE_NOMLI = opamGlobals.ml opamParser.ml opamLexer.ml opamLineLexer.ml
CORE_MLI = $(foreach i, $(shell find src/core -name "*.mli"), $(notdir $i))
REPO_MLI = $(foreach i, $(shell find src/repositories -name "*.mli"), $(notdir $i))
SOLVER_MLI = $(foreach i, $(shell find src/solver -name "*.mli"), $(notdir $i))
CLIENT_MLI = $(foreach i, $(shell find src/client -name "*.mli"), $(notdir $i))

CORE_FILES = $(CORE_LIB:%=%.a) $(CORE_LIB:%=%.cma) $(CORE_LIB:%=%.cmxa)\
$(CORE_MLI:%.mli=%.cmi) $(CORE_NOMLI:%.ml=%.cmi)
REPO_FILES = $(REPO_LIB:%=%.a) $(REPO_LIB:%=%.cma) $(REPO_LIB:%=%.cmxa)\
$(REPO_MLI:%.mli=%.cmi)
SOLVER_FILES = $(SOLVER_LIB:%=%.a) $(SOLVER_LIB:%=%.cma) $(SOLVER_LIB:%=%.cmxa)\
$(SOLVER_MLI:%.mli=%.cmi)
CLIENT_FILES = $(CLIENT_LIB:%=%.a) $(CLIENT_LIB:%=%.cma) $(CLIENT_LIB:%=%.cmxa)\
$(CLIENT_MLI:%.mli=%.cmi)

FILES = $(CORE_FILES:%=_obuild/opam-core/%)\
$(REPO_FILES:%=_obuild/opam-repositories/%)\
$(SOLVER_FILES:%=_obuild/opam-solver/%)\
$(CLIENT_FILES:%=_obuild/opam-client/%)

OCAMLBUILD_FILES =\
$(CORE_FILES:%=_build/src/core/%)\
$(REPO_FILES:%=_build/src/repositories/%)\
$(SOLVER_FILES:%=_build/src/solver/%)\
$(CLIENT_FILES:%=_build/src/client/%)

.PHONY: libuninstall libinstall libinstall-with-ocamlbuild
libinstall: META
$(MAKE) libuninstall
ocamlfind install opam META $(FILES)
libinstall-with-ocamlbuild: META
$(MAKE) libuninstall
ocamlfind install opam META $(OCAMLBUILD_FILES)
libuninstall:
ocamlfind remove opam
#backwards-compat
compile with-ocamlbuild: all
@
install-with-ocamlbuild: install
@
libinstall-with-ocamlbuild: libinstall
@

doc: compile
$(MAKE) -C doc
byte:
$(MAKE) all USE_BYTE=true

src/%:
$(MAKE) -C src $*

%:
$(MAKE) -C src $@

OPAM_FULL = opam-full-$(version)
OPAM_FULL_TARGZ = $(OPAM_FULL).tar.gz
lib-ext:
$(MAKE) -C src_ext lib-ext

OPAM_FILES = $(wildcard src_ext/*.tar.gz)\
$(wildcard src_ext/*.tbz)\
$(shell git ls-tree --name-only -r HEAD)
download-ext:
$(MAKE) -C src_ext archives

prepare-archive:
clean-ext:
$(MAKE) -C src_ext distclean
$(MAKE) clone
rm -f $(OPAM_FULL) $(OPAM_FULL).tar.gz
ln -s . $(OPAM_FULL)

# we want OPAM_FILES to be up-to-date here
complete-archive:
tar cz $(addprefix $(OPAM_FULL)/,$(OPAM_FILES)) > $(OPAM_FULL).tar.gz
rm -f $(OPAM_FULL)
ifdef DESTDIR
LIBINSTALL_PREFIX ?= $(DESTDIR)
else
DESTDIR ?= $(prefix)
ifneq ($(OCAMLFIND),no)
LIBINSTALL_PREFIX = $(dir $(shell $(OCAMLFIND) printconf destdir))
else
LIBINSTALL_PREFIX ?= $(DESTDIR)
endif
endif

$(OPAM_FULL_TARGZ):
$(MAKE) prepare-archive
$(MAKE) complete-archive
# Workaround bug #1355 in opam-installer
OPAM_INSTALLER = OPAMROOT=/tmp/opam-install-$@ src/opam-installer

archive: $(OPAM_FULL_TARGZ)
@
upload: $(OPAM_FULL_TARGZ)
scp $(OPAM_FULL_TARGZ) webmaster@ocamlpro.com:pub/
libinstall:
$(if $(wildcard src_ext/lib/*),$(error Installing the opam libraries is incompatible with embedding the dependencies. Run 'make clean-ext' and try again))
$(OPAM_INSTALLER) --prefix $(LIBINSTALL_PREFIX) --name opam opam-lib.install

install:
$(OPAM_INSTALLER) --prefix $(DESTDIR) opam.install

libuninstall:
$(OPAM_INSTALLER) -u --prefix $(LIBINSTALL_PREFIX) --name opam opam-lib.install

uninstall:
$(OPAM_INSTALLER) -u --prefix $(DESTDIR) opam.install

.PHONY: tests tests-local tests-git
tests: opam opam-admin opam-check
$(MAKE) -C tests all

# tests-local, tests-git
tests-%: opam opam-admin opam-check
$(MAKE) -C tests $*

.PHONY: doc
doc: opam-lib
$(MAKE) -C doc

configure: configure.ac m4/*.m4
aclocal -I m4
autoconf

release:
release-tag:
git tag -d latest || true
git tag -a latest -m "Latest release"
git tag -a $(version) -m "Release $(version)"
$(MAKE) upload


$(OPAM_FULL).tar.gz:
$(MAKE) -C src_ext distclean
$(MAKE) -C src_ext downloads
rm -f $(OPAM_FULL) $(OPAM_FULL).tar.gz
ln -s .

fast: src/core/opamGitVersion.ml src/core/opamScript.ml
@if [ -n "$(wildcard src/*/*.cmi)" ]; then $(MAKE) clean; fi
@ocp-build -init -scan
@ln -sf ../_obuild/opam/opam.asm src/opam
@ln -sf ../_obuild/opam-admin/opam-admin.asm src/opam-admin
@ln -sf ../_obuild/opam-installer/opam-installer.asm src/opam-installer
@ln -sf ../_obuild/opam-check/opam-check.asm src/opam-check

fastclean:
@ocp-build -clean
@rm -f $(addprefix src/, opam opam-admin opam-installer opam-check)

0 comments on commit 02863c9

Please sign in to comment.