Skip to content

Commit

Permalink
Rely on ocamlmklib to build libraries when possible; build system cle…
Browse files Browse the repository at this point in the history
…anup

- mlapronidl/META is now automatically generated based on PPL's
  availability

- New file vars.mk gathers common variable definitions for the build
  system

- Fix some typos in configure script, and avoid integrating
  non-existent directories in include paths

- New, upgraded, ocamlpack script

- Parallel builds should now be possible in subdirectories (make -j)
  • Loading branch information
nberth committed Aug 20, 2015
1 parent 322bf5d commit b95d0cd
Show file tree
Hide file tree
Showing 24 changed files with 614 additions and 789 deletions.
55 changes: 31 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
include Makefile.config

LCFLAGS = \
-Lapron -Litv -Lbox -Loctagons -Lnewpolka -Ltaylor1plus \
-L$(PPL_PREFIX)/lib -Lppl \
-Lproducts \
-L$(GMP_PREFIX)/lib -L$(MPFR_PREFIX)/lib \
-L$(CAMLIDL_PREFIX)
SRCROOT = .
include vars.mk
PKGNAME = apron
VERSION_STR = 20150729

all: c
ifneq ($(HAS_OCAML),)
Expand Down Expand Up @@ -48,14 +45,12 @@ ifneq ($(HAS_PPL),)
(cd products; $(MAKE) ml)
endif

.PHONY: aprontop apronppltop

aprontop:
$(OCAMLMKTOP) -I $(MLGMPIDL_PREFIX)/lib -I $(APRON_PREFIX)/lib -verbose -o $@ \
$(OCAMLMKTOP) -I $(MLGMPIDL_LIB) -I $(APRON_LIB) -verbose -o $@ \
bigarray.cma gmp.cma apron.cma boxMPQ.cma octMPQ.cma polkaMPQ.cma t1pMPQ.cma

apronppltop:
$(OCAMLMKTOP) -I $(MLGMPIDL_PREFIX)/lib -I $(APRON_PREFIX)/lib -verbose -o $@ \
$(OCAMLMKTOP) -I $(MLGMPIDL_LIB) -I $(APRON_LIB) -verbose -o $@ \
bigarray.cma gmp.cma apron.cma boxMPQ.cma octMPQ.cma polkaMPQ.cma ppl.cma polkaGrid.cma t1pMPQ.cmxa

rebuild:
Expand Down Expand Up @@ -110,7 +105,7 @@ OCAMLFIND_FILES += \
endif
endif

install:
install: all
(cd num; $(MAKE) install)
(cd itv; $(MAKE) install)
(cd apron; $(MAKE) install)
Expand All @@ -125,24 +120,32 @@ endif
ifneq ($(HAS_OCAML),)
ifeq ($(OCAMLFIND),)
(cd mlapronidl; $(MAKE) install)
$(INSTALLd) $(APRON_PREFIX)/bin
if test -f aprontop; then $(INSTALL) aprontop $(APRON_PREFIX)/bin; fi
$(INSTALLd) $(APRON_BIN)
if test -f aprontop; then $(INSTALL) aprontop $(APRON_BIN); fi
ifneq ($(HAS_PPL),)
if test -f apronppltop; then $(INSTALL) apronppltop $(APRON_PREFIX)/bin; fi
if test -f apronppltop; then $(INSTALL) apronppltop $(APRON_BIN); fi
endif
else
$(OCAMLFIND) remove apron
$(OCAMLFIND) install apron mlapronidl/META $(OCAMLFIND_FILES) \
mlapronidl/apron.d.cmxa mlapronidl/apron.d.a \
newpolka/polkaMPQ.d.cmxa newpolka/polkaMPQ.d.a \
newpolka/polkaRll.d.cmxa newpolka/polkaRll.d.a

endif
endif
ifneq ($(HAS_CPP),)
(cd apronxx; $(MAKE) install)
endif

ifneq ($(OCAMLFIND),)
install: mlapronidl/META
mlapronidl/META: mlapronidl/META.in mlapronidl/META.ppl.in
$(SED) -e "s!@VERSION@!$(VERSION_STR)!g;" $< > $@;
ifneq ($(HAS_PPL),)
cat mlapronidl/META.ppl.in >> $@;
endif
endif

