-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
151 lines (123 loc) · 5.36 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
TARGET = gw
.PHONY: default all debug clean
default: $(TARGET)
all: default
debug: default
# set system
PLATFORM=
ifeq ($(OS),Windows_NT) # assume we are using msys2-ucrt64 env
PLATFORM = "Windows"
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PLATFORM = "Linux"
else ifeq ($(UNAME_S),Darwin)
ifeq ($(shell uname -m), arm64)
PLATFORM = "Arm64"
else
PLATFORM = "Darwin"
endif
endif
endif
# try and add conda environment
ifdef CONDA_PREFIX
CPPFLAGS += -I$(CONDA_PREFIX)/include
LDFLAGS += -L$(CONDA_PREFIX)/lib
endif
# Options to use target htslib or skia
ifdef HTSLIB
CPPFLAGS += -I$(HTSLIB)
LDFLAGS += -L$(HTSLIB)
endif
SKIA ?= ""
ifneq ($(PLATFORM), "Windows")
ifneq ($(SKIA),"")
CPPFLAGS += -I$(SKIA)
LDFLAGS += -L $(wildcard $(SKIA)/out/Rel*)
else ifeq ($(PLATFORM),"Darwin")
CPPFLAGS += -I./lib/skia
LDFLAGS += -L./lib/skia/out/Release-x64
else ifeq ($(PLATFORM),"Arm64")
CPPFLAGS += -I./lib/skia
LDFLAGS += -L./lib/skia/out/Release-arm64
else
CPPFLAGS += -I./lib/skia
LDFLAGS += -L./lib/skia/out/Release-x64
endif
endif
SKIA_LINK=""
USE_GL ?= "" # Else use EGL backend for Linux only
prep:
@if [ "$(PLATFORM)" = "Darwin" ]; then \
SKIA_LINK=""; \
echo "Downloading pre-built skia for MacOS-Intel"; mkdir -p lib/skia; \
cd lib/skia && wget -O skia.zip "https://github.com/JetBrains/skia-build/releases/download/m93-87e8842e8c/Skia-m93-87e8842e8c-macos-Release-x64.zip" && unzip -o skia.zip && rm skia.zip && cd ../../; \
elif [ "$(PLATFORM)" = "Arm64" ]; then \
echo "Downloading pre-built skia for MacOS-Arm64"; mkdir -p lib/skia; \
cd lib/skia && wget -O skia.tar.gz "https://github.com/kcleal/skia_build_arm64/releases/download/v0.0.1/skia.zip" && tar -xvf skia.tar.gz && rm skia.tar.gz && cd ../../; \
elif [ "$(PLATFORM)" = "Linux" ] && [ "$(USE_GL)" = "1" ]; then \
echo "Downloading pre-built skia for Linux with GL"; mkdir -p lib/skia; \
cd lib/skia && wget -O skia.zip "https://github.com/JetBrains/skia-build/releases/download/m93-87e8842e8c/Skia-m93-87e8842e8c-linux-Release-x64.zip" && unzip -o skia.zip && rm skia.zip && cd ../../; \
elif [ "$(PLATFORM)" = "Linux" ]; then \
echo "Downloading pre-built skia for Linux with EGL"; mkdir -p lib/skia; \
cd lib/skia && wget -O skia.tar.gz "https://github.com/kcleal/skia_build_arm64/releases/download/v0.0.1/skia-m93-linux-Release-x64.tar.gz" && tar -xvf skia.tar.gz && rm skia.tar.gz && cd ../../; \
fi
CXXFLAGS += -Wall -std=c++17 -fno-common -fwrapv -fno-omit-frame-pointer -O3 -DNDEBUG
CPPFLAGS += -I./lib/libBigWig -I./include -I./src -I.
LDLIBS += -lskia -lm -ljpeg -lpng -lsvg -lhts -lfontconfig -lpthread
# set platform flags and libs
ifeq ($(PLATFORM),"Linux")
ifeq (${XDG_SESSION_TYPE},"wayland") # wayland is untested!
LDLIBS += -lwayland-client
else
LDLIBS += -lX11
endif
CPPFLAGS += -I/usr/local/include
CXXFLAGS += -D LINUX -D __STDC_FORMAT_MACROS
LDFLAGS += -L/usr/local/lib
# If installed from conda, glfw3 is named glfw, therefore if glfw3 is installed by another means use this:
# LDLIBS += -lGL -lfreetype -lfontconfig -luuid -lzlib -licu -ldl $(shell pkg-config --static --libs x11 xrandr xi xxf86vm glfw3)
# LDLIBS += -lEGL -lGLESv2 -lfreetype -lfontconfig -luuid -lz -lcurl -licu -ldl -lglfw #$(shell pkg-config --static --libs x11 xrandr xi xxf86vm glfw3)
# LDLIBS += -lGL -lfreetype -lfontconfig -luuid -lz -lcurl -licu -ldl -lglfw
ifeq ($(USE_GL),"1")
LDLIBS += -lGL
else
LDLIBS += -lEGL -lGLESv2
endif
LDLIBS += -lfreetype -lfontconfig -luuid -lz -lcurl -licu -ldl -lglfw
else ifeq ($(PLATFORM),"Darwin")
CPPFLAGS += -I/usr/local/include
CXXFLAGS += -D OSX -stdlib=libc++ -arch x86_64 -fvisibility=hidden -mmacosx-version-min=10.15 -Wno-deprecated-declarations
LDFLAGS += -undefined dynamic_lookup -framework OpenGL -framework AppKit -framework ApplicationServices -mmacosx-version-min=10.15 -L/usr/local/lib
LDLIBS += -lglfw -lzlib -lcurl -licu -ldl
else ifeq ($(PLATFORM),"Arm64")
CPPFLAGS += -I/usr/local/include
CXXFLAGS += -D OSX -stdlib=libc++ -arch arm64 -fvisibility=hidden -mmacosx-version-min=10.15 -Wno-deprecated-declarations
LDFLAGS += -undefined dynamic_lookup -framework OpenGL -framework AppKit -framework ApplicationServices -mmacosx-version-min=10.15 -L/usr/local/lib
LDLIBS += -lglfw -lzlib -lcurl -licu -ldl
else ifeq ($(PLATFORM),"Windows")
CXXFLAGS += -D WIN32
CPPFLAGS += $(shell pkgconf -cflags skia) $(shell ncursesw6-config --cflags)
LDLIBS += $(shell pkgconf -libs skia)
LDLIBS += -lharfbuzz-subset -lglfw3 -lcurl
endif
OBJECTS = $(patsubst %.cpp, %.o, $(wildcard ./src/*.cpp))
OBJECTS += $(patsubst %.c, %.o, $(wildcard ./lib/libBigWig/*.c))
debug: CXXFLAGS += -g
debug: LDFLAGS += -fsanitize=address -fsanitize=undefined
$(TARGET): $(OBJECTS)
$(CXX) -g $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
clean:
-rm -f *.o ./src/*.o ./src/*.o.tmp ./lib/libBigWig/*.o
-rm -f $(TARGET)
-rm -rf libgw
SHARED_TARGET = libgw/libgw.so
ifeq ($(PLATFORM),"Darwin")
SHARED_TARGET = libgw/libgw.dylib
endif
shared: CXXFLAGS += -fPIC
shared: $(OBJECTS)
-mkdir -p libgw/include
-cp src/*.h libgw/include
-cp include/*.h libgw/include
$(CXX) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -shared -o $(SHARED_TARGET)