forked from infinity0/mozilla-gnome-keyring-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
126 lines (102 loc) · 4.22 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
PACKAGE ?= mozilla-gnome-keyring
VERSION ?= $(shell git describe --tags 2>/dev/null || date +dev-%s)
# if these are empty, we will attempt to auto-detect correct values
#XUL_VER_MIN ?=
#XUL_VER_MAX ?=
# package distribution variables
FULLNAME ?= $(PACKAGE)-$(VERSION)
ARCHIVENAME ?= $(FULLNAME)
# xulrunner tools. use = not ?= so we don't execute on every invocation
XUL_PKG_NAME ?= $(shell (pkg-config --atleast-version=2 libxul && echo libxul) \
|| (pkg-config libxul2 && echo libxul2))
XUL_PKG_NAME := $(XUL_PKG_NAME)
# compilation flags
# if pkgconfig file for libxul is available, use it
ifneq ($(XUL_PKG_NAME),)
XUL_CFLAGS := `pkg-config --cflags $(XUL_PKG_NAME)`
XUL_LDFLAGS := `pkg-config --libs $(XUL_PKG_NAME)`
XPCOM_ABI_FLAGS += `pkg-config --libs-only-L $(XUL_PKG_NAME) | sed -e 's/-L\(\S*\).*/-Wl,-rpath=\1/' | sed -n -e 'p;s/^\(.*\)-devel\(.*\)\/lib$$/\1\2/gp'`
endif
GNOME_CFLAGS := `pkg-config --cflags gnome-keyring-1`
GNOME_LDFLAGS := `pkg-config --libs gnome-keyring-1`
CXXFLAGS += -Wall -fno-rtti -fno-exceptions -fPIC -std=gnu++0x -D__STDC_LIMIT_MACROS
LDFLAGS +=
# determine xul version from "mozilla-config.h" include file
XUL_VERSION = $(shell echo '\#include "mozilla-config.h"'| \
$(CXX) $(XUL_CFLAGS) $(CXXFLAGS) -shared -x c++ -w -E -fdirectives-only - | \
sed -n -e 's/\#[[:space:]]*define[[:space:]]\+MOZILLA_VERSION[[:space:]]\+\"\(.*\)\"/\1/gp')
XUL_VER_MIN ?= `echo $(XUL_VERSION) | sed -r -e 's/([^.]+\.[^.]+).*/\1/g'`
XUL_VER_MAX ?= `echo $(XUL_VERSION) | sed -rn -e 's/([^.]+).*/\1.*/gp'`
# if auto-detect but xulrunner is not available, fall back to these values
XUL_VER_MIN_ ?= 10.0.1
XUL_VER_MAX_ ?= 10.*
# platform-specific handling
# lazy variables, instantiated properly in a sub-make since make doesn't
# support dynamically adjusting the dependency tree during its run
PLATFORM ?= unknown
TARGET ?= libgnomekeyring.so
TARGET := $(TARGET)
XPI_TARGET := $(FULLNAME).xpi
BUILD_FILES := \
xpi/platform/$(PLATFORM)/components/$(TARGET) \
xpi/install.rdf \
xpi/chrome.manifest \
xpi/defaults/preferences/gnome-keyring.js \
xpi/chrome/skin/hicolor/seahorse.svg
.PHONY: all build build-xpi tarball
all: build
build: build-xpi
build-xpi: xpcom_abi
ifeq "$(PLATFORM)" "unknown"
# set PLATFORM properly in a sub-make
PLATFORM=$$(./xpcom_abi) && \
$(MAKE) -f $(lastword $(MAKEFILE_LIST)) $(XPI_TARGET) PLATFORM=$${PLATFORM}
else
$(MAKE) -f $(lastword $(MAKEFILE_LIST)) $(XPI_TARGET)
endif
$(XPI_TARGET): $(BUILD_FILES)
cd xpi && zip -rq ../$@ *
xpi/platform/%/components/$(TARGET): $(TARGET)
mkdir -p $(@D)
cp -a $< $@
xpi/install.rdf: install.rdf Makefile
mkdir -p xpi
XUL_VER_MIN=$(XUL_VER_MIN); \
XUL_VER_MAX=$(XUL_VER_MAX); \
sed -e 's $${PLATFORM} '$(PLATFORM)' g' \
-e 's $${VERSION} '$(VERSION)' g' \
-e 's $${XUL_VER_MIN} '"$${XUL_VER_MIN:-$(XUL_VER_MIN_)}"' g' \
-e 's $${XUL_VER_MAX} '"$${XUL_VER_MAX:-$(XUL_VER_MAX_)}"' g' \
$< > $@
xpi/chrome.manifest: chrome.manifest Makefile
mkdir -p xpi
sed -e 's $${PLATFORM} '$(PLATFORM)' g' \
-e 's $${TARGET} '$(TARGET)' g' \
$< > $@
xpi/defaults/preferences/gnome-keyring.js: gnome-keyring.js
mkdir -p xpi/defaults/preferences
cp -a $< $@
xpi/chrome/skin/hicolor/seahorse.svg: seahorse.svg
mkdir -p xpi/chrome/skin/hicolor
cp -a $< $@
$(TARGET): GnomeKeyring.cpp GnomeKeyring.h Makefile
$(CXX) $< -o $@ -shared \
$(XUL_CFLAGS) $(XUL_LDFLAGS) $(GNOME_CFLAGS) $(GNOME_LDFLAGS) $(CXXFLAGS) $(LDFLAGS)
chmod +x $@
xpcom_abi: xpcom_abi.cpp Makefile
$(CXX) $< -o $@ $(XUL_CFLAGS) $(XUL_LDFLAGS) $(XPCOM_ABI_FLAGS) $(CXXFLAGS) $(LDFLAGS) \
$$( $(CXX) $(XUL_CFLAGS) $(XUL_LDFLAGS) $(XPCOM_ABI_FLAGS) $(CXXFLAGS) $(LDFLAGS) -lmozglue -shared -o /dev/null \
&& echo "-Wl,-whole-archive -lmozglue -Wl,-no-whole-archive" ) # only add these flags if -lmozglue exists
tarball:
git archive --format=tar \
--prefix=$(FULLNAME)/ HEAD \
| gzip - > $(ARCHIVENAME).tar.gz
.PHONY: clean-all clean
clean:
rm -f $(TARGET)
rm -f $(XPI_TARGET)
rm -f xpcom_abi
rm -f -r xpi
clean-all: clean
rm -f *.xpi
rm -f *.tar.gz