Makefile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #
  2. # This Makefile takes .st files in the amber/st directory and produces compiled
  3. # javascript files from them, for both debug and deployment.
  4. #
  5. # Where we find the current runnable code and where we put our js files on install
  6. JS := ../js/
  7. # The compiler script
  8. AMBERC := ../bin/amberc
  9. # Generic flags to AMBERC
  10. FLAGS := -d
  11. # All corresponding js filenames for every st file available
  12. # In other words, if we have Kernel.st and Compiler.st, then OBJECTS will be "Kernel.js Compiler.js"
  13. OBJECTS := $(patsubst %.st,%.js,$(wildcard *.st))
  14. # Default make target since it is the first target in this Makefile
  15. all: $(OBJECTS)
  16. # Step by step
  17. #
  18. # First we copy the core javascript files from current working files
  19. # into this directory. These files are hand written or generated using
  20. # other tools (parser.js). $@ is the target name.
  21. boot.js init.js:
  22. cp ../js/$@ .
  23. # generate the parser
  24. # $@ is the target
  25. # $< is the prerequisite
  26. parser.js: ../js/parser.pegjs
  27. pegjs --track-line-and-column --cache -e smalltalk.parser $< $@
  28. # Then we compile Kernel-*.st files depending on having boot.js, init.js and parser.js
  29. # $< means the first dependency - in other words Kernel-*.st
  30. Kernel-Objects.js: Kernel-Objects.st boot.js init.js parser.js
  31. $(AMBERC) $(FLAGS) $<
  32. Kernel-Classes.js: Kernel-Classes.st boot.js init.js parser.js
  33. $(AMBERC) $(FLAGS) $<
  34. Kernel-Methods.js: Kernel-Methods.st boot.js init.js parser.js
  35. $(AMBERC) $(FLAGS) $<
  36. Kernel-Collections.js: Kernel-Collections.st boot.js init.js parser.js
  37. $(AMBERC) $(FLAGS) $<
  38. Kernel-Exceptions.js: Kernel-Exceptions.st boot.js init.js parser.js
  39. $(AMBERC) $(FLAGS) $<
  40. Kernel-Transcript.js: Kernel-Transcript.st boot.js init.js parser.js
  41. $(AMBERC) $(FLAGS) $<
  42. Kernel-Announcements.js: Kernel-Announcements.st boot.js init.js parser.js
  43. $(AMBERC) $(FLAGS) $<
  44. # ...and Compiler, but using the new Kernel from above.
  45. # We only need to depend on Kernel js files since it in turn depends on boot.js etc
  46. Compiler.st: Importer-Exporter.st Compiler-Exceptions.st Compiler-Core.st \
  47. Compiler-AST.st Compiler-Semantic.st Compiler-IR.st Compiler-Inlining.st \
  48. Compiler-Interpreter.st
  49. echo "Smalltalk current createPackage: 'Compiler' properties: #{}!" >$@
  50. sed -e '/^Smalltalk current createPackage:.*!$$/ d' \
  51. -e 's/package: '"'[^':]*'"'!/package:'"'Compiler'"'!/' \
  52. -e 's/ methodsFor: '"'[^']*'"'!$$/ methodsFor: '"'"'*Compiler'"'"'!/' \
  53. $^ >>$@
  54. Compiler.js: Compiler.st Kernel-Objects.js Kernel-Classes.js Kernel-Methods.js Kernel-Collections.js \
  55. Kernel-Exceptions.js Kernel-Transcript.js
  56. $(AMBERC) $(FLAGS) -l Importer-Exporter,Compiler-Exceptions,Compiler-Core,Compiler-AST,Compiler-Semantic,Compiler-IR,Compiler-Inlining $<
  57. # ...now that we have a new Kernel and Compiler we use them
  58. # to compile the rest of st files presuming that they only depend on Kernel, like
  59. # for example Canvas.js and Benchfib.js.
  60. %.js: %.st Compiler.js
  61. $(AMBERC) $(FLAGS) $<
  62. # But for some libraries there are more dependencies to care for. Then
  63. # we need to use -l so that the compiler first loads that library
  64. # before compiling the .st file. Otherwise bindings will fail.
  65. #
  66. # NOTE: With the new dependency model in class Package etc this will change!
  67. #
  68. Canvas.js: Canvas.st Compiler.js
  69. $(AMBERC) $(FLAGS) $<
  70. # IDE uses JQuery
  71. IDE.js: IDE.st Canvas.js Compiler.js
  72. $(AMBERC) $(FLAGS) -l Canvas $<
  73. TrySmalltalk.js: TrySmalltalk.st IDE.js Compiler.js
  74. $(AMBERC) $(FLAGS) -l Canvas,IDE $<
  75. # Some Examples use SUnit and also IDE
  76. Examples.js: Examples.st SUnit.js IDE.js Compiler.js
  77. $(AMBERC) $(FLAGS) -l SUnit,Canvas,IDE $<
  78. # Tests typically also use SUnit
  79. Kernel-Tests.js: Kernel-Tests.st SUnit.js Compiler.js
  80. $(AMBERC) $(FLAGS) -l SUnit $<
  81. Compiler-Tests.js: Compiler-Tests.st SUnit.js Compiler.js
  82. $(AMBERC) $(FLAGS) -l SUnit $<
  83. SUnit-Tests.js: SUnit-Tests.st SUnit.js Compiler.js
  84. $(AMBERC) $(FLAGS) -l SUnit $<
  85. # Documentation
  86. Documentation.js: Documentation.st Canvas.js Compiler.js
  87. $(AMBERC) $(FLAGS) -l Canvas $<;
  88. #Helios
  89. Helios-Core.js: Helios-Core.st Canvas.js Compiler.js
  90. $(AMBERC) $(FLAGS) -l Canvas $<;
  91. Helios-Browser.js: Helios-Browser.st Helios-Core.js Compiler.js
  92. $(AMBERC) $(FLAGS) -l Helios-Core $<;
  93. # Installing is simply copying all js files to js directory.
  94. install: all
  95. cp *.js $(JS)
  96. # And cleaning is trivial also
  97. clean:
  98. rm -f *.js
  99. # These three are phony
  100. .PHONY: all install clean