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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 sol_help.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. ifndef STDOUT_FILENAME
  17. STDOUT_FILENAME:=/dev/fd/1
  18. endif
  19. ifneq (,$(findstring -DNO_READLINE,$(_CFLAGS)))
  20. _LDFLAGS := $(filter-out -lreadline,$(_LDFLAGS))
  21. endif
  22. ifneq (,$(findstring -DNO_HELP,$(_CFLAGS)))
  23. OBJ := $(filter-out sol_help.o,$(OBJ))
  24. endif
  25. include VERSION_INFO
  26. include ARCH_INFO
  27. 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')\""
  28. SOL_VER:=$(MAJOR).$(MINOR)$(RELEASE)$(PATCH)$(SUFFIX)
  29. LINKED_VERS:=sol sol$(MAJOR) sol$(MAJOR).$(MINOR)
  30. .PHONY: install install_bin install_bindir install_lib install_libdir uninstall uninstall_bin uninstall_lib all test clean docs
  31. all: dsl libsol.a $(LINKED_VERS)
  32. install: install_bindir install_libdir install_bin install_lib
  33. install_bin: sol$(SOL_VER) $(LINKED_VERS)
  34. install $? $(DESTDIR)/bin/
  35. install_lib: programs tests
  36. cp -r $? $(DESTDIR)/lib/sol$(SOL_VER)/
  37. install_bindir:
  38. install -d $(DESTDIR)/bin/
  39. install_libdir:
  40. install -d $(DESTDIR)/lib/sol$(SOL_VER)/
  41. uninstall: uninstall_bin uninstall_lib
  42. uninstall_bin:
  43. rm $(DESTDIR)/bin/sol$(SOL_VER) || true
  44. for fname in $(LINKED_VERS); do rm $(DESTDIR)/bin/$$fname || true; done
  45. uninstall_lib:
  46. rm -r $(DESTDIR)/lib/sol$(SOL_VER)/{programs,tests}
  47. $(LINKED_VERS): sol$(SOL_VER)
  48. rm $@; ln -s $? $@
  49. sol$(SOL_VER): $(OBJ)
  50. $(CC) $(_CFLAGS) $(_LDFLAGS) $^ -o $@
  51. libsol.a: $(OBJ)
  52. $(AR) rcs $@ $^
  53. test: all $(sort $(patsubst tests/%.sol,test_%,$(filter-out tests/_%,$(wildcard tests/*.sol)))) $(sort $(patsubst tests/%.sol,testcomp_%,$(filter-out tests/_%,$(wildcard tests/*.sol))))
  54. test_%: tests/%.sol
  55. ./sol r $?
  56. testcomp_%: tests/%.sol
  57. ./sol rc $? $(STDOUT_FILENAME) | ./sol C
  58. profile: all prof profile-boot $(sort $(patsubst tests/%.sol,profile_%,$(wildcard tests/*.sol))) profilecomp-boot $(sort $(patsubst tests/%.sol,profilecomp_%,$(wildcard tests/*.sol)))
  59. prof:
  60. mkdir prof
  61. profile-boot: programs/test.sol
  62. LLVM_PROFILE_FILE=prof/boot.prof ./sol r $?
  63. profile_%: tests/%.sol
  64. LLVM_PROFILE_FILE=prof/sol.$(basename $(notdir $?)).prof ./sol r $?
  65. profilecomp-boot: programs/test.sol
  66. LLVM_PROFILE_FILE=prof/bootcomp.comp.prof ./sol rc $? $(STDOUT_FILENAME) | LLVM_PROFILE_FILE=prof/bootcomp.run.prof ./sol C
  67. profilecomp_%: tests/%.sol
  68. LLVM_PROFILE_FILE=prof/solcomp.$(basename $(notdir $?)).comp.prof ./sol rc $? $(STDOUT_FILENAME) | LLVM_PROFILE_FILE=prof/solcomp.$(basename $(notdir $?)).run.prof ./sol C
  69. prof/sol.html: profile
  70. llvm-profdata merge -sparse prof/*.prof -o prof/sol.prof.merged
  71. llvm-cov show -instr-profile prof/sol.prof.merged ./sol -format=html > $@
  72. all-profile: prof/sol.html
  73. dsl:
  74. git submodule init && git submodule sync && git submodule update
  75. VERSION_INFO: sol.h
  76. perl -n -e '/#define SOL_VERSION "([[:digit:]]+)\.([[:digit:]]+)(.)([[:digit:]]+)"/ && print "MAJOR:=$$1\nMINOR:=$$2\nRELEASE:=$$3\nPATCH:=$$4\n"' $? > $@
  77. ARCH_INFO: gc.o
  78. $(OBJDUMP) -f $? | perl -n -e '/file format ([^-]+-(.+))$$/ && print "HOST_ARCH:=$$2\nHOST_ELF:=$$1\n"' > $@
  79. %.o: %.c
  80. $(CC) -c -o $@ $? $(_CFLAGS)
  81. %.o: %.txt | ARCH_INFO
  82. $(OBJCOPY) -B i386 -I binary -O $(HOST_ELF) $? $@
  83. %.tab.c %.tab.h: %.y
  84. bison -rall -fall -d $?
  85. lex.yy.c: tokenizer.lex parser.tab.h
  86. flex $<
  87. clean:
  88. rm -f *.o dsl/*.o sol
  89. docs: Doxyfile
  90. doxygen Doxyfile
  91. sphinx-build -b html . ./_build