rules.mak 2.54 KB
Newer Older
1
# Lua 5.1
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
2

3
LUA_VERSION := 5.1.4
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
4 5 6 7 8 9 10 11 12 13 14 15 16
LUA_URL := http://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz

# Reverse priority order
LUA_TARGET := generic
ifdef HAVE_BSD
LUA_TARGET := bsd
endif
ifdef HAVE_LINUX
LUA_TARGET := linux
endif
ifdef HAVE_MACOSX
LUA_TARGET := macosx
endif
17 18 19
ifdef HAVE_IOS
LUA_TARGET := ios
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
20 21 22
ifdef HAVE_WIN32
LUA_TARGET := mingw
endif
23 24 25
ifdef HAVE_SOLARIS
LUA_TARGET := solaris
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
26 27

# Feel free to add autodetection if you need to...
28
PKGS += lua luac
29
PKGS_ALL += luac
30
ifeq ($(call need_pkg,"lua5.2"),)
31
PKGS_FOUND += lua luac
32
endif
33
ifeq ($(call need_pkg,"lua5.1"),)
34
PKGS_FOUND += lua luac
35
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
36 37

$(TARBALLS)/lua-$(LUA_VERSION).tar.gz:
38
	$(call download_pkg,$(LUA_URL),lua)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
39

40
.sum-lua: lua-$(LUA_VERSION).tar.gz
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
41

42
lua: lua-$(LUA_VERSION).tar.gz .sum-lua
43
	$(UNPACK)
44
	$(APPLY) $(SRC)/lua/lua-noreadline.patch
45
	$(APPLY) $(SRC)/lua/no-dylibs.patch
46
	$(APPLY) $(SRC)/lua/luac-32bits.patch
47
	$(APPLY) $(SRC)/lua/no-localeconv.patch
48
	$(APPLY) $(SRC)/lua/lua-ios-support.patch
49
	$(APPLY) $(SRC)/lua/implib.patch
50 51 52
ifdef HAVE_WINSTORE
	$(APPLY) $(SRC)/lua/lua-winrt.patch
endif
53
ifdef HAVE_DARWIN_OS
54
	(cd $(UNPACK_DIR) && \
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
55 56 57 58
	sed -e 's%gcc%$(CC)%' \
		-e 's%LDFLAGS=%LDFLAGS=$(EXTRA_CFLAGS) $(EXTRA_LDFLAGS)%' \
		-i.orig src/Makefile)
endif
59 60 61 62 63
ifdef HAVE_SOLARIS
	(cd $(UNPACK_DIR) && \
	sed -e 's%LIBS="-ldl"$$%LIBS="-ldl" MYLDFLAGS="$(EXTRA_LDFLAGS)"%' \
		-i.orig src/Makefile)
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
64
ifdef HAVE_WIN32
65
	cd $(UNPACK_DIR) && sed -i.orig -e 's/lua luac/lua.exe luac.exe/' Makefile
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
66
endif
67
	cd $(UNPACK_DIR)/src && sed -i.orig \
68 69 70
		-e 's%CC=%#CC=%' \
		-e 's%= *strip%=$(STRIP)%' \
		-e 's%= *ranlib%= $(RANLIB)%' \
71
		-e 's%= *ar%= $(AR)%' \
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
72
		Makefile
73
	$(MOVE)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
74 75

.lua: lua
76
	cd $< && $(HOSTVARS_PIC) $(MAKE) $(LUA_TARGET)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
77
ifdef HAVE_WIN32
78
	cd $< && $(HOSTVARS) $(MAKE) -C src liblua.a
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
79 80 81 82
endif
	cd $< && $(HOSTVARS) $(MAKE) install INSTALL_TOP="$(PREFIX)"
ifdef HAVE_WIN32
	cd $< && $(RANLIB) "$(PREFIX)/lib/liblua.a"
83 84
	mkdir -p -- "$(PREFIX)/lib/pkgconfig"
	cp $</etc/lua.pc "$(PREFIX)/lib/pkgconfig/"
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
85 86
endif
	touch $@
87

88 89 90
.sum-luac: .sum-lua
	touch $@

91
ifdef HAVE_WIN32
92
ifndef HAVE_CROSS_COMPILE
93 94
LUACVARS=CPPFLAGS="-DLUA_DL_DLL"
endif
95
endif
96

97
luac: lua-$(LUA_VERSION).tar.gz .sum-luac
98 99 100 101 102 103 104 105
	# DO NOT use the same intermediate directory as the lua target
	rm -Rf -- $@-$(LUA_VERSION) $@
	mkdir -- $@-$(LUA_VERSION)
	tar -x -v -z -C $@-$(LUA_VERSION) --strip-components=1 -f $<
	(cd luac-$(LUA_VERSION) && patch -p1) < $(SRC)/lua/luac-32bits.patch
	mv luac-$(LUA_VERSION) luac

.luac: luac
106
	cd $< && $(LUACVARS) $(MAKE) generic
107
	mkdir -p -- $(BUILDBINDIR)
108
	install -m 0755 -s -- $</src/luac $(BUILDBINDIR)/$(HOST)-luac
109
	touch $@