clean:
(cd num; $(MAKE) clean)
(cd itv; $(MAKE) clean)
Expand All @@ -159,8 +162,10 @@ clean:
(cd test; $(MAKE) clean)
(cd japron; $(MAKE) clean)
rm -fr online tmp apron*run aprontop apronppltop
rm -f mlapronidl/META

distclean: clean
rm -f Makefile.config

uninstall:
(cd num; $(MAKE) uninstall)
Expand All @@ -175,7 +180,7 @@ uninstall:
(cd ppl; $(MAKE) uninstall)
(cd products; $(MAKE) uninstall)
(cd apronxx; $(MAKE) uninstall)
(cd $(APRON_PREFIX)/bin; rm -f apron*)
(cd $(APRON_BIN); rm -f apron*)
ifneq ($(OCAMLFIND),)
$(OCAMLFIND) remove apron
endif
Expand All @@ -191,18 +196,18 @@ endif

# make distribution, update to reflect current version

PKGNAME = apron-0.9.11
PKGFILES = Makefile README README.windows README.mac AUTHORS COPYING Makefile.config.model Changes configure
PKG = $(PKGNAME)-$(VERSION_STR)
PKGFILES = Makefile README README.windows README.mac AUTHORS COPYING Makefile.config.model Changes configure vars.mk
PKGDIRS = apron num itv octagons box newpolka taylor1plus ppl products mlapronidl examples test apronxx japron

dist:
$(MAKE) all
$(MAKE) doc
mkdir -p $(PKGNAME)
mkdir -p $(PKG)
$(MAKE) $(foreach pkg,$(PKGDIRS),pkg_$(pkg))
cp $(PKGFILES) $(PKGNAME)
tar vczf $(PKGNAME).tgz $(PKGNAME)
rm -rf $(PKGNAME)
cp $(PKGFILES) $(PKG)
tar vczf $(PKG).tgz $(PKG)
rm -rf $(PKG)

# these 2 targets are for main developpers only
index.html: index.tex
Expand All @@ -221,5 +226,7 @@ online: doc index.html

pkg_%:
(cd $*; $(MAKE) dist)
(cd $(PKGNAME); tar xzf ../$*.tgz)
(cd $(PKG); tar xzf ../$*.tgz)
rm -rf $*.tgz

.NOTPARALLEL:
2 changes: 2 additions & 0 deletions Makefile.config.model
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,5 @@ DVIPDF=dvipdf
MAKEINDEX=makeindex
TEXI2DVI=texi2dvi
TEXI2HTML=texi2html

OCAMLPACK = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ocamlpack
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CONFIGURATION and COMPILATION

1. Copy Makefile.config.model into Makefile.config and edit the
_PREFIX paths to suit your installation (you might want to set
APRON_PREFIX, MLGMPIDL_PREFIX, CAMLIDL_PREFIX and CAML_PREFIX
APRON_PREFIX, MLGMPIDL_PREFIX, CAMLIDL_DIR and CAML_DIR
to some of your directory instead of the default /tmp).

2. 'make'
Expand Down
131 changes: 53 additions & 78 deletions apron/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
include ../Makefile.config

#---------------------------------------
# Directories
#---------------------------------------

SRCDIR = $(shell pwd)
#
PREFIX = $(APRON_PREFIX)
#
# C include and lib directories
INCDIR = $(PREFIX)/include
LIBDIR = $(PREFIX)/lib
BINDIR = $(PREFIX)/bin
#
include ../vars.mk

#---------------------------------------
# C part
#---------------------------------------
ICFLAGS = -I../num -I$(GMP_PREFIX)/include -I$(MPFR_PREFIX)/include

ICFLAGS = $(NUM_ICFLAGS) $(ITV_ICFLAGS) $(MP_ICFLAGS)
OCAMLINC = -I $(MLGMPIDL)

#---------------------------------------
# Files
Expand Down Expand Up @@ -55,17 +44,19 @@ C_FILES_AUX = ap_linearize_aux.c
H_FILES_AUX = ap_linearize_aux.h
CH_FILES_AUX = $(H_FILES_AUX) $(C_FILES_AUX)

LIBS = -lm -L$(GMP_PREFIX)/lib -lgmp -L$(MPFR_PREFIX)/lib -lmpfr
LDFLAGS += $(MP_LIFLAGS) -lm -lgmp -lmpfr

#---------------------------------------
# Rules
#---------------------------------------

