-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
59 lines (49 loc) · 1.33 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
OS=$(shell uname -s)
ifneq ("$(wildcard .git)","")
CFLAGS?=-g -Wall
VERSION := $(shell git describe --dirty --tags | sed 's/^v//')
CURR_VERSION := $(shell sed 's/^\#define VERSION "\(.*\)"$$/\1/' version.h 2>/dev/null)
else
BASE_VERSION := $(shell cat base_version)
endif
ifeq ($(OS),Linux)
DESTDIR?=/usr
LDLIBS?=-pthread -lutil
INSTGROUP?=root
else
DESTDIR?=/usr/local
MANDIR?=$(DESTDIR)/man
INSTGROUP?=wheel
ifneq ($(OS),Darwin)
LDLIBS?=-lpthread -lutil
endif
endif
BINDIR?=$(DESTDIR)/bin
MANDIR?=$(DESTDIR)/share/man
objects=kplex.o fileio.o serial.o bcast.o tcp.o options.o error.o lookup.o mcast.o gofree.o udp.o
all: version kplex
.PHONY: version
version:
@if [ "$(VERSION)" != "$(CURR_VERSION)" ]; then \
echo '#define VERSION "'$(VERSION)'"' > version.h; \
fi
kplex: $(objects)
$(CC) -o kplex $(objects) $(LDFLAGS) $(LDLIBS)
tcp.o: tcp.h
gofree.o: tcp.h
$(objects): kplex.h
kplex.o: kplex_mods.h version.h
version.h:
@echo '#define VERSION "'$(BASE_VERSION)'"' > version.h
install: kplex
test -d "$(BINDIR)" || install -d -g $(INSTGROUP) -o root -m 755 $(BINDIR)
install -g $(INSTGROUP) -o root -m 755 kplex $(BINDIR)/kplex
test -d $(MANDIR)/man1 && gzip -c kplex.1 > $(MANDIR)/man1/kplex.1.gz
uninstall:
-rm -f $(BINDIR)/kplex
-rm -f $(MANDIR)/man1/kplex.1.gz
clean:
-rm -f kplex $(objects)
.PHONY: release
release:
sudo ./release