-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathMakefile
62 lines (45 loc) · 1.57 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
51
52
53
54
55
56
57
58
59
60
61
62
# This Makefile is based on LuaSec's Makefile. Thanks to the LuaSec developers.
# Inform the location to install the modules
LUAPATH ?= /usr/share/lua/5.1
LUACPATH ?= /usr/lib/lua/5.1
INCDIR ?= -I/usr/include/lua5.1
LIBDIR ?= -L/usr/lib
# For Mac OS X: set the system version
MACOSX_VERSION = 10.4
CMOD = zlib.so
OBJS = lua_zlib.o
LIBS = -lz -llua -lm
WARN = -Wall -pedantic
BSD_CFLAGS = -O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
BSD_LDFLAGS = -O -shared -fPIC $(LIBDIR)
LNX_CFLAGS = -O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
LNX_LDFLAGS = -O -shared -fPIC $(LIBDIR)
MAC_ENV = env MACOSX_DEPLOYMENT_TARGET='$(MACVER)'
MAC_CFLAGS = -O2 -fPIC -fno-common $(WARN) $(INCDIR) $(DEFS)
MAC_LDFLAGS = -bundle -undefined dynamic_lookup -fPIC $(LIBDIR)
CC = gcc
LD = $(MYENV) gcc
CFLAGS = $(MYCFLAGS)
LDFLAGS = $(MYLDFLAGS)
.PHONY: all clean install none linux bsd macosx
all:
@echo "Usage: $(MAKE) <platform>"
@echo " * linux"
@echo " * bsd"
@echo " * macosx"
install: $(CMOD)
cp $(CMOD) $(LUACPATH)
uninstall:
rm $(LUACPATH)/zlib.so
linux:
@$(MAKE) $(CMOD) MYCFLAGS="$(LNX_CFLAGS)" MYLDFLAGS="$(LNX_LDFLAGS)" INCDIR="$(INCDIR)" LIBDIR="$(LIBDIR)" DEFS="$(DEFS)"
bsd:
@$(MAKE) $(CMOD) MYCFLAGS="$(BSD_CFLAGS)" MYLDFLAGS="$(BSD_LDFLAGS)" INCDIR="$(INCDIR)" LIBDIR="$(LIBDIR)" DEFS="$(DEFS)"
macosx:
@$(MAKE) $(CMOD) MYCFLAGS="$(MAC_CFLAGS)" MYLDFLAGS="$(MAC_LDFLAGS)" MYENV="$(MAC_ENV)" INCDIR="$(INCDIR)" LIBDIR="$(LIBDIR)" DEFS="$(DEFS)"
clean:
rm -f $(OBJS) $(CMOD)
.c.o:
$(CC) -c $(CFLAGS) $(DEFS) $(INCDIR) -o $@ $<
$(CMOD): $(OBJS)
$(LD) $(LDFLAGS) $(LIBDIR) $(OBJS) $(LIBS) -o $@