forked from xlq/lua-subprocess
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
50 lines (39 loc) · 1.17 KB
/
Makefile
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
.POSIX:
INSTALL ?= install
ASCIIDOC ?= asciidoc
SOURCES := subprocess.c liolib-copy.c
VERSION := 0.02
DISTDIR := lua-subprocess-$(VERSION)
DISTFILES := Makefile $(SOURCES) liolib-copy.h subprocess.txt subprocess.html
lua_package := lua
INSTALL_CMOD := $(shell pkg-config --variable=INSTALL_CMOD $(lua_package))
ifeq ($(INSTALL_CMOD),)
lua_package := lua5.1
INSTALL_CMOD := $(shell pkg-config --variable=INSTALL_CMOD $(lua_package))
endif
ifeq ($(INSTALL_CMOD),)
$(error Lua package not found)
endif
CFLAGS ?= -Wall -Wextra -pedantic -O2
LUA_CFLAGS := $(shell pkg-config --cflags --libs $(lua_package))
.PHONY: all
all: subprocess.so subprocess.html
subprocess.so: $(SOURCES)
$(CC) $(CFLAGS) $(LUA_CFLAGS) -DOS_POSIX -shared -fPIC -o $@ $(SOURCES)
subprocess.html: subprocess.txt
$(ASCIIDOC) $<
.PHONY: clean
clean:
$(RM) subprocess.so
.PHONY: install
install: subprocess.so
mkdir -p $(DESTDIR)$(INSTALL_CMOD)/
$(INSTALL) -m755 subprocess.so $(DESTDIR)$(INSTALL_CMOD)/
.PHONY: uninstall
uninstall:
$(RM) $(INSTALL_CMOD)/subprocess.so
.PHONY: dist
dist: $(DISTFILES)
[ -d $(DISTDIR) ] || mkdir $(DISTDIR)
$(INSTALL) -m644 $(DISTFILES) $(DISTDIR)/
tar -czf $(DISTDIR).tar.gz $(DISTDIR)