Makefile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Make uses /bin/sh as default shell. Chenge to /bin/bash to support
  2. # wildcard expansion in commands.
  3. SHELL=/bin/bash
  4. # The path to the DOKK "data" repository.
  5. # This is used by some sources instead of downloading the repository.
  6. DOKK-DATA=$(realpath ../data)
  7. # List of all sources.
  8. # A source is the name of the sub-directory in ./source
  9. SOURCE=$(shell find ./source/ -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
  10. # Build all sources.
  11. # Documentation for "Automatic Variables": https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html#Automatic-Variables
  12. ${SOURCE}:
  13. @ # Do not print commands
  14. if [ ! -d "${DOKK-DATA}" ]
  15. then
  16. echo "DOKK-DATA doesn't exist!"
  17. exit
  18. fi
  19. # Run a source Makefile in its sub-directory.
  20. # The job of each subdirectory is to create a data/ directory
  21. # containing all the required RDF files.
  22. ${MAKE} DOKK-DATA=${DOKK-DATA} --directory ./source/$@
  23. # Merge all RDF data into single .nt file.
  24. # This code will create a .nt file in the source directory. For example,
  25. # if the source name ($@) is "grid", will create ./source/grid/grid.nt.
  26. # This process assumes that all input triples are valid (no syntax errors).
  27. # NB: we use - in front of "find" because RIOT does not return 0
  28. # if it raised any warnings. "Make" aborts execution if it sees
  29. # a return code other than 0, but we are OK with RIOT warnings.
  30. -find ./source/$@/data/ \
  31. -type f \
  32. -exec riot --base "#" \
  33. --check \
  34. --strict \
  35. --stop \
  36. --output nq \
  37. {} > ./source/$@/$@.nt \
  38. +
  39. # Delete old source dataset
  40. echo "Deleting $@ dataset."
  41. rm --recursive --force ./dataset/$@/
  42. # Now build a TDB2 dataset for this source
  43. tdb2.tdbloader --loc ./dataset/$@/ ./source/$@/$@.nt
  44. # Build the DOKK graph from queries
  45. graph:
  46. @ # Do not print commands
  47. echo "Deleting dokk dataset."
  48. rm --recursive --force dataset/dokk/
  49. # Execute queries in order!
  50. for query in RadioChannel License rdf-prefixes manpages \
  51. library articles documentation
  52. do
  53. echo "Processing: $${query}"
  54. update --desc dataset.ttl --update "query/$${query}.rq"
  55. done
  56. clean:
  57. rm --recursive --force dataset
  58. .ONESHELL:
  59. .PHONY: $(SOURCE) clean