-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
76 lines (58 loc) · 1.81 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
.SUFFIXES:
UNAME := $(shell uname)
FLTK_CONFIG = local/bin/fltk-config
FLTK_TAR = fltk-1.3.3-source.tar.gz
FLTK_URL = http://fltk.org/pub/fltk/1.3.3/$(FLTK_TAR)
FLTK_DIR = build/fltk-1.3.3
CXX = g++
FLAGS = -g $(shell $(FLTK_CONFIG) --use-gl --cxxflags)
LFLAGS = -g $(shell $(FLTK_CONFIG) --use-gl --ldstaticflags)
SRC = main.cpp VDBWindow.cpp SocketManager.cpp Frame.cpp trackball.cpp GLWindow.cpp
OBJS = $(SRC:.cpp=.o)
EXECUTABLE = vdb
ifeq ($(UNAME), Darwin)
ARCHIVE = vdb-osx
APPLICATION = $(EXECUTABLE).app
else
ARCHIVE = vdb-linux
APPLICATION = $(EXECUTABLE)
endif
.PHONY: all purge clean examples release
all: $(APPLICATION) examples
examples:
make -C examples
build/$(FLTK_TAR):
ifeq ($(UNAME), Darwin)
curl $(FLTK_URL) -o build/$(FLTK_TAR)
else
wget $(FLTK_URL) -O build/$(FLTK_TAR)
endif
$(FLTK_DIR): build/$(FLTK_TAR)
(cd build; tar -xf $(FLTK_TAR))
$(FLTK_CONFIG): $(FLTK_DIR)
(cd $(FLTK_DIR); ./configure --prefix=$(shell pwd)/local; make install)
build/%.o: src/%.cpp $(FLTK_CONFIG)
$(CXX) $(FLAGS) $< -c -o $@
$(EXECUTABLE): $(addprefix build/, $(OBJS))
$(CXX) $^ -o $@ $(LFLAGS)
$(EXECUTABLE).app: $(EXECUTABLE)
mkdir -p $@/Contents/Resources $@/Contents/MacOS
echo APPLnone > $@/Contents/PkgInfo
cp $(EXECUTABLE) $@/Contents/MacOS/$(EXECUTABLE)
cp src/info.plist $@/Contents/info.plist
clean:
make -C examples clean
rm -rf build/*.o build/*.d build/$(ARCHIVE)
rm -rf $(EXECUTABLE) $(ARCHIVE).tar.gz $(APPLICATION)
purge: clean
rm -rf build/* local/*
$(ARCHIVE).tar.gz: $(APPLICATION) vdb.h README.md
mkdir -p build/$(ARCHIVE)
cp -r $^ build/$(ARCHIVE)
(cd build; tar czf ../$@ $(ARCHIVE))
release: $(ARCHIVE).tar.gz
# dependency rules
DEPENDENCIES = $(patsubst %.cpp,build/%.d,$(SRC))
build/%.d: src/%.cpp $(FLTK_CONFIG)
@$(CXX) $(FLAGS) -MM -MT '$@ $(@:.d=.o)' $< -o $@
-include $(DEPENDENCIES)