all: libapron.a libapron_debug.a
LIB_FILES = libapron.a libapron_debug.a
ifneq ($(HAS_SHARED),)
all: libapron.so libapron_debug.so
LIB_FILES += libapron.so libapron_debug.so
endif

all: $(LIB_FILES)

#---------------------------------------
# Misc rules
#---------------------------------------
Expand All @@ -85,17 +76,17 @@ clean:
distclean: clean

install: all
mkdir -p $(APRON_PREFIX)/include
cp $(H_FILES) $(APRON_PREFIX)/include
mkdir -p $(APRON_PREFIX)/lib
for i in libapron.a libapron_debug.a libapron.so libapron_debug.so; do if test -f $$i; then $(INSTALL) $$i $(APRON_PREFIX)/lib; fi; done
mkdir -p $(APRON_INCLUDE)
cp $(H_FILES) $(APRON_INCLUDE)
mkdir -p $(APRON_LIB)
for i in $(LIB_FILES); do if test -f $$i; then $(INSTALL) $$i $(APRON_LIB); fi; done

uninstall:
/bin/rm -f $(H_FILES:%=$(APRON_PREFIX)/include/%)
/bin/rm -f $(APRON_PREFIX)/lib/libapron.a
/bin/rm -f $(APRON_PREFIX)/lib/libapron_debug.a
/bin/rm -f $(APRON_PREFIX)/lib/libapron.so
/bin/rm -f $(APRON_PREFIX)/lib/libapron_debug.so
/bin/rm -f $(H_FILES:%=$(APRON_INCLUDE)/%)
/bin/rm -f $(APRON_LIB)/libapron.a
/bin/rm -f $(APRON_LIB)/libapron_debug.a
/bin/rm -f $(APRON_LIB)/libapron.so
/bin/rm -f $(APRON_LIB)/libapron_debug.so

#---------------------------------------
# Latex rules
Expand Down Expand Up @@ -127,59 +118,43 @@ html: apron.texi rationale.texi ap_pkgrid.texi ap_ppl.texi newpolka.texi box.tex
# C rules
#---------------------------------------

libapron.a: $(C_FILES:%.c=%.o) \
O_FILES = \
$(C_FILES:%.c=%.o) \
$(C_FILES_AUX:%.c=%MPQ.o) \
$(C_FILES_AUX:%.c=%D.o) \
$(C_FILES_AUX:%.c=%MPFR.o) \
../itv/libitv.a
cp ../itv/libitv.a $@
$(AR) rs $@ $(C_FILES:%.c=%.o) \
$(C_FILES_AUX:%.c=%MPQ.o) \
$(C_FILES_AUX:%.c=%D.o) \
$(C_FILES_AUX:%.c=%MPFR.o)
$(RANLIB) $@
$(C_FILES_AUX:%.c=%MPFR.o)

libapron_debug.a: $(C_FILES:%.c=%_debug.o) \
O_FILES_DEBUG = \
$(C_FILES:%.c=%_debug.o) \
$(C_FILES_AUX:%.c=%MPQ_debug.o) \
$(C_FILES_AUX:%.c=%D_debug.o) \
$(C_FILES_AUX:%.c=%MPFR_debug.o) \
../itv/libitv_debug.a
$(C_FILES_AUX:%.c=%MPFR_debug.o)

libapron.a: $(O_FILES) ../itv/libitv.a
cp ../itv/libitv.a $@
$(AR) rs $@ $(O_FILES)
$(RANLIB) $@

libapron_debug.a: $(O_FILES_DEBUG) ../itv/libitv_debug.a
cp ../itv/libitv_debug.a $@
$(AR) rs $@ $(C_FILES:%.c=%_debug.o) \
$(C_FILES_AUX:%.c=%MPQ_debug.o) \
$(C_FILES_AUX:%.c=%D_debug.o) \
$(C_FILES_AUX:%.c=%MPFR_debug.o)
$(AR) rs $@ $(O_FILES_DEBUG)
$(RANLIB) $@

libapron.so: $(C_FILES:%.c=%.o) \
$(C_FILES_AUX:%.c=%MPQ.o) \
$(C_FILES_AUX:%.c=%D.o) \
$(C_FILES_AUX:%.c=%MPFR.o) \
../itv/libitv.a
$(CC) $(CFLAGS) -shared -o $@ $(C_FILES:%.c=%.o) \
$(C_FILES_AUX:%.c=%MPQ.o) \
$(C_FILES_AUX:%.c=%D.o) \
$(C_FILES_AUX:%.c=%MPFR.o) \
$(patsubst %,../itv/%,$(filter %.o, $(shell $(AR) t ../itv/libitv.a))) \
$(LIBS)

