summaryrefslogtreecommitdiffhomepage
path: root/plugin/Makefile
blob: 21b3eff23d6c93ea72d6140a6dbf3ea929fc18ea (plain)
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

#
#  Copyright (c) 2009 Samuel Lidén Borell <samuel@kodafritt.se>
# 
#  Permission is hereby granted, free of charge, to any person obtaining a copy
#  of this software and associated documentation files (the "Software"), to deal
#  in the Software without restriction, including without limitation the rights
#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#  copies of the Software, and to permit persons to whom the Software is
#  furnished to do so, subject to the following conditions:
#  
#  The above copyright notice and this permission notice shall be included in
#  all copies or substantial portions of the Software.
#  
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#  THE SOFTWARE.
#

CFLAGS ?= -O2 -g
PKGCONFIG_CFLAGS=`pkg-config --cflags glib-2.0 x11`
CCFLAGS:=$(CFLAGS) -Wall -Wextra -std=c99 -pedantic -Wno-unused-parameter -I../npapi -fPIC -fvisibility=hidden $(PKGCONFIG_CFLAGS) -DG_DISABLE_DEPRECATED=1 -DGSEAL_ENABLE -DFRIBID_PLUGIN

LINKFLAGS:=$(CFLAGS) $(LDFLAGS) -Wl,-z,defs,-soname,libfribidplugin.so
PKGCONFIG_LIBS=`pkg-config --libs glib-2.0`
LIBS:=-lc $(PKGCONFIG_LIBS)

# Files to be installed
LIB_PATH=`../configure --internal--get-define=LIB_PATH`
NPAPI_PLUGIN_LIB=`../configure --internal--get-define=NPAPI_PLUGIN_LIB`
NPAPI_PLUGIN_PATHS=`../configure --internal--get-define=NPAPI_PLUGIN_PATHS`

OBJECTS=ipc.o npmain.o npobject.o plugin.o pluginutil.o pipe.o npn_gate.o np_entry.o

all: libfribidplugin.so

ipc.o: ../common/defines.h ../common/pipe.h ../common/bidtypes.h plugin.h
npmain.o: ../common/defines.h ../common/bidtypes.h  npobject.h plugin.h
npobject.o: ../common/bidtypes.h npobject.h plugin.h pluginutil.h
pipe.o: ../common/pipe.h ../common/pipe.c
plugin.o: ../common/biderror.h ../common/bidtypes.h plugin.h
pluginutil.o: pluginutil.h
np_entry.o: ../npapi/np_entry.c
npn_gate.o: ../npapi/npn_gate.c

.c.o:
	$(CC) $(CCFLAGS) -c $< -o $@

libfribidplugin.so: $(OBJECTS)
	$(CC) -shared $(LINKFLAGS) -o $@ $(OBJECTS) $(LIBS)

.PHONY: all clean install uninstall
clean:
	rm -f $(OBJECTS) libfribidplugin.so

install: all
	install -d $(DESTDIR)$(LIB_PATH)
	install -m 644 libfribidplugin.so $(DESTDIR)$(LIB_PATH)
	for path in $(NPAPI_PLUGIN_PATHS); do \
	    (../configure --internal--remove-link $(DESTDIR)$$path/libfribidplugin.so $(NPAPI_PLUGIN_LIB) || exit 1) && \
	    install -d $(DESTDIR)$$path && \
	    ln -sf $(NPAPI_PLUGIN_LIB) $(DESTDIR)$$path/libfribidplugin.so; \
	done

uninstall:
	rm -f $(DESTDIR)$(NPAPI_PLUGIN_LIB)
	[ ! -d $(DESTDIR)$(LIB_PATH) ] || rmdir $(DESTDIR)$(LIB_PATH) 2> /dev/null || true
	for path in $(NPAPI_PLUGIN_PATHS); do \
	    ../configure --internal--remove-link $(DESTDIR)$$path/libfribidplugin.so $(NPAPI_PLUGIN_LIB) || exit 1; \
	done

$(OBJECTS): ../common/defines.h ../common/config.h
../common/config.h:
	@echo "You must run ./configure first." >&2 && false
../common/defines.h: