summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: a10bd456791ae2e64e85b7c1e4f3817fe556f7af (plain) (blame)
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
DESTDIR=/
SRCFILE=src/main.c
BINFILE=discord.c
O=0
CC=cc
CFLAGS += -Wextra -Wall -pedantic -g -O$O -Itmp -Isrc -I. -odiscord.c -Wno-unused-parameter -rdynamic -finput-charset=UTF-8 -fextended-identifiers
LIBS += -lm
CFLAGS += $(shell pkg-config --cflags libwebsockets) $(shell pkg-config --cflags gtk+-3.0) $(shell pkg-config --cflags gmodule-export-2.0)
LIBS += $(shell pkg-config --libs libwebsockets) $(shell pkg-config --libs gtk+-3.0) $(shell pkg-config --libs gmodule-export-2.0) -lcjson
VGARGS += --leak-check=full --track-origins=yes --verbose --log-file=valgrind-out.txt --suppressions=/usr/share/glib-2.0/valgrind/glib.supp --suppressions=tmp/gtk.supp --suppressions=/usr/lib/i386-linux-gnu/valgrind/default.supp --suppressions=tmp/gnome.supp --show-leak-kinds=definite --suppressions=misc/misc.supp --suppressions=/usr/share/gtk-3.0/valgrind/gtk.supp --leak-resolution=low
# notparallel ker morajo biti ukazi izvedeni po vrsti, mkdir se mora zgoditi pred xxd recimo.

.NOTPARALLEL:
default:
	mkdir tmp -p
	xxd -i < src/ui.glade > tmp/ui.xxd
	echo ', 0' >> tmp/ui.xxd
	xxd -i < src/identify.json > tmp/identify.xxd
	echo ', 0' >> tmp/identify.xxd
	$(CC) $(CFLAGS) $(SRCFILE) $(LIBS)

# tests if code compiles under gcc, clang and tcc
cc:
	make -e CC=tcc
	make -e CC=gcc
	scan-build make

install:
	mkdir -p $(DESTDIR)/usr/bin/
	cp discord.c $(DESTDIR)/usr/bin/

distclean:
	rm discord.c tmp -f

clean:
	rm discord.c tmp -f
	
prepare:
	apt install build-essential libwebsockets-dev libcjson-dev libsoundio-dev libgtk-3-dev xxd -y

# developing is to be done on i386. for example the default suppression file is hardcoded for i386 here:
# developing is to be done on bullseye. we download gtk.supp even though debian ships it, because that's how we "get rid of" more leaks.

valgrind-prepare:
	mkdir -p tmp
	-[ ! -f tmp/gtk.supp ] && wget -c -Otmp/gtk.supp https://gitlab.gnome.org/GNOME/gtk/raw/master/gtk.supp
	-[ ! -d tmp/GNOME.supp ] && bash -c "cd tmp && git clone https://github.com/GreenBeard/GNOME.supp && cd GNOME.supp && make && cd build && cat * > ../../gnome.supp"

valgrind:
	-[ ! -f tmp/gend.supp ] && bash -c "echo '' > tmp/gend.supp"
	G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind $(VGARGS) --suppressions=tmp/gend.supp ./$(BINFILE)

gensupp:
	cc misc/valgrind-supp-extractor.c -otmp/vse
	G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind $(VGARGS) --gen-suppressions=all ./discord.c
	tmp/vse < valgrind-out.txt > tmp/gend.supp