The Sol Programming Language!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. _CFLAGS= -g $(BUILD_DEFINES) $(CFLAGS)
  2. _LDFLAGS= -lfl -lm -ldl -lreadline $(LDFLAGS)
  3. OBJ= lex.yy.o parser.tab.o dsl/seq.o dsl/list.o dsl/array.o dsl/generic.o astprint.o runtime.o gc.o object.o state.o builtins.o solrun.o ser.o
  4. ifndef CC
  5. CC:= gcc
  6. endif
  7. ifndef OBJCOPY
  8. OBJCOPY:= objcopy
  9. endif
  10. ifndef OBJDUMP
  11. OBJDUMP:= objdump
  12. endif
  13. ifndef DESTDIR
  14. DESTDIR:= /usr/local/
  15. endif
  16. ifdef NO_HELP
  17. _CFLAGS+= -DNO_HELP
  18. else
  19. OBJ+= sol_help.o
  20. endif
  21. ifndef STDOUT_FILENAME
  22. STDOUT_FILENAME:=/dev/fd/1
  23. endif
  24. include VERSION_INFO
  25. include ARCH_INFO
  26. BUILD_DEFINES:= -DSOL_BUILD_HOST="\"$(shell uname -n)\"" -DSOL_BUILD_KERNEL="\"$(shell uname -s)\"" -DSOL_BUILD_ARCH="\"$(shell uname -m)\"" -DSOL_BUILD_REV="\"$(shell git rev-parse --short HEAD)$(shell git diff-index --quiet HEAD || echo '-dirty')\""
  27. SOL_VER:=$(MAJOR).$(MINOR)$(RELEASE)$(PATCH)$(SUFFIX)
  28. LINKED_VERS:=sol sol$(MAJOR) sol$(MAJOR).$(MINOR)
  29. .PHONY: install install_bin install_bindir install_lib install_libdir uninstall uninstall_bin uninstall_lib all test clean docs
  30. all: dsl libsol.a $(LINKED_VERS)
  31. install: install_bindir install_libdir install_bin install_lib
  32. install_bin: sol$(SOL_VER) $(LINKED_VERS)
  33. install $? $(DESTDIR)/bin/
  34. install_lib: programs tests
  35. cp -r $? $(DESTDIR)/lib/sol$(SOL_VER)/
  36. install_bindir:
  37. install -d $(DESTDIR)/bin/
  38. install_libdir:
  39. install -d $(DESTDIR)/lib/sol$(SOL_VER)/
  40. uninstall: uninstall_bin uninstall_lib
  41. uninstall_bin:
  42. rm $(DESTDIR)/bin/sol$(SOL_VER) || true
  43. for fname in $(LINKED_VERS); do rm $(DESTDIR)/bin/$$fname || true; done
  44. uninstall_lib:
  45. rm -r $(DESTDIR)/lib/sol$(SOL_VER)/{programs,tests}
  46. $(LINKED_VERS): sol$(SOL_VER)
  47. rm $@; ln -s $? $@
  48. sol$(SOL_VER): $(OBJ)
  49. $(CC) $(_CFLAGS) $^ $(_LDFLAGS) -o $@
  50. libsol.a: $(OBJ)
  51. $(AR) rcs $@ $^
  52. test: all $(sort $(patsubst tests/%.sol,test_%,$(filter-out tests/_%,$(wildcard tests/*.sol)))) $(sort $(patsubst tests/%.sol,testcomp_%,$(filter-out tests/_%,$(wildcard tests/*.sol))))
  53. test_%: tests/%.sol
  54. ./sol r $?
  55. testcomp_%: tests/%.sol
  56. ./sol rc $? $(STDOUT_FILENAME) | ./sol C
  57. profile: all prof profile-boot $(sort $(patsubst tests/%.sol,profile_%,$(wildcard tests/*.sol))) profilecomp-boot $(sort $(patsubst tests/%.sol,profilecomp_%,$(wildcard tests/*.sol)))
  58. prof:
  59. mkdir prof
  60. profile-boot: programs/test.sol
  61. LLVM_PROFILE_FILE=prof/boot.prof ./sol r $?
  62. profile_%: tests/%.sol
  63. LLVM_PROFILE_FILE=prof/sol.$(basename $(notdir $?)).prof ./sol r $?
  64. profilecomp-boot: programs/test.sol
  65. LLVM_PROFILE_FILE=prof/bootcomp.comp.prof ./sol rc $? $(STDOUT_FILENAME) | LLVM_PROFILE_FILE=prof/bootcomp.run.prof ./sol C
  66. profilecomp_%: tests/%.sol
  67. LLVM_PROFILE_FILE=prof/solcomp.$(basename $(notdir $?)).comp.prof ./sol rc $? $(STDOUT_FILENAME) | LLVM_PROFILE_FILE=prof/solcomp.$(basename $(notdir $?)).run.prof ./sol C
  68. prof/sol.html: profile
  69. llvm-profdata merge -sparse prof/*.prof -o prof/sol.prof.merged
  70. llvm-cov show -instr-profile prof/sol.prof.merged ./sol -format=html > $@
  71. all-profile: prof/sol.html
  72. dsl:
  73. git submodule init && git submodule sync && git submodule update
  74. VERSION_INFO: sol.h
  75. perl -n -e '/#define SOL_VERSION "([[:digit:]]+)\.([[:digit:]]+)(.)([[:digit:]]+)"/ && print "MAJOR:=$$1\nMINOR:=$$2\nRELEASE:=$$3\nPATCH:=$$4\n"' $? > $@
  76. ARCH_INFO: gc.o
  77. $(OBJDUMP) -f $? | perl -n -e '/file format ([^-]+-(.+))$$/ && print "HOST_ARCH:=$$2\nHOST_ELF:=$$1\n"' > $@
  78. %.o: %.c
  79. $(CC) -c -o $@ $? $(_CFLAGS)
  80. %.o: %.txt | ARCH_INFO
  81. $(OBJCOPY) -B i386 -I binary -O $(HOST_ELF) $? $@
  82. %.tab.c %.tab.h: %.y
  83. bison -rall -fall -d $?
  84. lex.yy.c: tokenizer.lex parser.tab.h
  85. flex $<
  86. clean:
  87. rm -f *.o dsl/*.o sol
  88. docs: Doxyfile
  89. doxygen Doxyfile
  90. sphinx-build -b html . ./_build