-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
executable file
·79 lines (53 loc) · 1.62 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
# simple unified Makefile for mxToolKit
LIB_NAME = libmxtk
CXX ?= g++
PREFIX ?= /usr/local
CFLAGS += -O3 -pipe -DNDEBUG
CXXFLAGS =
SYS = $(shell $(CXX) -dumpmachine)
ifneq (, $(findstring mingw, $(SYS)))
PLATFORM = win32
STATIC_LIB_EXT = lib
SHARED_LIB_EXT = dll
LIBS = -lshlwapi -lcomctl32 -lcomdlg32 -lgdi32 -lopengl32 -lwinmm -static-libgcc -static-libstdc++
else
CFLAGS += -fPIC
PLATFORM = qt
STATIC_LIB_EXT = a
SHARED_LIB_EXT = so
MOC ?= moc-qt5
MOC_HEADERS = $(wildcard src/$(PLATFORM)/*_i.h)
MOC_PREFIX = $(subst $(PLATFORM)/,$(PLATFORM)/moc_,$(MOC_HEADERS))
MOC_SRC = $(MOC_PREFIX:%_i.h=%.cpp)
MOC_OBJS = $(MOC_SRC:%.cpp=%.o)
INCLUDE = $(shell pkg-config --cflags Qt5OpenGL gl)
LIBS = $(shell pkg-config --libs Qt5OpenGL gl)
endif
SRC = $(wildcard src/$(PLATFORM)/*.cpp) $(wildcard src/common/*.cpp)
OBJS = $(SRC:%.cpp=%.o)
INCLUDE += -Iinclude -Isrc/$(PLATFORM)
LDFLAGS += -shared
DEST_LIB = $(PREFIX)/lib
DEST_INC = $(PREFIX)/include
STATIC_LIB = lib/$(LIB_NAME)-$(PLATFORM).$(STATIC_LIB_EXT)
SHARED_LIB = lib/$(LIB_NAME)-$(PLATFORM).$(SHARED_LIB_EXT)
all: $(STATIC_LIB) $(SHARED_LIB)
$(STATIC_LIB): $(OBJS) $(MOC_OBJS)
ar rcs $(STATIC_LIB) $(OBJS) $(MOC_OBJS)
$(SHARED_LIB): $(OBJS) $(MOC_OBJS)
$(CXX) $(OBJS) $(MOC_OBJS) $(LDFLAGS) $(LIBS) -o $(SHARED_LIB)
#ifeq (, $(findstring mingw, $(SYS)))
moc_%.cpp: %_i.h
$(MOC) $< -o $@
#endif
.cpp.o:
$(CXX) $(CFLAGS) $(CPPFLAGS) $(INCLUDE) -c $< -o $@
.PHONY: all clean install
# clean
clean:
$(RM) $(OBJS) $(MOC_OBJS)
# install
install:
install -m 644 $(STATIC_LIB) $(DEST_LIB)
install -m 644 $(SHARED_LIB) $(DEST_LIB)
install -m 644 -D ../../include/mx/* $(DEST_INC)/mx