summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 1e911a0cb25a6e1015d224222a77cda45ae67443 (plain)
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
########################################################################
#                                                                      #
#  Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>            #
#  This file is part of gluster-block.                                 #
#                                                                      #
#  This file is licensed to you under your choice of the GNU Lesser    #
#  General Public License, version 3 or any later version (LGPLv3 or   #
#  later), or the GNU General Public License, version 2 (GPLv2), in all#
#  cases as published by the Free Software Foundation.                 #
#                                                                      #
########################################################################

CC = gcc

CLIENT = gluster-block
CDEP = glfs-operations.o utils.o rpc/block_clnt.c rpc/block_xdr.c gluster-block.o

SERVER = gluster-blockd
SDEP = rpc/block_svc.o rpc/block_xdr.o gluster-blockd.o utils.o

CFLAGS = -g -ggdb -Wall
LIBS := $(shell pkg-config --libs uuid glusterfs-api)

DEPS_LIST = gcc tcmu-runner targetcli

PREFIX ?= /usr/local/sbin
MKDIR_P = mkdir -p
LOGDIR = /var/log/


all: $(CLIENT) $(SERVER)

$(CLIENT): $(CDEP)
	@$(MKDIR_P) $(LOGDIR)$@
	$(CC) $(CFLAGS) $(LIBS) $^ -o $@

$(SERVER): $(SDEP)
	$(CC) $(CFLAGS) $^ -o $@

glfs-operations.o: glfs-operations.c glfs-operations.h
	$(foreach x, $(DEPS_LIST),\
		$(if $(shell which $x), \
		$(info -- found $x),\
		$(else, \
		$(error "No $x in PATH, install '$x' and continue ..."))))
	$(CC) $(CFLAGS) -c $< -o $@

$(CLIENT).o: $(CLIENT).c
	$(CC) $(CFLAGS) -c $< -o $@

install: $(CLIENT) $(SERVER)
	cp $^ $(PREFIX)/

.PHONY: clean distclean
clean distclean:
	rm -f ./*.o ./rpc/*.o $(CLIENT) $(SERVER)

uninstall:
	rm -f $(PREFIX)/$(CLIENT) $(PREFIX)/$(SERVER)