summaryrefslogtreecommitdiffstats
path: root/makefile
blob: 8b6bd0a18e10d59fa7d9689aaab7f170d91fe505 (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
DESTDIR=/
CC=cc
MYCFLAGS=-DHARDCODED_DNS=`(host ipv6.sijanec.eu || echo no_host_program_on_build_host) | tail -n1 | rev | cut -d\  -f1 | rev` -O0 -Wall -Wextra -Wformat -pedantic -g -Isrc -Itmp -Itiny-AES-c # -fsanitize=address
MYLDFLAGS=-lresolv -lmd

default: travnik metainfo.o metainfo utils

tmp:
	mkdir -p tmp

travnik: src/main.c src/dht.c src/tcp.c src/bencoding.c
	$(CC) $(MYCFLAGS) $(CFLAGS) $< -o$@ $(MYLDFLAGS) $(LDFLAGS)

metainfo: src/metainfo.c src/metainfo.h
	$(CC) $(MYCFLAGS) $(CFLAGS) $< -o$@ $(MYLDFLAGS) $(LDFLAGS)

metainfo.o: src/metainfo.c src/metainfo.h
	$(CC) -fPIC $(MYCFLAGS) $(CFLAGS) $< -o$@ $(MYLDFLAGS) $(LDFLAGS)

utils: tmp/midpoint tmp/bencoding tmp/dns tmp/info

tmp/%: utils/%.c src/dht.c src/tcp.c tmp
	$(CC) $(MYCFLAGS) $(CFLAGS) $< -o$@ $(MYLDFLAGS) $(LDFLAGS)

install:
	mkdir -p $(DESTDIR)/usr/bin/
	cp travnik $(DESTDIR)/usr/bin/

distclean: clean

clean:
	rm -rf travnik tmp test-eval

prepare:
	sudo apt install libmicrohttpd-dev build-essential default-libmysqlclient-dev -y

valgrind:
	valgrind --error-exitcode=59 --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt $(CMD)

.PHONY: default install distclean clean prepare valgrind utils