summaryrefslogtreecommitdiff
path: root/Makefile
blob: a4965d285d906315997da67b4ca93d3183a65084 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
PREFIX ?= /usr
CP := cp -r
RM := rm -rf

.PHONY: all
all: lua-5.1-try lua-5.2-try

include findlua.mk

.PHONY: install
install: lua-5.1-try-install lua-5.2-try-install

.PHONY: install-doc
install-doc: doc
	$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/doc/luxio
	$(CP) doc/* $(DESTDIR)$(PREFIX)/share/doc/luxio

.PHONY: doc
doc:
	ldoc .

CFLAGS ?= -O2 -Wall
INSTALL := /usr/bin/install

LUALIBS := $(patsubst %,luxio/%.lua, event simple subprocess)

.PHONY: clean
clean:
	$(RM) *.so *.o luxio_constants.inc luxio-5.1 luxio-5.2 doc

luxio_constants.inc: luxio_constants.inc.in const-proc.lua
	$(LUA_REPL) ./const-proc.lua < $^ > $@

.PHONY: lua-5.1
lua-5.1: luxio-5.1.so luxio-5.1
	ln -s -f luxio-5.1.so luxio.so

LUA_BINDIR ?= $(DESTDIR)$(PREFIX)/bin

.PHONY: lua-5.1-install
lua-5.1-install: INST_LIBDIR ?= $(DESTDIR)$(LUA51_CMOD_INST)
lua-5.1-install: INST_LUADIR ?= $(DESTDIR)$(LUA51_LMOD_INST)
lua-5.1-install: lua-5.1
	$(INSTALL) -d $(INST_LIBDIR)
	$(INSTALL) -m 755 luxio-5.1.so $(INST_LIBDIR)/luxio.so
	$(INSTALL) -d $(INST_LUADIR)/luxio
	$(INSTALL) -m 644 $(LUALIBS) $(INST_LUADIR)/luxio/
	$(INSTALL) -d $(LUA_BINDIR)
	$(INSTALL) luxio-5.1 $(LUA_BINDIR)/luxio-5.1

luxio-5.1.so: luxio-5.1.o
	$(CC) $(LDFLAGS) -shared $(EXTRA_LIBS) -o luxio-5.1.so $^

luxio-5.1: lua-5.1.c luxio-5.1.o
	$(CC) -o luxio-5.1 $(CFLAGS) $(LUA51_INC) lua-5.1.c luxio-5.1.o $(LUA51_LIB) $(LDFLAGS) $(EXTRA_LIBS)

.PHONY: lua-5.2
lua-5.2: luxio-5.2.so luxio-5.2
	ln -s -f luxio-5.2.so luxio.so

.PHONY: lua-5.2-install
lua-5.2-install: INST_LIBDIR ?= $(DESTDIR)$(LUA52_CMOD_INST)
lua-5.2-install: INST_LUADIR ?= $(DESTDIR)$(LUA52_LMOD_INST)
lua-5.2-install: lua-5.2
	$(INSTALL) -d $(INST_LIBDIR)
	$(INSTALL) -m 755 luxio-5.2.so $(INST_LIBDIR)/luxio.so
	$(INSTALL) -d $(INST_LUADIR)/luxio
	$(INSTALL) -m 644 $(LUALIBS) $(INST_LUADIR)/luxio/
	$(INSTALL) -d $(LUA_BINDIR)
	$(INSTALL) luxio-5.2 $(LUA_BINDIR)/luxio-5.2

luxio-5.2.so: luxio-5.2.o
	$(CC) $(LDFLAGS) -shared $(EXTRA_LIBS) -o luxio-5.2.so $^

luxio-5.2: lua-5.2.c luxio-5.2.o
	$(CC) -o luxio-5.2 $(CFLAGS) $(LUA52_INC) lua-5.2.c luxio-5.2.o $(LUA52_LIB) $(LDFLAGS) $(EXTRA_LIBS)

###

luxio-5.1.o: luxio.c luxio_constants.inc
	$(CC) $(CFLAGS) -fPIC $(EXTRA_INC) $(LUA51_INC) -c $< -o $@

luxio-5.2.o: luxio.c luxio_constants.inc
	$(CC) $(CFLAGS) -fPIC $(EXTRA_INC) $(LUA52_INC) -c $< -o $@