build: Get 'make install' working.
authorRichard W.M. Jones <rjones@redhat.com>
Mon, 16 Sep 2013 13:36:20 +0000 (14:36 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Mon, 16 Sep 2013 14:09:08 +0000 (15:09 +0100)
Add a spec file.

.gitignore
META.in [new file with mode: 0644]
Makefile.am
common-rules.mk
configure.ac
examples/compile-c/Makefile.am
goaljobs [new file with mode: 0755]
goaljobs.spec.in [new file with mode: 0644]
m4/ocaml.m4 [new file with mode: 0644]

index 5613406..c32e226 100644 (file)
@@ -22,8 +22,11 @@ Makefile
 /configure
 /examples/compile-c/compile
 /examples/compile-c/program
+/goaljobs.spec
+/goaljobs-*.tar.gz
 /install-sh
 /libtool
 /ltmain.sh
+/META
 /missing
 /stamp-h1
diff --git a/META.in b/META.in
new file mode 100644 (file)
index 0000000..479a8c6
--- /dev/null
+++ b/META.in
@@ -0,0 +1,14 @@
+name="goaljobs"
+version="@PACKAGE_VERSION@"
+description="make & cron replacement and business rules manager"
+requires="unix"
+archive(byte)="goaljobs.cma"
+archive(native)="goaljobs.cmxa"
+
+package "syntax" (
+        version="@PACKAGE_VERSION@"
+        requires="camlp4"
+        description="goaljobs syntax extension"
+        archive(syntax,preprocessor) = "-parser o -parser op -printer p unix.cma goaljobs.cma pa_goal.cmo"
+        archive(syntax,toploop) = "unix.cma goaljobs.cma pa_goal.cmo"
+)
index b995c23..1aa4248 100644 (file)
@@ -21,9 +21,14 @@ ACLOCAL_AMFLAGS = -I m4
 
 EXTRA_DIST = \
        COPYING \
+       goaljobs \
+       goaljobs.spec \
+       goaljobs.spec.in \
+       META.in \
        NOTES \
        README \
-       $(sources)
+       $(sources) \
+       pa_goal.ml
 
 SUBDIRS = . examples tests
 
@@ -31,9 +36,17 @@ sources = \
        goaljobs.ml \
        goaljobs.mli
 
-noinst_SCRIPTS = goaljobs.cmxa pa_goal.cmo
+bin_SCRIPTS = goaljobs
+
+# These targets are noinst because we use a custom install hook to
+# install them, and are _SCRIPTS because automake doesn't know how to
+# compile OCaml code.
+noinst_SCRIPTS = goaljobs.cma goaljobs.cmxa pa_goal.cmo
 
 # Library.
+goaljobs.cma: goaljobs.cmo
+       $(OCAMLFIND) ocamlc -a -o $@ $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $<
+
 goaljobs.cmxa: goaljobs.cmx
        $(OCAMLFIND) ocamlopt -a -o $@ $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $<
 
@@ -42,8 +55,16 @@ pa_goal.cmo: pa_goal.ml
        $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package camlp4.lib -linkpkg \
            -pp $(CAMLP4OF) -c $< -o $@
 
-# Dependencies.
+# Install.
+install-data-hook:
+       mkdir -p $(DESTDIR)$(OCAMLLIB)
+       $(OCAMLFIND) install \
+           -ldconf ignore -destdir $(DESTDIR)$(OCAMLLIB) \
+           goaljobs \
+           META goaljobs.cma goaljobs.cmxa pa_goal.cmo *.cmi $(srcdir)/*.mli
+       rm $(DESTDIR)$(OCAMLLIB)/goaljobs/pa_goal.cmi
 
+# Dependencies.
 depend: .depend
 
 .depend: $(sources)
@@ -57,9 +78,9 @@ depend: .depend
 
 -include .depend
 
-SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
+rpm: dist
+       rpmbuild -ta $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz
 
 # License check.
-
 licensecheck:
        licensecheck $$(git ls-files)
index 692c906..c11bc82 100644 (file)
@@ -28,3 +28,5 @@ OCAMLOPTPACKAGES = $(OCAMLCPACKAGES)
        $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $< -o $@
 %.cmx: %.ml
        $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $< -o $@
+
+SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
index 6ca6f32..613186d 100644 (file)
 AC_INIT([goaljobs],[0.1])
 AM_INIT_AUTOMAKE([foreign])
 
+dnl Only used temporarily while goaljobs.spec is contained in the
+dnl tarball.  We will remove this later.
+AC_SUBST([RPM_RELEASE],[1])
+
 AC_CONFIG_MACRO_DIR([m4])
 
 dnl Allow all GNU/Linux functions.
@@ -85,7 +89,9 @@ if test "x$PERLDOC" = "x"; then
 fi
 
 AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile
+AC_CONFIG_FILES([goaljobs.spec
+                 Makefile
+                 META
                  examples/Makefile
                  examples/compile-c/Makefile
                  tests/Makefile])
index d8a1be7..89906ad 100644 (file)
@@ -30,6 +30,7 @@ compile: ../../goaljobs.cmxa compile.cmx
            $(OCAMLOPTPACKAGES) -linkpkg $^ -o $@
 
 compile.cmx: compile.ml ../../pa_goal.cmo
+       OCAMLPATH=$(abs_top_builddir) \
        $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) \
            -pp "$(CAMLP4O) ../../pa_goal.cmo" -c $< -o $@
 
@@ -47,5 +48,3 @@ depend: .depend
        mv $@-t $@
 
 -include .depend
-
-SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
diff --git a/goaljobs b/goaljobs
new file mode 100755 (executable)
index 0000000..6628d3e
--- /dev/null
+++ b/goaljobs
@@ -0,0 +1,17 @@
+#!/bin/bash -
+# goaljobs
+# Copyright (C) 2013 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
diff --git a/goaljobs.spec.in b/goaljobs.spec.in
new file mode 100644 (file)
index 0000000..7532cb8
--- /dev/null
@@ -0,0 +1,77 @@
+%global opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0)
+
+Name:            @PACKAGE_NAME@
+Version:         @PACKAGE_VERSION@
+Release:         @RPM_RELEASE@%{?dist}
+Summary:         Make & cron replacement and business rules manager.
+License:         GPLv2+
+
+URL:             http://people.redhat.com/~rjones/goaljobs
+Source0:         http://people.redhat.com/~rjones/goaljobs/files/%{name}-%{version}.tar.gz
+
+BuildRequires:   ocaml >= 3.12.0
+BuildRequires:   ocaml-ocamldoc
+BuildRequires:   ocaml-findlib-devel
+BuildRequires:   ocaml-camlp4-devel
+
+# For building manual pages.
+BuildRequires:   /usr/bin/perldoc
+
+# Requires camlp4 and ocamlfind at runtime.
+Requires:        /usr/bin/ocamlc
+Requires:        ocaml-camlp4-devel
+Requires:        ocaml-findlib-devel
+
+
+%description
+Goaljobs is make & cron replacement and business rules manager.
+
+It can be used in many situations where you want a more powerful
+'make' or a more powerful 'cron', especially where you have
+dependencies on network resources.
+
+This is also an enhancement and replacement for the 'whenjobs'
+package.
+
+
+%prep
+%setup -q
+
+
+%build
+%configure
+make %{?_smp_mflags}
+
+
+%check
+make check
+
+
+%install
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%if %opt
+# Remove bytecode library.
+rm $RPM_BUILD_ROOT%{_libdir}/ocaml/goaljobs/goaljobs.cma
+%endif
+
+
+%files
+%doc COPYING README
+%{_bindir}/goaljobs
+%dir %{_libdir}/ocaml/goaljobs
+%{_libdir}/ocaml/goaljobs/META
+%{_libdir}/ocaml/goaljobs/*.mli
+%{_libdir}/ocaml/goaljobs/*.cmi
+%{_libdir}/ocaml/goaljobs/pa_goal.cmo
+%if %opt
+%{_libdir}/ocaml/goaljobs/goaljobs.cmxa
+%else
+%{_libdir}/ocaml/goaljobs/goaljobs.cma
+%endif
+#%{_mandir}/man1/*.1*
+
+
+%changelog
+* Mon Sep 16 2013 Richard W.M. Jones <rjones@redhat.com> - @PACKAGE_VERSION@-@RPM_RELEASE@
+- Initial release.
diff --git a/m4/ocaml.m4 b/m4/ocaml.m4
new file mode 100644 (file)
index 0000000..fddd6a0
--- /dev/null
@@ -0,0 +1,217 @@
+dnl autoconf macros for OCaml
+dnl
+dnl Copyright © 2009      Richard W.M. Jones
+dnl Copyright © 2009      Stefano Zacchiroli
+dnl Copyright © 2000-2005 Olivier Andrieu
+dnl Copyright © 2000-2005 Jean-Christophe Filliâtre
+dnl Copyright © 2000-2005 Georges Mariano
+dnl
+dnl For documentation, please read the ocaml.m4 man page.
+
+AC_DEFUN([AC_PROG_OCAML],
+[dnl
+  # checking for ocamlc
+  AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
+
+  if test "$OCAMLC" != "no"; then
+     OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
+     AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
+     OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
+     AC_MSG_RESULT([OCaml library path is $OCAMLLIB])
+
+     AC_SUBST([OCAMLVERSION])
+     AC_SUBST([OCAMLLIB])
+
+     # checking for ocamlopt
+     AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no])
+     OCAMLBEST=byte
+     if test "$OCAMLOPT" = "no"; then
+        AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
+     else
+        TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+        if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+            AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
+            OCAMLOPT=no
+        else
+            OCAMLBEST=opt
+        fi
+     fi
+
+     AC_SUBST([OCAMLBEST])
+
+     # checking for ocamlc.opt
+     AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no])
+     if test "$OCAMLCDOTOPT" != "no"; then
+        TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+        if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+            AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
+        else
+            OCAMLC=$OCAMLCDOTOPT
+        fi
+     fi
+
+     # checking for ocamlopt.opt
+     if test "$OCAMLOPT" != "no" ; then
+        AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
+        if test "$OCAMLOPTDOTOPT" != "no"; then
+           TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+           if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+              AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
+           else
+              OCAMLOPT=$OCAMLOPTDOTOPT
+           fi
+        fi
+     fi
+
+     AC_SUBST([OCAMLOPT])
+  fi
+
+  AC_SUBST([OCAMLC])
+
+  # checking for ocamldep
+  AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no])
+
+  # checking for ocamlmktop
+  AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no])
+
+  # checking for ocamlmklib
+  AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no])
+
+  # checking for ocamldoc
+  AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
+
+  # checking for ocamlbuild
+  AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no])
+])
+
+
+AC_DEFUN([AC_PROG_OCAMLLEX],
+[dnl
+  # checking for ocamllex
+  AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no])
+  if test "$OCAMLLEX" != "no"; then
+    AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
+    if test "$OCAMLLEXDOTOPT" != "no"; then
+        OCAMLLEX=$OCAMLLEXDOTOPT
+    fi
+  fi
+  AC_SUBST([OCAMLLEX])
+])
+
+AC_DEFUN([AC_PROG_OCAMLYACC],
+[dnl
+  AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no])
+  AC_SUBST([OCAMLYACC])
+])
+
+
+AC_DEFUN([AC_PROG_CAMLP4],
+[dnl
+  AC_REQUIRE([AC_PROG_OCAML])dnl
+
+  # checking for camlp4
+  AC_CHECK_TOOL([CAMLP4],[camlp4],[no])
+  if test "$CAMLP4" != "no"; then
+     TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'`
+     if test "$TMPVERSION" != "$OCAMLVERSION" ; then
+        AC_MSG_RESULT([versions differs from ocamlc])
+        CAMLP4=no
+     fi
+  fi
+  AC_SUBST([CAMLP4])
+
+  # checking for companion tools
+  AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no])
+  AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no])
+  AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no])
+  AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no])
+  AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no])
+  AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no])
+  AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no])
+  AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no])
+  AC_SUBST([CAMLP4BOOT])
+  AC_SUBST([CAMLP4O])
+  AC_SUBST([CAMLP4OF])
+  AC_SUBST([CAMLP4OOF])
+  AC_SUBST([CAMLP4ORF])
+  AC_SUBST([CAMLP4PROF])
+  AC_SUBST([CAMLP4R])
+  AC_SUBST([CAMLP4RF])
+])
+
+
+AC_DEFUN([AC_PROG_FINDLIB],
+[dnl
+  AC_REQUIRE([AC_PROG_OCAML])dnl
+
+  # checking for ocamlfind
+  AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no])
+  AC_SUBST([OCAMLFIND])
+])
+
+
+dnl Thanks to Jim Meyering for working this next bit out for us.
+dnl XXX We should define AS_TR_SH if it's not defined already
+dnl (eg. for old autoconf).
+AC_DEFUN([AC_CHECK_OCAML_PKG],
+[dnl
+  AC_REQUIRE([AC_PROG_FINDLIB])dnl
+
+  AC_MSG_CHECKING([for OCaml findlib package $1])
+
+  unset found
+  unset pkg
+  found=no
+  for pkg in $1 $2 ; do
+    if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
+      AC_MSG_RESULT([found])
+      AS_TR_SH([OCAML_PKG_$1])=$pkg
+      found=yes
+      break
+    fi
+  done
+  if test "$found" = "no" ; then
+    AC_MSG_RESULT([not found])
+    AS_TR_SH([OCAML_PKG_$1])=no
+  fi
+
+  AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
+])
+
+
+AC_DEFUN([AC_CHECK_OCAML_MODULE],
+[dnl
+  AC_MSG_CHECKING([for OCaml module $2])
+
+  cat > conftest.ml <<EOF
+open $3
+EOF
+  unset found
+  for $1 in $$1 $4 ; do
+    if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then
+      found=yes
+      break
+    fi
+  done
+
+  if test "$found" ; then
+    AC_MSG_RESULT([$$1])
+  else
+    AC_MSG_RESULT([not found])
+    $1=no
+  fi
+  AC_SUBST([$1])
+])
+
+
+dnl XXX Cross-compiling
+AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
+[dnl
+  AC_MSG_CHECKING([for OCaml compiler word size])
+  cat > conftest.ml <<EOF
+  print_endline (string_of_int Sys.word_size)
+  EOF
+  OCAML_WORD_SIZE=`ocaml conftest.ml`
+  AC_MSG_RESULT([$OCAML_WORD_SIZE])
+  AC_SUBST([OCAML_WORD_SIZE])
+])