-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (67 loc) · 2.79 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
BUILD_DIR=build
RNO_G_INSTALL_DIR?=/rno-g/
PREFIX?=$(RNO_G_INSTALL_DIR)
CFLAGS=-Og -fPIC -Wall -Wextra -g -std=gnu11 -I$(RNO_G_INSTALL_DIR)/include
BINDIR=bin
LDFLAGS=-L$(RNO_G_INSTALL_DIR)/lib
LIBS=-lz -pthread -lrno-g -lradiant -lrno-g-cal -lconfig -lflower -lm -lsystemd
INCLUDES=src/ice-config.h src/ice-buf.h src/ice-common.h
.PHONY: all clean install uninstall
OBJS:=$(addprefix $(BUILD_DIR)/, ice-config.o ice-buf.o ice-common.o ice-version.o)
BINS:=$(addprefix $(BINDIR)/, rno-g-acq make-default-rno-g-config check-rno-g-config update-rno-g-config rno-g-find-config )
$(shell /bin/echo -e "/*This file is auto-generated by the Makefile!*/\n#include \"ice-version.h\"\n\nconst char * get_ice_software_git_hash() { return \"$$(git describe --always --dirty --match 'NOT A TAG')\";}" > src/ice-version.c.tmp; if diff -q src/ice-version.c.tmp src/ice-version.c >/dev/null 2>&1; then rm src/ice-version.c.tmp; else mv src/ice-version.c.tmp src/ice-version.c; fi)
STATION_NUMBER=$(shell if [ -f /STATION_ID ] ; then printf "%03d" `cat /STATION_ID`; fi )
$(info STATION_NUMBER=${STATION_NUMBER})
all: $(OBJS) $(BINS)
$(BINDIR)/update-rno-g-config: $(BINDIR)/check-rno-g-config
ln -f $< $@
$(BINDIR)/%: src/%.c $(INCLUDES) $(OBJS) Makefile | $(BINDIR)
@echo Compiling $@
@cc -o $@ $(CFLAGS) $< $(OBJS) $(LDFLAGS) $(LIBS)
$(BUILD_DIR)/%.o: src/%.c $(INCLUDES) | $(BUILD_DIR)
@echo Compiling $@
@cc -c -o $@ $(CFLAGS) $<
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
$(BINDIR):
@mkdir -p $(BINDIR)
clean:
rm -rf $(BUILD_DIR)
rm -rf $(BINDIR)
setup:
mkdir -p $(PREFIX)/run
chown rno-g:rno-g $(PREFIX)/run
mkdir -p $(PREFIX)/var
chown rno-g:rno-g $(PREFIX)/var
mkdir -p $(PREFIX)/cfg
chown rno-g:rno-g $(PREFIX)/cfg
mkdir -p $(PREFIX)/bin
chown rno-g:rno-g $(PREFIX)/bin
mkdir -p /data/daq
chown rno-g:rno-g /data/daq
mkdir -p /data/timing
chown rno-g:rno-g /data/timing
mkdir -p /data/power
chown rno-g:rno-g /data/power
install: $(BINS) setup
install $(BINS) $(PREFIX)/bin
install scripts/* $(PREFIX)/bin
cfg-update: $(BINDIR)/update-rno-g-config
@ echo "Updating acq configs"
@ for i in cfg/acq*.cfg ; do echo $$i ; $(BINDIR)/update-rno-g-config acq $$i ; done
cfg-install:
@ echo "Installing configuration..."
@ if [ -f cfg/acq-${STATION_NUMBER}.cfg ] ; \
then \
echo "Using station-specific file cfg/acq-${STATION_NUMBER}.cfg" ; install cfg/acq-${STATION_NUMBER}.cfg $(PREFIX)/cfg/acq.cfg ;\
else \
echo "Using default cfg/acq.cfg" ; install cfg/acq.cfg $(PREFIX)/cfg/acq.cfg ; \
fi
@mkdir -p ${PREFIX}/cfg/acq.cfg.once
cppcheck:
cppcheck --enable=portability --enable=performance --enable=information src
polkit-install:
install polkit/rno-g.rules /etc/polkit-1/rules.d/10-rno-g.rules
service-install: polkit-install
install systemd/*.service /etc/systemd/system
systemctl daemon-reload