Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ##############################################################################
  2. # LuaJIT top level Makefile for installation. Requires GNU Make.
  3. #
  4. # Please read doc/install.html before changing any variables!
  5. #
  6. # Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
  7. # Note: src/Makefile has many more configurable options.
  8. #
  9. # ##### This Makefile is NOT useful for Windows! #####
  10. # For MSVC, please follow the instructions given in src/msvcbuild.bat.
  11. # For MinGW and Cygwin, cd to src and run make with the Makefile there.
  12. #
  13. # Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
  14. ##############################################################################
  15. MAJVER= 2
  16. MINVER= 0
  17. ABIVER= 5.1
  18. # LuaJIT uses rolling releases. The release version is based on the time of
  19. # the latest git commit. The 'git' command must be available during the build.
  20. RELVER= $(shell cat src/luajit_relver.txt 2>/dev/null || : )
  21. # Note: setting it with := doesn't work, since it will change during the build.
  22. MMVERSION= $(MAJVER).$(MINVER)
  23. VERSION= $(MMVERSION).$(RELVER)
  24. ##############################################################################
  25. #
  26. # Change the installation path as needed. This automatically adjusts
  27. # the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path!
  28. #
  29. export PREFIX= /usr/local
  30. export MULTILIB= lib
  31. ##############################################################################
  32. DPREFIX= $(DESTDIR)$(PREFIX)
  33. INSTALL_BIN= $(DPREFIX)/bin
  34. INSTALL_LIB= $(DPREFIX)/$(MULTILIB)
  35. INSTALL_SHARE= $(DPREFIX)/share
  36. INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MMVERSION)
  37. INSTALL_INC= $(INSTALL_DEFINC)
  38. INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(MMVERSION)
  39. INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit
  40. INSTALL_LMODD= $(INSTALL_SHARE)/lua
  41. INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER)
  42. INSTALL_CMODD= $(INSTALL_LIB)/lua
  43. INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER)
  44. INSTALL_MAN= $(INSTALL_SHARE)/man/man1
  45. INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig
  46. INSTALL_TNAME= luajit-$(VERSION)
  47. INSTALL_TSYMNAME= luajit
  48. INSTALL_ANAME= libluajit-$(ABIVER).a
  49. INSTALL_SOSHORT1= libluajit-$(ABIVER).so
  50. INSTALL_SOSHORT2= libluajit-$(ABIVER).so.$(MAJVER)
  51. INSTALL_SONAME= libluajit-$(ABIVER).so.$(VERSION)
  52. INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib
  53. INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib
  54. INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(VERSION).dylib
  55. INSTALL_PCNAME= luajit.pc
  56. INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME)
  57. INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME)
  58. INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_SOSHORT1)
  59. INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_SOSHORT2)
  60. INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME)
  61. INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME)
  62. INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME)
  63. INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \
  64. $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD)
  65. UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \
  66. $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD)
  67. RM= rm -f
  68. MKDIR= mkdir -p
  69. RMDIR= rmdir 2>/dev/null
  70. SYMLINK= ln -sf
  71. INSTALL_X= install -m 0755
  72. INSTALL_F= install -m 0644
  73. UNINSTALL= $(RM)
  74. LDCONFIG= ldconfig -n 2>/dev/null
  75. SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
  76. -e "s|^multilib=.*|multilib=$(MULTILIB)|" \
  77. -e "s|^relver=.*|relver=$(RELVER)|"
  78. ifneq ($(INSTALL_DEFINC),$(INSTALL_INC))
  79. SED_PC+= -e "s|^includedir=.*|includedir=$(INSTALL_INC)|"
  80. endif
  81. FILE_T= luajit
  82. FILE_A= libluajit.a
  83. FILE_SO= libluajit.so
  84. FILE_MAN= luajit.1
  85. FILE_PC= luajit.pc
  86. FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h
  87. FILES_JITLIB= bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua dis_arm.lua \
  88. dis_ppc.lua dis_mips.lua dis_mipsel.lua bcsave.lua vmdef.lua
  89. ifeq (,$(findstring Windows,$(OS)))
  90. HOST_SYS:= $(shell uname -s)
  91. else
  92. HOST_SYS= Windows
  93. endif
  94. TARGET_SYS?= $(HOST_SYS)
  95. ifeq (Darwin,$(TARGET_SYS))
  96. INSTALL_SONAME= $(INSTALL_DYLIBNAME)
  97. INSTALL_SOSHORT1= $(INSTALL_DYLIBSHORT1)
  98. INSTALL_SOSHORT2= $(INSTALL_DYLIBSHORT2)
  99. LDCONFIG= :
  100. endif
  101. ##############################################################################
  102. INSTALL_DEP= src/luajit
  103. default all $(INSTALL_DEP):
  104. @echo "==== Building LuaJIT $(MMVERSION) ===="
  105. $(MAKE) -C src
  106. @echo "==== Successfully built LuaJIT $(MMVERSION) ===="
  107. install: $(INSTALL_DEP)
  108. @echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ===="
  109. $(MKDIR) $(INSTALL_DIRS)
  110. cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T)
  111. cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || :
  112. $(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
  113. cd src && test -f $(FILE_SO) && \
  114. $(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \
  115. ( $(LDCONFIG) $(INSTALL_LIB) || : ) && \
  116. $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \
  117. $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || :
  118. cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN)
  119. cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \
  120. $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \
  121. $(RM) $(FILE_PC).tmp
  122. cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC)
  123. cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB)
  124. $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)
  125. @echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ===="
  126. uninstall:
  127. @echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ===="
  128. $(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
  129. for file in $(FILES_JITLIB); do \
  130. $(UNINSTALL) $(INSTALL_JITLIB)/$$file; \
  131. done
  132. for file in $(FILES_INC); do \
  133. $(UNINSTALL) $(INSTALL_INC)/$$file; \
  134. done
  135. $(LDCONFIG) $(INSTALL_LIB)
  136. $(RMDIR) $(UNINSTALL_DIRS) || :
  137. @echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ===="
  138. ##############################################################################
  139. amalg:
  140. @echo "==== Building LuaJIT $(MMVERSION) (amalgamation) ===="
  141. $(MAKE) -C src amalg
  142. @echo "==== Successfully built LuaJIT $(MMVERSION) (amalgamation) ===="
  143. clean:
  144. $(MAKE) -C src clean
  145. .PHONY: all install amalg clean
  146. ##############################################################################