libapron_debug.so: $(C_FILES:%.c=%_debug.o) \
$(C_FILES_AUX:%.c=%MPQ_debug.o) \
$(C_FILES_AUX:%.c=%D_debug.o) \
$(C_FILES_AUX:%.c=%MPFR_debug.o) \
../itv/libitv_debug.a
$(CC) $(CFLAGS_DEBUG) -shared -o $@ $(C_FILES:%.c=%_debug.o) \
$(C_FILES_AUX:%.c=%MPQ_debug.o) \
$(C_FILES_AUX:%.c=%D_debug.o) \
$(C_FILES_AUX:%.c=%MPFR_debug.o) \
$(patsubst %,../itv/%,$(filter %.o, $(shell $(AR) t ../itv/libitv_debug.a))) \
$(LIBS)
libapron.so: $(O_FILES) ../itv/libitv.a
$(CC) $(CFLAGS) -shared -o $@ $(O_FILES) $(patsubst \
%,../itv/%,$(filter %.o, $(shell $(AR) t \
../itv/libitv.a))) $(LDFLAGS)

libapron_debug.so: $(O_FILES_DEBUG) ../itv/libitv_debug.a
$(CC) $(CFLAGS_DEBUG) -shared -o $@ $(O_FILES_DEBUG) \
$(patsubst %,../itv/%,$(filter %.o, $(shell $(AR) t \
../itv/libitv_debug.a))) $(LDFLAGS)

.PHONY : dep

dep: $(H_FILES)
for i in $(C_FILES); do \
cpp $(ICFLAGS) -I../itv -MM $$i; \
cpp $(ICFLAGS) -MM $$i; \
done

#--------------------------------------------------------------
Expand All @@ -193,35 +168,35 @@ dep: $(H_FILES)
#---------------------------------------

%.o: %.c %.h
$(CC) $(CFLAGS) $(ICFLAGS) -I../itv -c $<
$(CC) $(CFLAGS) $(ICFLAGS) -c $<

%MPQ.o: %.c %.h
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_MPQ -I../num -I../itv -I. -c $< -o $@
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_MPQ -I. -c $< -o $@
%D.o: %.c %.h
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_DOUBLE -I../num -I../itv -I. -c $< -o $@
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_DOUBLE -I. -c $< -o $@
%Dl.o: %.c %.h
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_LONGDOUBLE -I../num -I../itv -I. -c $< -o $@
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_LONGDOUBLE -I. -c $< -o $@
%MPFR.o: %.c %.h
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_MPFR -I../num -I../itv -I. -c $< -o $@
$(CC) $(CFLAGS) $(ICFLAGS) -DNUM_MPFR -I. -c $< -o $@

%_debug.o: %.c %.h
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -I../itv -c -o $@ $<
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -c -o $@ $<

%MPQ_debug.o: %.c %.h
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_MPQ -I../num -I../itv -I. -c -o $@ $< -o $@
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_MPQ -I. -c -o $@ $< -o $@
%D_debug.o: %.c %.h
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_DOUBLE -I../num -I../itv -I. -c -o $@ $< -o $@
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_DOUBLE -I. -c -o $@ $< -o $@
%Dl_debug.o: %.c %.h
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_LONGDOUBLE -I../num -I../itv -I. -c -o $@ $< -o $@
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_LONGDOUBLE -I. -c -o $@ $< -o $@
%MPFR_debug.o: %.c %.h
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_MPFR -I../num -I../itv -I. -c -o $@ $< -o $@
$(CC) $(CFLAGS_DEBUG) $(ICFLAGS) -DNUM_MPFR -I. -c -o $@ $< -o $@

#---------------------------------------
# dependencies (generated with make depend)
#---------------------------------------

depend: $(C_FILES) $(H_FILES)
$(CC) $(ICFLAGS) -I../num -E -MM $(C_FILES)
$(CC) $(ICFLAGS) -E -MM $(C_FILES)


ap_scalar.o: ap_scalar.c ap_scalar.h ap_config.h
Expand Down
Loading

0 comments on commit b95d0cd

Please sign in to comment.