Merge pull request #7 from u3shit/api-fixes
[ljx.git] / Makefile
blob25c80a11990b37d35376bb9a408b07014dc4ec69
1 ##############################################################################
2 # LuaJIT top level Makefile for installation. Requires GNU Make.
4 # Please read doc/install.html before changing any variables!
6 # Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
7 # Note: src/Makefile has many more configurable options.
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.
13 # Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
14 ##############################################################################
16 ABIVER=5.3
17 APIVER=5.3
18 NODOTABIVER:=$(subst .,,$(ABIVER))
19 VERSION= $(shell git describe 2> /dev/null || cat .version)
21 ##############################################################################
23 # Change the installation path as needed. This automatically adjusts
24 # the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path!
26 export PREFIX= /usr/local
27 export MULTILIB= lib
28 ##############################################################################
30 DPREFIX= $(DESTDIR)$(PREFIX)
31 INSTALL_BIN= $(DPREFIX)/bin
32 INSTALL_LIB= $(DPREFIX)/$(MULTILIB)
33 INSTALL_SHARE= $(DPREFIX)/share
34 INSTALL_INC= $(DPREFIX)/include/ljx-$(ABIVER)
36 INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION)
37 INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit
38 INSTALL_LMODD= $(INSTALL_SHARE)/lua
39 INSTALL_LMOD= $(INSTALL_LMODD)/$(APIVER)
40 INSTALL_CMODD= $(INSTALL_LIB)/lua
41 INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER)
42 INSTALL_MAN_DIR= $(INSTALL_SHARE)/man/man1
43 INSTALL_MAN= $(INSTALL_MAN_DIR)/luajit-ljx.1
44 INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig
46 INSTALL_TNAME= ljx
47 INSTALL_TSYMNAME= luajit
48 INSTALL_ANAME= libluajit-ljx-$(ABIVER).a
49 INSTALL_SONAME= libluajit-ljx-$(ABIVER).so.$(VERSION)
50 INSTALL_SOSHORT1= libluajit-ljx-$(ABIVER).so
51 INSTALL_SOSHORT2= libluajit-ljx-$(ABIVER).so.$(VERSION)
52 INSTALL_DYLIBNAME= libluajit-ljx-$(ABIVER).$(VERSION).dylib
53 INSTALL_DYLIBSHORT1= libluajit-ljx-$(ABIVER).dylib
54 INSTALL_DYLIBSHORT2= libluajit-ljx-$(ABIVER).LJX.dylib
55 INSTALL_PCNAME= luajit-ljx.pc
57 INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME)
58 INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME)
59 INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_SOSHORT1)
60 INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_SOSHORT2)
61 INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME)
62 INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME)
63 INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME)
65 INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN_DIR) \
66 $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD)
67 UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \
68 $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD)
70 RM= rm -f
71 MKDIR= mkdir -p
72 RMDIR= rmdir 2>/dev/null
73 SYMLINK= ln -sf
74 INSTALL_X= install -m 0755
75 INSTALL_F= install -m 0644
76 UNINSTALL= $(RM)
77 LDCONFIG= ldconfig -n
78 SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
79 -e "s|^multilib=.*|multilib=$(MULTILIB)|" \
80 -e "s|^abiver=.*|abiver=$(ABIVER)|" \
81 -e "s|^version=.*|version=$(VERSION)|"
83 FILE_T= luajit-ljx
84 FILE_A= libluajit-ljx.a
85 FILE_SO= libluajit-ljx.so
86 FILE_MAN= luajit.1
87 FILE_PC= luajit.pc
88 FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h
89 ARCH_INC= lj_arch.h
90 FILES_JITLIB= bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua \
91 dis_x86.lua dis_x64.lua dis_arm.lua dis_ppc.lua \
92 dis_mips.lua dis_mipsel.lua vmdef.lua
94 ifeq (Darwin,$(shell uname -s))
95 INSTALL_SONAME= $(INSTALL_DYLIBNAME)
96 INSTALL_SOSHORT1= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT1)
97 INSTALL_SOSHORT2= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT2)
98 LDCONFIG= :
99 endif
100 ifneq (,$(findstring MSYS,$(shell uname -s)))
101 FILE_SO=lua$(NODOTABIVER).dll
102 INSTALL_SONAME=$(FILE_SO)
103 INSTALL_TNAME= ljx.exe
104 INSTALL_TSYMNAME= luajit.exe
105 INSTALL_SOSHORT1= libluajit-ljx-$(ABIVER).dll
106 INSTALL_SOSHORT2= libluajit-ljx-$(ABIVER).$(VERSION).dll
107 FILE_T=luajit.exe
108 LDCONFIG= :
109 endif
111 ##############################################################################
113 INSTALL_DEP= src/luajit
115 default all $(INSTALL_DEP):
116 @echo "==== Building LuaJIT/$(VERSION) ===="
117 $(MAKE) -C src ABIVER=$(ABIVER) APIVER=$(APIVER)
118 @echo "==== Successfully built LuaJIT/$(VERSION), ABI: $(ABIVER), API: $(APIVER) ===="
120 install: $(INSTALL_DEP)
121 @echo "==== Installing LuaJIT/$(VERSION) to $(PREFIX) ===="
122 $(MKDIR) $(INSTALL_DIRS)
123 cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T)
124 cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || :
125 $(RM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
126 cd src && test -f $(FILE_SO) && \
127 $(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \
128 $(LDCONFIG) $(INSTALL_LIB) && \
129 $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \
130 $(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || :
131 cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN)
132 cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \
133 $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \
134 $(RM) $(FILE_PC).tmp
135 cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC)
136 cd src && $(INSTALL_F) $(ARCH_INC).dist $(INSTALL_INC)/$(ARCH_INC)
137 cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB)
138 @echo "==== Successfully installed LuaJIT/$(VERSION) to $(PREFIX) ===="
139 @echo ""
140 @echo "Note: the development releases deliberately do NOT install a symlink for luajit"
141 @echo "You can do this now by running this command (with sudo):"
142 @echo ""
143 @echo " $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)"
144 @echo ""
147 uninstall:
148 @echo "==== Uninstalling LuaJIT/$(VERSION) from $(PREFIX) ===="
149 $(UNINSTALL) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
150 for file in $(FILES_JITLIB); do \
151 $(UNINSTALL) $(INSTALL_JITLIB)/$$file; \
152 done
153 for file in $(FILES_INC); do \
154 $(UNINSTALL) $(INSTALL_INC)/$$file; \
155 done
156 $(LDCONFIG) $(INSTALL_LIB)
157 $(RMDIR) $(UNINSTALL_DIRS) || :
158 @echo "==== Successfully uninstalled LuaJIT/$(VERSION) from $(PREFIX) ===="
160 ##############################################################################
162 amalg:
163 @echo "Building LuaJIT/$(VERSION)"
164 $(MAKE) -C src amalg
166 clean:
167 $(MAKE) -C src clean
169 .PHONY: all install amalg clean
171 ##############################################################################