-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
62 lines (47 loc) · 1.11 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
CC = gcc
HOST_OS = $(shell uname)
LUA_VERSION = 5.3
ifneq ($(filter FreeBSD%, $(HOST_OS)),)
INC = /usr/local/include
LUA_VERSION_INC = $(subst .,,$(LUA_VERSION))
else
INC = /usr/include
LUA_VERSION_INC = $(LUA_VERSION)
endif
OUTPUT_DIR = out
LUA_INC = -I$(INC)/lua$(LUA_VERSION_INC)
LUA_LIB = -llua$(LUA_VERSION)
ifneq ($(filter CYGWIN% msys% MINGW%, $(HOST_OS)),)
CORE = $(OUTPUT_DIR)/bitarray.dll
LIBFLAG = -shared
LIBS = $(LUA_LIB)
else
ifeq ($(HOST_OS),darwin)
CORE = $(OUTPUT_DIR)/bitarray.so
LIBFLAG = -bundle -undefined dynamic_lookup
CCSHARED = -fno-common
else
CORE = $(OUTPUT_DIR)/bitarray.so
LIBFLAG = -shared
CCSHARED = -fPIC
endif
endif
ifndef CFLAGS
CFLAGS = -Wall -Wextra -Wno-sign-compare -O2 -g -std=c99
endif
CFLAGS += $(CCSHARED) $(LUA_CFLAGS)
LDFLAGS += $(LIBFLAG)
SRC = ext/bitarray.c ext/bitarray_impl.h ext/lualibdefs.h
OBJ = $(OUTPUT_DIR)/bitarray.o
.PHONY : all
all : $(OUTPUT_DIR) $(CORE)
doc : $(SRC)
ldoc .
$(OUTPUT_DIR) :
mkdir -p $@
$(CORE) : $(OBJ)
$(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
$(OBJ) : $(SRC)
$(CC) $(CFLAGS) -c -o $@ $< $(LUA_INC)
clean :
rm -r $(OUTPUT_DIR)