-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (90 loc) · 3.87 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
include choose_mrbuild.mk
include $(MRBUILD_MK)/Makefile.common.header
PROJECT_NAME := GL_image_display
ABI_VERSION := 0
TAIL_VERSION := 1
LDLIBS += \
-lGLU -lGL -lepoxy -lglut \
-lfreeimage \
-lm \
-pthread
CFLAGS += --std=gnu99
CCXXFLAGS += -Wno-missing-field-initializers -Wno-unused-parameter
################# library ###############
LIB_SOURCES := GL_image_display.c
GL_image_display.o: $(foreach w,image line,$(foreach t,vertex geometry fragment,$w.$t.glsl.h))
%.glsl.h: %.glsl
< $< sed 's/.*/"&\\n"/g' > [email protected] && mv [email protected] $@
EXTRA_CLEAN += *.glsl.h
BIN_SOURCES += \
GL_image_display-test-glut.c
################ FLTK widget library #############
# This is mostly a copy of the library logic in mrbuild. mrbuild currently
# doesn't support more than one DSO per project, so I duplicate that logic here
# for the second library
LIB_SOURCES_FLTK := Fl_Gl_Image_Widget.cc
LIB_OBJECTS_FLTK := $(addsuffix .o,$(basename $(LIB_SOURCES_FLTK)))
LIB_NAME_FLTK = libGL_image_display_fltk
LIB_TARGET_SO_BARE_FLTK = $(LIB_NAME_FLTK).so
LIB_TARGET_SO_ABI_FLTK = $(LIB_TARGET_SO_BARE_FLTK).$(ABI_VERSION)
LIB_TARGET_SO_FULL_FLTK = $(LIB_TARGET_SO_ABI_FLTK).$(TAIL_VERSION)
LIB_TARGET_SO_ALL_FLTK = $(LIB_TARGET_SO_BARE_FLTK) $(LIB_TARGET_SO_ABI_FLTK) $(LIB_TARGET_SO_FULL_FLTK)
$(LIB_OBJECTS_FLTK): CCXXFLAGS += -fPIC
$(LIB_TARGET_SO_FULL_FLTK): LDFLAGS += -shared $(LD_DEFAULT_SYMVER) -fPIC -Wl,-soname,$(notdir $(LIB_TARGET_SO_BARE_FLTK)).$(ABI_VERSION) -Wl,-rpath='$$ORIGIN'$(call get_parentdir_relative_to_childdir,$(abspath .),$(dir $(abspath $@)))
$(LIB_TARGET_SO_BARE_FLTK) $(LIB_TARGET_SO_ABI_FLTK): $(LIB_TARGET_SO_FULL_FLTK)
ln -fs $(notdir $(LIB_TARGET_SO_FULL_FLTK)) $@
$(LIB_TARGET_SO_FULL_FLTK): $(LIB_OBJECTS_FLTK)
$(CC_LINKER) $(LDFLAGS) $(filter %.o, $^) $(filter-out %.o, $^) $(LDLIBS) -o $@
all: $(LIB_TARGET_SO_ALL_FLTK)
install: install_lib_fltk
.PHONY: install_lib_fltk
install_lib_fltk: $(LIB_TARGET_SO_ALL_FLTK)
mkdir -p $(DESTDIR)/$(USRLIB)
cp -P $(LIB_TARGET_SO_FULL_FLTK) $(DESTDIR)/$(USRLIB)
chrpath -d $(DESTDIR)/$(USRLIB)/$(LIB_TARGET_SO_FULL_FLTK)
ln -fs $(notdir $(LIB_TARGET_SO_FULL_FLTK)) $(DESTDIR)/$(USRLIB)/$(notdir $(LIB_TARGET_SO_ABI_FLTK))
ln -fs $(notdir $(LIB_TARGET_SO_FULL_FLTK)) $(DESTDIR)/$(USRLIB)/$(notdir $(LIB_TARGET_SO_BARE_FLTK))
$(LIB_TARGET_SO_FULL_FLTK): lib$(PROJECT_NAME).so
$(LIB_TARGET_SO_FULL_FLTK): LDLIBS += -lfltk_gl -lfltk -lX11
############### FLTK test application ############
BIN_SOURCES += \
GL_image_display-test-fltk.cc
CXXFLAGS_FLTK := $(shell fltk-config --use-images --cxxflags)
CXXFLAGS += $(CXXFLAGS_FLTK)
GL_image_display-test-fltk: $(LIB_TARGET_SO_FULL_FLTK)
GL_image_display-test-fltk: LDLIBS += -lfltk_gl -lfltk -lX11
############### FLTK widget Python wrapper ############
install all: Fl_Gl_Image_Widget.py _Fl_Gl_Image_Widget$(PY_EXT_SUFFIX)
%.py %_pywrap.h %_pywrap.cc: %.i
swig \
-w302 -w312 -w325 -w362 -w389 -w401 -w473 -w509 \
-I/usr/include/ \
-DFL_EXPORT="" \
-DPYTHON \
-DPYTHON3 \
-python \
-c++ \
-keyword \
-shadow \
-fastdispatch \
-outdir . \
-o $*_pywrap.cc \
$<
EXTRA_CLEAN += Fl_Gl_Image_Widget.py *_pywrap.h *_pywrap.cc
Fl_Gl_Image_Widget.py Fl_Gl_Image_Widget_pywrap.cc: Fl_Gl_Image_Widget.hh
Fl_Gl_Image_Widget_pywrap.o: CXXFLAGS += $(PY_MRBUILD_CFLAGS)
_Fl_Gl_Image_Widget$(PY_EXT_SUFFIX): Fl_Gl_Image_Widget_pywrap.o $(LIB_TARGET_SO_FULL_FLTK)
$(PY_MRBUILD_LINKER) $(LDFLAGS) $(PY_MRBUILD_LDFLAGS) -Wl,-rpath=$$ORIGIN/ $^ -o $@
# The python libraries (compiled ones and ones written in python) all live in
# mrcal/
DIST_PY3_MODULES := Fl_Gl_Image_Widget.py _Fl_Gl_Image_Widget$(PY_EXT_SUFFIX)
DIST_INCLUDE := \
Fl_Gl_Image_Widget.hh \
GL_image_display.h
# I don't ship any binaries
DIST_BIN := ""
DIST_DOC := \
GL_image_display-test-fltk.cc \
GL_image_display-test-fltk.py \
GL_image_display-test-glut.c
include $(MRBUILD_MK)/Makefile.common.footer