forked from scottnewell/ka9q-web
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (45 loc) · 2.15 KB
/
Copy pathMakefile
File metadata and controls
60 lines (45 loc) · 2.15 KB
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
60
PREFIX=/usr/local
# for production
DOPTS=-DNDEBUG=1 -O3
# for debugging
#DOPTS=-g
COPTS=-march=native -std=gnu11 -pthread -Wall -funsafe-math-optimizations -D_GNU_SOURCE=1
KA9QOBJS = misc.o multicast.o rtp.o status.o decode_status.o
INCLUDES=
RESOURCES_BASE_DIR=$(PREFIX)/share/ka9q-web
CFLAGS=$(DOPTS) $(COPTS)
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || printf "unknown")
GIT_COMMIT_INDEX := $(shell git rev-list --count HEAD 2>/dev/null || printf "unknown")
CPPFLAGS=$(INCLUDES) -DRESOURCES_BASE_DIR=$(RESOURCES_BASE_DIR) -DPKGDATADIR=\"$(RESOURCES_BASE_DIR)\" -DGIT_COMMIT=\"$(GIT_COMMIT)\" -DGIT_COMMIT_INDEX=\"$(GIT_COMMIT_INDEX)\"
KA9Q_RADIO_OBJS=$(KA9QOBJS)
all: ka9q-web
ka9q-web: ka9q-web.o $(KA9Q_RADIO_OBJS)
$(CC) -o $@ $^ -lonion -lbsd -lm -ldl
# Generate config paths header (copied from ka9q-web1 Makefile)
esc = sed 's/\\/\\\\/g; s/"/\\"/g'
config_paths.h: Makefile
echo "make $@"
@printf '#ifndef _CONFIG_PATHS_H\n' > $@
@printf '#define _CONFIG_PATHS_H 1\n' >> $@
@printf '#define CONFDIR "%s"\n' '$(PREFIX)/etc/radio' >> $@
@printf '#define STATEDIR "%s"\n' '$(PREFIX)/var/lib/ka9q-radio' >> $@
@printf '#define PKGDATADIR "%s"\n' '$(RESOURCES_BASE_DIR)' >> $@
@printf '#define PKGLIBDIR "%s"\n' '$(PREFIX)/lib/ka9q-web' >> $@
@printf '#define GIT_HASH "%s"\n' "$$(git rev-parse HEAD | $(esc))" >> $@
@printf '#define GIT_TIME "%s"\n' "$$(git show -s --format=%ci | $(esc))" >> $@
@printf '#define GIT_BRANCH "%s"\n' "$$(git log --pretty=format:%d -n 1 | $(esc))" >> $@
@printf '#define GIT_SUMMARY "%s"\n' "$$(git log -1 --format=%s | $(esc))" >> $@
@printf '#define GIT_VERSION "%s"\n' "$$(git describe --always --dirty --tags | $(esc))" >> $@
@printf '#define GIT_REMOTE_URL "%s"\n' "$$(git remote get-url origin | $(esc))" >> $@
@printf '#define GIT_COMMIT_INDEX "%s"\n' "$$(git rev-list --count HEAD | $(esc))" >> $@
@printf '#endif\n' >> $@
%.o: %.c config_paths.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
install: ka9q-web
install -m 755 $^ $(PREFIX)/sbin
install -m 644 -D html/* -t $(RESOURCES_BASE_DIR)/html/
install-config:
install -b -m 644 config/* /etc/radio
clean:
-rm -f ka9q-web *.o *.d
.PHONY: clean all install