-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
140 lines (110 loc) · 3.33 KB
/
Makefile
File metadata and controls
140 lines (110 loc) · 3.33 KB
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
# Package : libhex
# Makefile Created : 2007/10/13
# Author : Alex Tingle
#
# Copyright (C) 2007-2008, Alex Tingle.
#
# This file is part of the libhex application.
#
# libhex is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# libhex is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
CPPFLAGS += \
-I$(PYINC) \
CXXFLAGS += \
-Wall \
-fno-strict-aliasing \
-fPIC \
DEBUG := 1
VERSION_MAJOR := 0
VERSION_MINOR := 1
OBJDIR := $(BUILDDIR)OBJ
CCFILES := \
algorithm.cc \
area.cc \
boundary.cc \
boundingbox.cc \
direction.cc \
edge.cc \
grid.cc \
hex.cc \
move.cc \
path.cc \
svg.cc \
OFILES := $(addprefix $(OBJDIR)/,$(CCFILES:.cc=.o))
DEPFILES := $(addprefix $(OBJDIR)/,$(CCFILES:.cc=.dep))
OBJDIRS := $(sort $(dir $(OFILES) $(DEPFILES)))
ifeq ($(DEBUG),1)
CXXFLAGS += -g
else
CXXFLAGS += -O2
endif
LDFLAGS += $(CXXFLAGS)
# Use python -V to automatically detect the python version
PYVER := $(shell python -V 2>&1 | sed 's/.* \([1-9][.][0-9]\).*/\1/')
PYINC := /usr/include/python$(PYVER)
# Use uname to automatically detect Mac builds.
PLATFORM := $(shell uname -a | sed 's/.*Darwin.*/mac/')
ifeq ($(PLATFORM),mac)
SOEXT := .dylib
# Build a shared object library: Use as $(call MakeSharedLib,OBJECTS,SONAME)
MakeSharedLib = \
MACOSX_DEPLOYMENT_TARGET=10.3 \
g++ -dynamiclib -undefined dynamic_lookup $(LDFLAGS) -o $(2) $(1)
else
SOEXT= .so
# Build a shared object library: Use as $(call MakeSharedLib,OBJECTS,SONAME)
MakeSharedLib = g++ -shared $(LDFLAGS) -o $(2) $(1)
endif
.PHONY: all
all: lib solib pylib test README
$(OBJDIR)/%.dep: %.cc | $(dir $(OBJDIR)/%)
g++ -MM $(CPPFLAGS) $< -o $@ -MT $@
$(OBJDIR)/%.o: %.cc $(OBJDIR)/%.dep
g++ -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
ifneq "$(MAKECMDGOALS)" "clean"
-include $(DEPFILES)
endif
# Make object directories
$(OBJDIRS):
mkdir -p $@
hex_wrap.cc: hex.i $(wildcard *.h)
swig -o $@ -classic -c++ -python $<
.PHONY: lib
lib: libhex.a
libhex.a: $(OFILES)
ar rus $@ $^
.PHONY: solib
solib: libhex$(SOEXT)
libhex$(SOEXT): $(OFILES)
$(call MakeSharedLib,$^,$@)
.PHONY: pylib
pylib: _hex.so
_hex.so: $(OBJDIR)/hex_wrap.o $(OFILES)
$(call MakeSharedLib,$^ $(LIBS),$@)
test: $(OBJDIR)/test.o libhex$(SOEXT)
g++ $(LDFLAGS) $< $(LIBS) -o $@ -L. -lhex
.PHONY: install
install: libhex$(SOEXT)
install libhex$(SOEXT) /usr/local/lib
install hex.h hexsvg.h hexmove.h /usr/local/include
.PHONY: clean
clean:
rm -rf $(OBJDIR) *$(SOEXT) *.a test hex_wrap.cc hex.py *.pyc
README: hex.h
sed -n -e '/\/\*\* *@mainpage/,/\*\//p' $< \
| sed -e 's%^[/* ]*\(@mainpage \)\?%%' > $@
# Eliminate all default rules.
.SUFFIXES:
# Don't leave half-finished targets lying around.
.DELETE_ON_ERROR: