PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/database/pgocaml/Makefile

http://github.com/aryx/fork-ocsigen
Makefile | 226 lines | 118 code | 50 blank | 58 comment | 4 complexity | 139950083a534fb9281447d275327547 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.0, LGPL-2.1, MIT, WTFPL
  1. # PG'OCaml - type safe interface to PostgreSQL.
  2. # Copyright (C) 2005-2009 Richard Jones and other authors.
  3. #
  4. # This library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2 of the License, or (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Library General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this library; see the file COPYING. If not, write to
  16. # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. # Boston, MA 02111-1307, USA.
  18. include Makefile.config
  19. SED := sed
  20. FGREP := fgrep
  21. OCAMLCFLAGS := -g
  22. OCAMLCPACKAGES := -package unix,extlib,pcre,calendar,csv
  23. OCAMLCLIBS := -linkpkg
  24. OCAMLOPTFLAGS :=
  25. OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
  26. OCAMLOPTLIBS := -linkpkg
  27. OCAMLDOCFLAGS := -html -stars -sort $(OCAMLCPACKAGES)
  28. GETLIB=-I +$(1) $(shell ocamlfind query $(1) -predicates byte -format "%d/%a")
  29. FOR_P4 := \
  30. $(call GETLIB,unix) \
  31. $(call GETLIB,str) \
  32. $(call GETLIB,pcre) \
  33. $(call GETLIB,extlib) \
  34. $(call GETLIB,calendar) \
  35. $(call GETLIB,csv) \
  36. ./pgocaml.cma
  37. #
  38. # This is split into two because back-tick notation
  39. # doesn't necessarily work under Windows
  40. #
  41. OCAMLVERSION := $(shell ocamlc -v | $(FGREP) "version" | $(SED) -e "s/.*3\.\(..\)\..*/\1/")
  42. P4_PARAMS := $(shell [ $(OCAMLVERSION) -ge 9 ] && echo -loc loc)
  43. ifdef WINDOWS
  44. EXECUTABLE_SUFFIX := .exe
  45. endif
  46. #
  47. # Top-rules.
  48. #
  49. OBJS := pGOCaml_config.cmo pGOCaml_generic.cmo pGOCaml.cmo
  50. XOBJS := $(OBJS:.cmo=.cmx)
  51. all: META pGOCaml_config.ml pgocaml.cma pgocaml.cmxa pa_pgsql.cmo pgocaml_prof$(EXECUTABLE_SUFFIX)
  52. test: test_pgocaml_lowlevel$(EXECUTABLE_SUFFIX) test_pgocaml$(EXECUTABLE_SUFFIX)
  53. #
  54. # Rules for testing programs.
  55. #
  56. test_pgocaml_lowlevel$(EXECUTABLE_SUFFIX): test_pgocaml_lowlevel.cmo pgocaml.cma
  57. ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(OCAMLCLIBS) pgocaml.cma -o $@ $<
  58. test_pgocaml$(EXECUTABLE_SUFFIX): test_pgocaml.cmo pgocaml.cma
  59. ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(OCAMLCLIBS) pgocaml.cma -o $@ $<
  60. pgocaml_prof$(EXECUTABLE_SUFFIX): pgocaml_prof.cmx
  61. ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) $(OCAMLOPTLIBS) -o $@ $<
  62. test_pgocaml.cmo: test_pgocaml.ml pgocaml.cma pa_pgsql.cmo
  63. ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(OCAMLCLIBS) -pp "camlp4o $(FOR_P4) ./pa_pgsql.cmo" -c $<
  64. print_test: force
  65. camlp4o $(FOR_P4) ./pa_pgsql.cmo pr_o.cmo test_pgocaml.ml
  66. #
  67. # Rules for core library.
  68. #
  69. pa_pgsql.cmo: pa_pgsql.ml4
  70. ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) \
  71. -pp "camlp4o pa_extend.cmo q_MLast.cmo $(P4_PARAMS) -impl" \
  72. -I +camlp4 -c -impl $<
  73. pgocaml.cma: $(OBJS)
  74. ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -a -o $@ $^
  75. pgocaml.cmxa: $(XOBJS)
  76. ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -a -o $@ $^
  77. pGOCaml_config.ml: pGOCaml_config.ml.in Makefile Makefile.config
  78. < $< sed -e "s|@DEFAULT_UNIX_DOMAIN_SOCKET_DIR@|$(DEFAULT_UNIX_DOMAIN_SOCKET_DIR)|" > $@
  79. #
  80. # Common rules for building OCaml objects.
  81. #
  82. .mli.cmi:
  83. ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCINCS) $(OCAMLCPACKAGES) -c $<
  84. .ml.cmo:
  85. ocamlfind ocamlc $(OCAMLCFLAGS) $(OCAMLCINCS) $(OCAMLCPACKAGES) -c $<
  86. .ml.cmx:
  87. ocamlfind ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTINCS) $(OCAMLOPTPACKAGES) -c $<
  88. #
  89. # Findlib META file.
  90. #
  91. META: META.in Makefile.config
  92. $(SED) -e 's/@PACKAGE@/$(PACKAGE)/' \
  93. -e 's/@VERSION@/$(VERSION)/' \
  94. < $< > $@
  95. #
  96. # Clean.
  97. #
  98. clean:
  99. rm -f *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so *~ core .depend META \
  100. test_pgocaml_lowlevel test_pgocaml pgocaml_prof
  101. #
  102. # Dependencies.
  103. #
  104. depend: .depend
  105. .depend: pGOCaml_config.ml
  106. rm -f .depend
  107. ocamldep pGOCaml*.ml pGOCaml*.mli > $@
  108. -ocamldep -pp "camlp4o $(FOR_P4) ./pa_pgsql.cmo" >> $@
  109. ifeq ($(wildcard .depend),.depend)
  110. include .depend
  111. endif
  112. #
  113. # Install.
  114. #
  115. #pad: make findlib install the default old
  116. install:
  117. ocamlfind install $(PACKAGE) META pgocaml.a pgocaml.cma pgocaml.cmxa pGOCaml_generic.cm[ix] pGOCaml.cm[ix] pa_pgsql.cmo pGOCaml_generic.mli pGOCaml.mli
  118. reinstall:
  119. ocamlfind remove $(PACKAGE)
  120. ocamlfind install $(PACKAGE) META pgocaml.a pgocaml.cma pgocaml.cmxa pGOCaml_generic.cm[ix] pGOCaml.cm[ix] pa_pgsql.cmo pGOCaml_generic.mli pGOCaml.mli
  121. install_oldschool:
  122. rm -rf $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)
  123. install -c -m 0755 -d $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)
  124. install -c -m 0644 *.cmi *.mli *.cmo *.cma *.cmxa *.a META \
  125. $(DESTDIR)$(OCAMLLIBDIR)/$(PACKAGE)
  126. #
  127. # Distribution.
  128. #
  129. dist:
  130. $(MAKE) check-manifest
  131. rm -rf $(PACKAGE)-$(VERSION)
  132. mkdir $(PACKAGE)-$(VERSION)
  133. tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
  134. tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
  135. rm -rf $(PACKAGE)-$(VERSION)
  136. ls -l $(PACKAGE)-$(VERSION).tar.gz
  137. check-manifest:
  138. svn list | sort > .check-manifest; \
  139. sort MANIFEST > .orig-manifest; \
  140. diff -u .orig-manifest .check-manifest; rv=$$?; \
  141. rm -f .orig-manifest .check-manifest; \
  142. exit $$rv
  143. #
  144. # Debian packages.
  145. #
  146. dpkg:
  147. @if [ 0 != `cvs -q update | wc -l` ]; then \
  148. echo Please commit all changes to CVS first.; \
  149. exit 1; \
  150. fi
  151. $(MAKE) dist
  152. rm -rf /tmp/dbuild
  153. mkdir /tmp/dbuild
  154. cp $(PACKAGE)-$(VERSION).tar.gz \
  155. /tmp/dbuild/$(PACKAGE)_$(VERSION).orig.tar.gz
  156. export CVSROOT=`cat CVS/Root`; \
  157. cd /tmp/dbuild && \
  158. cvs export \
  159. -d $(PACKAGE)-$(VERSION) \
  160. -D now merjis/freeware/pgocaml
  161. cd /tmp/dbuild/$(PACKAGE)-$(VERSION) && dpkg-buildpackage -rfakeroot
  162. rm -rf /tmp/dbuild/$(PACKAGE)-$(VERSION)
  163. ls -l /tmp/dbuild
  164. #
  165. # Developer documentation (in html/ subdirectory).
  166. #
  167. doc:
  168. rm -rf html
  169. mkdir html
  170. -ocamlfind ocamldoc $(OCAMLDOCFLAGS) -d html pGOCaml_generic.mli pGOCaml_generic.ml pGOCaml.mli pGOCaml.ml
  171. #
  172. # Miscelaneous.
  173. #
  174. force:
  175. .PHONY: depend dist check-manifest dpkg doc print_test
  176. .SUFFIXES: .cmo .cmi .cmx .ml .mli