forked from edartuz/lua-time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (66 loc) · 1.79 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
MAIN := ul_time
DIR_SRC := ./src
DIR_BUILD := ./build
ifndef COMSPEC
# posix
DIR_SEP := :
LIBEXT := .so
LBITS := $(shell getconf LONG_BIT)
LIBS := -llua
ifeq ($(OSTYPE), darwin)
# mac os
LFLAGS := -bundle -undefined dynamic_lookup
ifeq ($(LBITS),64)
SYSTEM := mac64
else
SYSTEM := mac32
endif
else
# linux/bsd
ifeq ($(LBITS),64)
SYSTEM := lin64
else
SYSTEM := lin32
endif
CFLAGS_SHARED := -fPIC
LFLAGS := -shared
endif
else
# windows
ifeq ($(PROCESSOR_ARCHITECTURE), AMD64)
ifndef CC_PREFIX
CC_PREFIX := amd64-mingw32msvc-
endif
SYSTEM := win64
else
ifndef CC_PREFIX
CC_PREFIX := i586-mingw32msvc-
endif
SYSTEM := win32
endif
DIR_SEP := ;
LIBEXT := .dll
EXEEXT := .exe
LIBS := -llua
LFLAGS := -shared
endif
INCLUDE_DIRS := $(INCLUDE_DIRS) -I../lua/src -I$(LUA_HOME)/src
LIB_DIRS := $(LIB_DIRS) -L../lua/build/$(SYSTEM) -L$(LUA_HOME)/bin
DIR_BUILD_ARCH := ./build/$(SYSTEM)
CC := $(CC_PREFIX)gcc
AR := $(CC_PREFIX)ar
RM := rm -f
CFLAGS := $(CFLAGS) -std=gnu99 -Os -g $(INCLUDE_DIRS) -ffunction-sections -fdata-sections
LFLAGS := $(LFLAGS) $(LIB_DIRS)
WFLAGS := $(WFLAGS) -Wall
build: static shared
static:
$(CC) -c $(CFLAGS) $(WFLAGS) -o $(DIR_BUILD_ARCH)/$(MAIN).o $(DIR_SRC)/$(MAIN).c
$(AR) rv $(DIR_BUILD_ARCH)/lib$(MAIN).a $(DIR_BUILD_ARCH)/$(MAIN).o
$(RM) $(DIR_BUILD_ARCH)/$(MAIN).o
shared:
$(CC) -c $(CFLAGS_SHARED) $(CFLAGS) $(WFLAGS) -o $(DIR_BUILD_ARCH)/$(MAIN).o $(DIR_SRC)/$(MAIN).c
$(CC) $(LFLAGS) $(WFLAGS) -o $(DIR_BUILD_ARCH)/$(MAIN)$(LIBEXT) $(DIR_BUILD_ARCH)/$(MAIN).o $(LIBS)
$(RM) $(DIR_BUILD_ARCH)/$(MAIN).o
clean:
$(RM) $(DIR_BUILD_ARCH)/*.o $(DIR_BUILD_ARCH)/*.a $(DIR_BUILD_ARCH)/*.so $(DIR_BUILD_ARCH)/*.dll