]> git.decadent.org.uk Git - videolink.git/blob - Makefile
Only strip at installation time if NDEBUG is defined - closes: #438252
[videolink.git] / Makefile
1 prefix := /usr/local
2
3 bindir := $(prefix)/bin
4 sharedir := $(prefix)/share
5 docdir := $(sharedir)/doc
6 mandir := $(sharedir)/man
7
8 ifeq ($(shell pkg-config --atleast-version 1.9 mozilla-gtkmozembed-embedding && echo yes),yes)
9     moz_name := xulrunner-1.9
10     moz_pc := mozilla-gtkmozembed-embedding
11     moz_cppflags_extra := $(shell pkg-config --cflags xulrunner-nspr)
12     moz_unstable_cppflags_extra :=
13     moz_ldflags_extra :=
14 else
15     ifeq ($(shell pkg-config --exists xulrunner-gtkmozembed && echo yes),yes)
16     moz_name := xulrunner
17     moz_pc := xulrunner-gtkmozembed
18     else
19     moz_name := mozilla
20     moz_pc := mozilla-gtkmozembed
21     endif
22     moz_unstable_cppflags_extra = \
23         $(addprefix -I$(moz_include_dir)/, \
24           content docshell dom gfx imglib2 layout locale necko uconv webshell widget) \
25         -DMOZILLA_INTERNAL_API
26     moz_ldflags_extra = -Wl,-rpath,$(moz_lib_dir)
27 endif
28
29 moz_prefix := $(shell pkg-config --variable=prefix $(moz_pc))
30 moz_include_dir := $(shell pkg-config --variable=includedir $(moz_pc))
31 moz_lib_dir := $(moz_prefix)/lib/$(moz_name)
32
33 moz_version := $(shell pkg-config --modversion $(moz_pc))
34 moz_version_major := $(word 1,$(subst ., ,$(moz_version)))
35 moz_version_minor := $(word 2,$(subst ., ,$(moz_version)))
36
37 CFLAGS := -ansi -Wall -Wunused -Wno-unused-parameter
38 CPPFLAGS := -D_REENTRANT
39 CXXFLAGS := -ansi -Wall -Wunused
40 LDFLAGS := -lpthread                                            \
41            $(shell pkg-config --libs gtkmm-2.4 $(moz_pc))       \
42            $(moz_ldflags_extra) -lexpat
43
44 ifdef NDEBUG
45     CPPFLAGS += -DNDEBUG
46 else
47     CFLAGS += -g
48     CXXFLAGS += -g
49     LDFLAGS += -g
50 endif
51
52 cxxsources := \
53     auto_proc.cpp browser_widget.cpp child_iterator.cpp                    \
54     event_state_manager.cpp generate_dvd.cpp link_iterator.cpp             \
55     null_prompt_service.cpp pixbufs.cpp style_sheets.cpp temp_file.cpp     \
56     video.cpp vob_list.cpp videolink.cpp warp_pointer.cpp                  \
57     x_frame_buffer.cpp xml_utils.cpp xpcom_support.cpp
58 csources := jquant2.c
59
60 sources_using_gtkmm :=                                                     \
61     browser_widget.cpp generate_dvd.cpp pixbufs.cpp temp_file.cpp          \
62     vob_list.cpp videolink.cpp warp_pointer.cpp
63 sources_using_moz :=                                                       \
64     browser_widget.cpp child_iterator.cpp event_state_manager.cpp          \
65     link_iterator.cpp null_prompt_service.cpp style_sheets.cpp             \
66     videolink.cpp xpcom_support.cpp
67 sources_using_moz_unstable := \
68     browser_widget.cpp event_state_manager.cpp link_iterator.cpp           \
69     null_prompt_service.cpp style_sheets.cpp videolink.cpp
70
71 videolink : $(cxxsources:%.cpp=.objs/%.o) $(csources:%.c=.objs/%.o)
72         $(CXX) $^ $(LDFLAGS) -o $@
73
74 clean :
75         rm -rf .objs
76         rm -f videolink *~ .\#* *.orig *.rej svn-commit*.tmp
77
78 install :
79         mkdir -p -m 755 $(DESTDIR)$(bindir)
80         install -m 755 $(if $(NDEBUG),-s,) videolink $(DESTDIR)$(bindir)
81         mkdir -p -m 755 $(DESTDIR)$(docdir)/videolink
82         gzip -c9 README >$(DESTDIR)$(docdir)/videolink/README.gz
83         gzip -c9 ChangeLog >$(DESTDIR)$(docdir)/videolink/ChangeLog.gz
84         chmod 644 $(DESTDIR)$(docdir)/videolink/*.gz
85         mkdir -p -m 755 $(DESTDIR)$(mandir)/man1
86         gzip -c9 videolink.1 >$(DESTDIR)$(mandir)/man1/videolink.1.gz
87         chmod 644 $(DESTDIR)$(mandir)/man1/videolink.1.gz
88         mkdir -p -m 755 $(DESTDIR)$(sharedir)/videolink
89         install -m 644 *.css $(DESTDIR)$(sharedir)/videolink
90
91 .PHONY : clean install
92
93 .objs/browser_widget.% : CPPFLAGS += -DMOZ_LIB_DIR='"$(moz_lib_dir)"'
94
95 .objs/videolink.% \
96     : CPPFLAGS += -DVIDEOLINK_SHARE_DIR='"$(sharedir)/videolink"'
97
98 $(sources_using_gtkmm:%.cpp=.objs/%.o) \
99     : CPPFLAGS += $(shell pkg-config --cflags gtkmm-2.4)
100
101 $(sources_using_moz:%.cpp=.objs/%.o) \
102     : CPPFLAGS += $(filter-out -fshort-wchar, \
103                     $(shell pkg-config --cflags $(moz_pc)) $(moz_cppflags_extra))
104 # Non-virtual destructors are fine in XPCOM interface classes since
105 # instances are only ever called by the Release function which is virtual.
106 $(sources_using_moz:%.cpp=.objs/%.o) : CXXFLAGS += -Wno-non-virtual-dtor
107
108 $(sources_using_moz_unstable:%.cpp=.objs/%.o)                          \
109     : CPPFLAGS += $(moz_unstable_cppflags_extra)                       \
110                   -DMOZ_VERSION_MAJOR=$(moz_version_major)             \
111                   -DMOZ_VERSION_MINOR=$(moz_version_minor)
112
113 .objs/%.o : %.cpp .objs/.created
114         $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -MD -MF .objs/$*.d -c $<
115
116 .objs/%.o : %.c .objs/.created
117         $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -MD -MF .objs/$*.d -c $<
118
119 %/.created :
120         mkdir -p $*
121         touch $@
122
123 ifneq ($(MAKECMDGOALS),clean)
124     -include $(cxxsources:%.cpp=.objs/%.d) $(csources:%.c=.objs/%.d)
125 endif
126
127 .PRECIOUS : %/.created