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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
# See COPYING for copyright and license details
REAL_NAME=dwb
include $(dir $(lastword $(MAKEFILE_LIST)))version.mk
COPYRIGHT="(C) 2010-2014 Stefan Bolte"
LICENSE="GNU General Public License, version 3 or later"
# dirs
DISTDIR=$(REAL_NAME)-$(REAL_VERSION)
DOCDIR=doc
APIDIR=$(DOCDIR)/api
SRCDIR=src
JSDIR=scripts
HTMLDIR=html
LIBDIR=lib
LIBJSDIR=$(JSDIR)/$(LIBDIR)
LIBJSFILES=$(wildcard $(LIBJSDIR)/*.js)
SHAREDIR=share
M4DIR=m4
UTILDIR=$(SRCDIR)/util
TOOLDIR=tools
EXTENSIONDIR=extensions
CONTRIBDIR=contrib
MODULEDIR=$(JSDIR)/modules
DWB_LIB_DIR_EXAR = exar
DWB_LIB_DIR_RC = dwbremote
DWB_LIB_DIRS = $(DWB_LIB_DIR_EXAR) $(DWB_LIB_DIR_RC)
SUBDIRS=$(M4DIR) $(SRCDIR) $(DWBEMDIR) $(LIBJSDIR)
SUBDIR_BUILD_FIRST=$(UTILDIR) $(DWB_LIB_DIRS)
DWBEMDIR=dwbem
EXTENSION_MANAGER=dwbem
DWBRCDIR=dwbremote
DWBRC=dwbremote
DTARGET=$(TARGET)_d
# Version info
#GIT_VERSION=$(shell git log -1 --format="%cd %h" --date=short 2>/dev/null)
#VERSION=$(shell if [ "$(GIT_VERSION)" ]; then echo "commit\ \"$(GIT_VERSION)\""; else echo "$(REAL_VERSION)"; fi)
#NAME=$(shell if [ "$(GIT_VERSION)" ]; then echo "$(REAL_NAME)-git"; else echo "$(REAL_NAME)"; fi)
# Targets
TARGET = $(REAL_NAME)
# target directories
PREFIX=/usr
BINDIR=$(PREFIX)/bin
DATAROOTDIR=$(PREFIX)/share
DATADIR=$(DATAROOTDIR)
# manpages
MANFILE=$(REAL_NAME).1
MANDIR=$(DATAROOTDIR)/man
MAN1DIR=$(MANDIR)/man1
MAN7DIR=$(MANDIR)/man7
MANAPI=dwb-js.7
# Compiler
CC ?= gcc
GTK3LIBS=gtk+-3.0 webkitgtk-3.0
ifeq ($(shell pkg-config --exists javascriptcoregtk-3.0 && echo 1), 1)
GTK3LIBS+=javascriptcoregtk-3.0
endif
GTK2LIBS=gtk+-2.0 webkit-1.0
ifeq ($(shell pkg-config --exists javascriptcoregtk-1.0 && echo 1), 1)
GTK2LIBS+=javascriptcoregtk-1.0
endif
LIBSOUP=libsoup-2.4
ifeq ($(shell pkg-config --exists $(LIBSOUP) && echo 1), 1)
LIBS=$(LIBSOUP)
else
$(error Cannot find $(LIBSOUP))
endif
#determine gtk version
ifeq (${GTK}, 3) #GTK=3
ifeq ($(shell pkg-config --exists $(GTK3LIBS) && echo 1), 1) #has gtk3 libs
LIBS+=$(GTK3LIBS)
USEGTK3 := 1
else #has gtk3 libs
ifeq ($(shell pkg-config --exists $(GTK2LIBS) && echo 1), 1) #has gtk2 libs
$(warning Cannot find gtk3-libs, falling back to gtk2)
LIBS+=$(GTK2LIBS)
else #has gtk2 libs
$(error Cannot find gtk2-libs or gtk3-libs)
endif #has gtk2 libs
endif #has gtk3 libs
else #GTK=3
ifeq ($(shell pkg-config --exists $(GTK2LIBS) && echo 1), 1) #has gtk2 libs
LIBS+=$(GTK2LIBS)
else #has gtk2 libs
ifeq ($(shell pkg-config --exists $(GTK3LIBS) && echo 1), 1) #has gtk3 libs
LIBS+=$(GTK3LIBS)
USEGTK3 := 1
$(warning Cannot find gtk2-libs, falling back to gtk3)
else #has gtk3 libs
$(error Cannot find gtk2-libs or gtk3-libs)
endif #has gtk3 libs
endif #has gtk2 libs
endif #GTK=3
GNUTLS=gnutls
ifeq ($(shell pkg-config --exists $(GNUTLS) && echo 1), 1)
LIBS+=$(GNUTLS)
else
$(error Cannot find $(GNUTLS))
endif
# >=json-c-0.11 renamed its library, pc file, and include dir
# first check for >=0.11, if it doesn't exist check for <0.11
ifeq ($(shell pkg-config --exists json-c && echo 1), 1)
JSONC=json-c
else
ifeq ($(shell pkg-config --exists json && echo 1), 1)
JSONC=json
endif
endif
ifdef JSONC
LIBS+=$(JSONC)
else
$(error Cannot find json-c)
endif
# HTML-files
INFO_FILE=info.html
SETTINGS_FILE=settings.html
HEAD_FILE=head.html
KEY_FILE=keys.html
ERROR_FILE=error.html
LOCAL_FILE=local.html
#Base javascript script
BASE_SCRIPT=base.js
# CFLAGS
CFLAGS := $(CFLAGS)
CFLAGS += -Wall
CFLAGS += -Werror=format-security
CFLAGS += -pipe
CFLAGS += --ansi
CFLAGS += -std=c99
CFLAGS += -D_POSIX_C_SOURCE='200112L'
CFLAGS += -O2
CFLAGS += -g
CFLAGS += -D_BSD_SOURCE
CFLAGS += -D_NETBSD_SOURCE
CFLAGS += -D__BSD_VISIBLE
CFLAGS += $(shell pkg-config --cflags $(LIBS))
ifeq ($(shell pkg-config --exists '$(LIBSOUP) >= 2.38' && echo 1), 1)
M4FLAGS += -DWITH_LIBSOUP_2_38=1 -G
CFLAGS += -DWITH_LIBSOUP_2_38=1
endif
ifeq (${DISABLE_HSTS}, 1)
CFLAGS += -DDISABLE_HSTS
else
M4FLAGS += -DWITH_HSTS=1 -G
endif
CFLAGS_OPTIONS := $(CFLAGS)
ifeq (${USEGTK3}, 1)
CPPFLAGS+=-DGTK_DISABLE_SINGLE_INCLUDES
CPPFLAGS+=-DGTK_DISABLE_DEPRECATED
CPPFLAGS+=-DGDK_DISABLE_DEPRECATED
CPPFLAGS+=-DGSEAL_ENABLE
M4FLAGS += -DWITH_GTK3=1
endif
#defines
CFLAGS += -DINFO_FILE=\"$(INFO_FILE)\"
CFLAGS += -DSETTINGS_FILE=\"$(SETTINGS_FILE)\"
CFLAGS += -DHEAD_FILE=\"$(HEAD_FILE)\"
CFLAGS += -DKEY_FILE=\"$(KEY_FILE)\"
CFLAGS += -DERROR_FILE=\"$(ERROR_FILE)\"
CFLAGS += -DLOCAL_FILE=\"$(LOCAL_FILE)\"
CFLAGS += -DBASE_SCRIPT=\"$(BASE_SCRIPT)\"
CFLAGS += -DSYSTEM_DATA_DIR=\"$(DATADIR)\"
CFLAGS += -DLIBJS_DIR=\"$(LIBJSDIR)\"
# LDFLAGS
LDFLAGS += $(shell pkg-config --libs $(LIBS))
LDFLAGS += -lpthread -lm -lX11
# Debug flags
DCFLAGS = $(CFLAGS)
#DCFLAGS += -DDWB_DEBUG
DCFLAGS += -g
DCFLAGS += -O0
DCFLAGS += -Wextra -Wno-unused-parameter
# Makeflags
MFLAGS=
#Input
SOURCE = $(wildcard *.c)
HDR = $(wildcard *.h)
# OUTPUT
# Objects
OBJ = $(patsubst %.c, %.o, $(wildcard *.c))
DOBJ = $(patsubst %.c, %.do, $(wildcard *.c))
OBJLIB = exar/exar.o dwbremote/dwbremote.o
OBJEXAR = exar/exar.o
OBJRC = dwbremote/dwbremote.o
|