-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
165 lines (124 loc) · 3.66 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# ------------------------------------------------------------------------------
#
# Command line macros:
#
# INSTALL_TOP ... place to put includes and library files
# LUA_HOME ... where to find lua header and library files
#
# If this is a local build, then you should set the environment variable
# LUA_CPATH to the local directory. On bash, this will work:
#
# export LUA_CPATH="$LUA_CPATH;`pwd`/lib/?.so"
#
# Absolute paths may be used instead, which will be useful if you are doing a
# remote install.
#
# ------------------------------------------------------------------------------
# System-specific things.
# ------------------------------------------------------------------------------
# C compiler icc, gcc, etc if other than system default
# CC = cc
# C++ compiler icpc, g++, etc if other than system default
# CXX = c++
# sometimes only -fpic works
FPIC = -fPIC
# Warning level flags
WARN = -Wall
# robust optimazation level
OPTIM = -O2
# debug flags, use -g for debug symbols
DEBUG =
# location of Lua install on this system
LUA_HOME ?= $(PWD)/lua
# where to install lunum library and include
INSTALL_TOP = $(PWD)
# C Flags
CFLAGS = $(WARN) $(OPTIM) $(DEBUG) $(FPIC)
# Configuration for common platforms. If you need to use a different linker,
# archiver, or C libraries then uncomment the UNAME = Custom line below, and
# edit the custom first block following.
# ------------------------------------------------------------------------------
UNAME = $(shell uname)
#UNAME = Custom
# ------------------------------------------------------------------------------
#
#
ifeq ($(UNAME), Custom)
# common for library links on Linux
CLIBS = -lm -ldl
# command for building shared libraries (this works for most Linux systems)
SO = $(CC) -O -shared
# command for generating static archives
AR = ar rcu
endif
ifeq ($(UNAME), Linux)
SO = $(CC) -O -shared
AR = ar rcu
CLIBS = -lm -ldl
endif
ifeq ($(UNAME), Darwin)
SO = $(CC) -O -bundle -undefined dynamic_lookup
AR = ar rcu
CLIBS =
endif
# -------------------------------------------------
# Ensure these values are passed to child Makefiles
# -------------------------------------------------
export CC
export CXX
export CFLAGS
export LUA_HOME
export SO
export AR
export CLIBS
# -------------------------------------------------
BUILD_TOP = $(shell pwd)
LIB_SO = lunum.so
LIB_A = liblunum.a
export LUNUM_SO = $(BUILD_TOP)/src/$(LIB_SO)
export LUNUM_A = $(BUILD_TOP)/src/$(LIB_A)
INSTALL_SO = $(INSTALL_TOP)/lib/$(LIB_SO)
INSTALL_A = $(INSTALL_TOP)/lib/$(LIB_A)
H1 = lunum.h
H2 = numarray.h
HEADERS = \
$(INSTALL_TOP)/include/$(H1) \
$(INSTALL_TOP)/include/$(H2)
default : $(LUNUM_SO) $(LUNUM_A)
config :
@echo "CC = $(CC)"
@echo "CXX = $(CXX)"
@echo "FPIC = $(FPIC)"
@echo "WARN = $(WARN)"
@echo "OPTIM = $(OPTIM)"
@echo "DEBUG = $(DEBUG)"
@echo "AR = $(AR)"
@echo "SO = $(SO)"
@echo "LUA_HOME = $(LUA_HOME)"
@echo "INSTALL_TOP = $(INSTALL_TOP)"
test : $(LUNUM_SO) $(LUNUM_A)
all : default test
install : $(INSTALL_SO) $(INSTALL_A) $(HEADERS)
$(INSTALL_TOP)/include/$(H1) :
mkdir -p $(INSTALL_TOP)/include
cp src/$(H1) $(INSTALL_TOP)/include
$(INSTALL_TOP)/include/$(H2) :
mkdir -p $(INSTALL_TOP)/include
cp src/$(H2) $(INSTALL_TOP)/include
$(LUNUM_SO) : FORCE
@make -C src $(LUNUM_SO)
$(LUNUM_A) : FORCE
@make -C src $(LUNUM_A)
test : FORCE
@make -C test
$(INSTALL_SO) : $(LUNUM_SO)
mkdir -p $(INSTALL_TOP)/lib
cp $(LUNUM_SO) $(INSTALL_TOP)/lib
$(INSTALL_A) : $(LUNUM_A)
mkdir -p $(INSTALL_TOP)/lib
cp $(LUNUM_A) $(INSTALL_TOP)/lib
clean :
make -C test clean
make -C src clean
rm -rf lib include
FORCE :