-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (67 loc) · 2.77 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
#https://stackoverflow.com/questions/5178125/how-to-place-object-files-in-separate-subdirectory
#Compiler and Linker
CC := gcc
#The Target Binary Program
TARGET := cbf_sensor_dashboard
#The Directories, Source, Includes, Objects, Binary and Resources
SRCDIR := src
INCDIR := inc
BUILDDIR := obj
TARGETDIR := bin
CONFDIR := conf
HTMLDIR := html
INSTALLDIR := /usr/local/sbin
CONFDESTDIR := /etc/cbf_sensor_dashboard
HTMLDESTDIR := /usr/local/share/cbf_sensor_dashboard/html
SYSTEMDDIR := /lib/systemd/system
SRCEXT := c
DEPEXT := d
OBJEXT := o
#Flags, Libraries and Includes
CFLAGS := -Wall -Wconversion -ggdb -rdynamic
KATCPDIR := ../katcp_devel/katcp
LIB := -L $(KATCPDIR) -lkatcp
INC := -I$(INCDIR) -I/usr/local/include -I $(KATCPDIR)
INCDEP := -I$(INCDIR) -I../katcp_devel/katcp
#---------------------------------------------------------------------------------
#DO NOT EDIT BELOW THIS LINE
#---------------------------------------------------------------------------------
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
#Defauilt Make
all: directories $(TARGET)
#Remake
remake: clean all
#Make the Directories
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
#Full Clean, Objects and Binaries
clean:
$(RM) -rf $(BUILDDIR)
$(RM) -rf $(TARGETDIR)
#Pull in dependency info for *existing* .o files
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
install: $(TARGETDIR)/$(TARGET)
install -v -o root -g root -m 744 -C $(TARGETDIR)/$(TARGET) -t $(INSTALLDIR)
install -v -o root -g root -m 644 -C $(CONFDIR)/30-cbf_sensor_dashboard.conf -t /etc/rsyslog.d
install -v -o root -g root -m 644 -C -D $(CONFDIR)/cmc_list.conf -t $(CONFDESTDIR)
install -v -o root -g root -m 644 -C -D $(CONFDIR)/sensor_list.conf -t $(CONFDESTDIR)
install -v -o root -g root -m 644 -C -D $(HTMLDIR)/* -t $(HTMLDESTDIR)
install -v -o root -g root -m 644 -C -D $(CONFDIR)/cbf_sensor_dashboard.service -t $(SYSTEMDDIR)
systemctl enable cbf_sensor_dashboard
systemctl start cbf_sensor_dashboard
#Link
$(TARGET): $(OBJECTS)
$(CC) -o $(TARGETDIR)/$(TARGET) $^ $(LIB)
#Compile
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
@$(CC) $(CFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp
@sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT)
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT)
@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp
#Non-File Targets
.PHONY: all remake clean cleaner resources