-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (118 loc) · 4.53 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
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
# =============================================================================
#
# Copyright 2016-2019, Andrew Lindesay. All Rights Reserved.
# Distributed under the terms of the MIT License.
#
# Authors:
# Andrew Lindesay, [email protected]
#
# =============================================================================
VERSIONMAJOR=0
VERSIONMIDDLE=2
VERSIONMINOR=1
VERSION=$(VERSIONMAJOR).$(VERSIONMIDDLE).$(VERSIONMINOR)
SQLITEVERSION=3210000
SQLITEZIPURL=http://sqlite.org/2017/sqlite-amalgamation-$(SQLITEVERSION).zip
SQLITETMP=sqlite-amalgamation-$(SQLITEVERSION).zip
SQLITEDIR=sqlite-amalgamation-$(SQLITEVERSION)
SQLITEHEADER=$(SQLITEDIR)/sqlite3.h
SQLITECOMPILEOPTS=-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION
GLIBCOMPILERESOURCES=glib-compile-resources
CC=gcc
RM=rm -f
FLEX=flex
ECHO=@echo
ZIP=zip
WGET=wget
CFLAGSOTHER=-Wall -c -I . -I $(SQLITEDIR) -DDEEN_VERSION=\"$(VERSION)\" $(SQLITECOMPILEOPTS)
# Different flags are required for the compilation of the flex output file
# because some warnings can be tolerated from that.
CFLAGSFLEXOTHER=-c -I . -I $(SQLITEDIR)
# -fstack-protector; checks for operations happening on the stack. Requires
# also use of -lssp
ifdef DEBUG
CFLAGS=-g -gdwarf-2 -ggdb -DDEBUG
LDFLAGS=-g -gdwarf-2 -ggdb
else
CFLAGS=-O
LDFLAGS=-dead_strip
endif
COREOBJS=core/common.o core/entry.o core/entry_parse.o core/install.o \
core/keyword.o core/search.o core/index.o \
$(SQLITEDIR)/sqlite3.o
CLIOBJS=cli/climain.o cli/renderplain.o cli/rendercommon.o
GTKOBJS=gui-gtk/ggtkmain.o gui-gtk/ggtkinstall.o gui-gtk/ggtkgeneral.o \
gui-gtk/ggtkresources.o gui-gtk/ggtksearch.o gui-gtk/ggtkrendertextbuffer.o
GTKRSRCS=gui-gtk/ggtkresources.xml gui-gtk/ggtkmain.glade
LDFLAGSOTHER=
GTKLDFLAGS=-lpthread
TESTKEYWORDOBJS=core-test/keyword-test.o
TESTCOMMONOBJS=core-test/common-test.o
TESTINDEXOBJS=core-test/index-test.o
TESTENTRYOBJS=core-test/entry-test.o
all: deen
deen: $(SQLITEHEADER) $(CLILIBS) $(COREOBJS) $(CLIOBJS)
$(CC) $(CLIOBJS) $(COREOBJS) -o deen $(LDFLAGS) $(LDFLAGSOTHER)
deen-ggtk: $(SQLITEHEADER) $(GTKOBJS) $(COREOBJS)
$(CC) -rdynamic $(GTKOBJS) $(COREOBJS) -o deen-ggtk $(LDFLAGS) $(LDFLAGSOTHER) $(GTKLDFLAGS) $(shell pkg-config gtk+-3.0 --libs)
# ----------------------------------
# TESTS
tests: deen-keyword-test deen-common-test deen-index-test deen-entry-test
./deen-keyword-test
./deen-common-test
./deen-index-test
./deen-entry-test
deen-keyword-test: $(SQLITEHEADER) $(COREOBJS) $(TESTKEYWORDOBJS)
$(CC) $(TESTKEYWORDOBJS) $(COREOBJS) -o deen-keyword-test $(LDFLAGS) $(LDFLAGSOTHER)
deen-common-test: $(SQLITEHEADER) $(COREOBJS) $(TESTCOMMONOBJS)
$(CC) $(TESTCOMMONOBJS) $(COREOBJS) -o deen-common-test $(LDFLAGS) $(LDFLAGSOTHER)
deen-index-test: $(SQLITEHEADER) $(COREOBJS) $(TESTINDEXOBJS)
$(CC) $(TESTINDEXOBJS) $(COREOBJS) -o deen-index-test $(LDFLAGS) $(LDFLAGSOTHER)
deen-entry-test: $(SQLITEHEADER) $(COREOBJS) $(TESTENTRYOBJS)
$(CC) $(TESTENTRYOBJS) $(COREOBJS) -o deen-entry-test $(LDFLAGS) $(LDFLAGSOTHER)
# ----------------------------------
$(SQLITETMP):
$(WGET) $(SQLITEZIPURL)
$(SQLITEDIR)/sqlite3.c $(SQLITEDIR)/sqlite3.h: $(SQLITETMP)
unzip $(SQLITETMP)
touch $(SQLITEDIR)/sqlite3.c
touch $(SQLITEDIR)/sqlite3.h
core/entry_parse.c: core/entry_parse.flex
$(FLEX) -o core/entry_parse.c core/entry_parse.flex
core/entry_parse.o: core/entry_parse.c
$(CC) $(CFLAGS) $(CFLAGSFLEXOTHER) -o $@ $^
gui-gtk/ggtkresources.h: $(GTKRSRCS)
$(GLIBCOMPILERESOURCES) gui-gtk/ggtkresources.xml --sourcedir=gui-gtk \
--c-name deen_ggtk --manual-register --generate-header --target=gui-gtk/ggtkresources.h
gui-gtk/ggtkresources.c: $(GTKRSRCS)
$(GLIBCOMPILERESOURCES) gui-gtk/ggtkresources.xml --sourcedir=gui-gtk \
--c-name deen_ggtk --manual-register --generate-source --target=gui-gtk/ggtkresources.c
gui-gtk/ggtkmain.o: gui-gtk/ggtkmain.c gui-gtk/ggtkresources.h
$(CC) $(CFLAGS) $(CFLAGSOTHER) $(shell pkg-config gtk+-3.0 --cflags) \
-o gui-gtk/ggtkmain.o gui-gtk/ggtkmain.c
gui-gtk/%.o: gui-gtk/%.c
$(CC) $(CFLAGS) $(CFLAGSOTHER) $(shell pkg-config gtk+-3.0 --cflags) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) $(CFLAGSOTHER) -o $@ $^
clean-sqlite:
$(RM) $(SQLITETMP)
$(RM) $(SQLITEDIR)/*.o
$(RM) $(SQLITEDIR)/*.c
$(RM) $(SQLITEDIR)/*.h
clean-own:
$(RM) core/*.o
$(RM) core/entry_parse.c
$(RM) cli/*.o
$(RM) deen
$(RM) deen-*-test
$(RM) deen.exe
$(RM) deen-*-test.exe
$(RM) tmp_index_e2e.sqlite
clean-gui:
$(RM) deen-gui
$(RM) gui-gtk/ggtkresources.c
$(RM) gui-gtk/ggtkresources.h
$(RM) gui-gtk/*.o
$(RM) gui-gtk/*.o
clean: clean-sqlite clean-own clean-gui
# ----------------------------------