summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 3622a3e358047cfd8c590e941c9d3c30491ce69b (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
DESTDIR=/
CC = cc
cflags = -O0 -Wall -I. -fpic -Wformat-security -Wextra -pedantic -g3 $(shell pkg-config --cflags libstrophe) -I/usr/include/libircclient
ldflags = $(shell pkg-config --libs libstrophe) -lircclient
PROJ = ircxmpp
# cflags and ldflags are used so that users specifying CFLAGS and LDFLAGS do not override my flags
# += is not used, because gcc usually accepts last option, for example -O0 -O2 will use -O2
.NOTPARALLEL:
default:
	$(CC) -c -DIX_LIB $(cflags) $(CFLAGS) $(PROJ).c
	$(CC) -shared -olib$(PROJ).so $(PROJ).o
	$(CC) -L. $(cflags) $(CFLAGS) $(PROJ).c -l$(PROJ) $(ldflags) $(LDFLAGS) -o$(PROJ)
install:
	mkdir -p $(DESTDIR)/usr/bin $(DESTDIR)/etc $(DESTDIR)/usr/include $(DESTDIR)/usr/lib
	cp $(PROJ) $(DESTDIR)/usr/bin/
	-[ ! -f $(DESTDIR)/etc/$(PROJ) ] && cp $(PROJ).conf $(DESTDIR)/etc/$(PROJ)
	cp lib$(PROJ).so $(DESTDIR)/usr/lib/
	cp $(PROJ).h $(DESTDIR)/usr/include/

distclean: clean

clean:
	rm -f $(PROJ) $(PROJ).o lib$(PROJ).so

uninstall:
	rm -f $(DESTDIR)/usr/bin/$(PROJ) $(DESTDIR)/usr/include/$(PROJ).h $(DESTDIR)/usr/lib/lib$(PROJ).so

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

.PHONY: valgrind clean distclean install uninstall default