-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
126 lines (99 loc) · 2.91 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
CC = cc
STRIP = strip
CROSS := $(TARGET)
MKDEP = $(CROSS)$(CC) -MP -MM -o $*.d $<
RM = rm -f
MV = mv -f
# Setup quiet build
Q =
SAY = @true
ifndef V
Q = @
SAY = @echo
endif
CFLAGS ?= -O2 -ggdb -pipe -ffunction-sections -fdata-sections \
-W -Wall -Wextra \
-Wshadow -Wformat-security -Wstrict-prototypes -Wno-unused-parameter \
-Wredundant-decls -Wold-style-definition
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
LDFLAGS ?= -Wl,--gc-sections
ifeq ($(uname_S),Darwin)
LDFLAGS :=
endif
DEFS += -D_FILE_OFFSET_BITS=64
PREFIX ?= /usr/local
INSTALL_PRG = videohubctrl
INSTALL_PRG_DIR = $(subst //,/,$(DESTDIR)/$(PREFIX)/bin)
INSTALL_DOC = videohubctrl.1
INSTALL_DOC_DIR = $(subst //,/,$(DESTDIR)/$(PREFIX)/share/man/man1)
FUNCS_DIR = libfuncs
FUNCS_LIB = $(FUNCS_DIR)/libfuncs.a
videohubctrl_SRC = \
cmd.c \
net.c \
util.c \
display.c \
videohubctrl.c
videohubctrl_LIBS = -lpthread
videohubctrl_OBJS = $(FUNCS_LIB) $(videohubctrl_SRC:.c=.o)
CLEAN_OBJS = videohubctrl $(videohubctrl_SRC:.c=.o) $(videohubctrl_SRC:.c=.d) test/*.out
DISTCLEAN_OBJS = version.h
.PHONY: distclean clean version install uninstall test
PROGS=videohubctrl
version:
$(shell ./version.sh >/dev/null)
@$(MAKE) --no-print-directory videohubctrl
videohubctrl: $(videohubctrl_OBJS)
$(SAY) " LINK videohubctrl"
$(Q)$(CROSS)$(CC) $(CFLAGS) $(DEFS) $(videohubctrl_OBJS) $(videohubctrl_LIBS) $(LDFLAGS) -o videohubctrl
all: version
test:
test/run
$(FUNCS_LIB): $(FUNCS_DIR)/libfuncs.h
$(SAY) " MAKE $(FUNCS_LIB)"
$(Q)$(MAKE) -s -C $(FUNCS_DIR)
%.o: %.c Makefile RELEASE
@$(MKDEP)
$(SAY) " CC videohubctrl $<"
$(Q)$(CROSS)$(CC) $(CFLAGS) $(DEFS) -c $<
-include $(videohubctrl_SRC:.c=.d)
strip:
$(SAY) " STRIP $(PROGS)"
$(Q)$(CROSS)$(STRIP) $(PROGS)
clean:
$(SAY) " RM $(CLEAN_OBJS)"
$(Q)$(RM) $(CLEAN_OBJS)
distclean: clean
$(SAY) " RM $(DISTCLEAN_OBJS)"
$(Q)$(RM) $(DISTCLEAN_OBJS)
$(Q)$(MAKE) -s -C $(FUNCS_DIR) clean
install: all
$(Q)install -d "$(INSTALL_PRG_DIR)"
$(Q)install -d "$(INSTALL_DOC_DIR)"
$(SAY) "INSTALL $(INSTALL_PRG) -> $(INSTALL_PRG_DIR)"
$(Q)-install $(INSTALL_PRG) "$(INSTALL_PRG_DIR)"
$(SAY) "INSTALL $(INSTALL_DOC) -> $(INSTALL_DOC_DIR)"
$(Q)-install -m 0644 $(INSTALL_DOC) "$(INSTALL_DOC_DIR)"
uninstall:
@-for FILE in $(INSTALL_PRG); do \
echo "RM $(INSTALL_PRG_DIR)/$$FILE"; \
rm "$(INSTALL_PRG_DIR)/$$FILE"; \
done
@-for FILE in $(INSTALL_DOC); do \
echo "RM $(INSTALL_DOC_DIR)/$$FILE"; \
rm "$(INSTALL_DOC_DIR)/$$FILE"; \
done
help:
@printf "\
videohubctrl build parameters\n\n\
Build targets:\n\
all - Build videohubctrl\n\
install - Install videohubctrl in PREFIX: $(PREFIX)\n\
uninstall - Uninstall videohubctrl from PREFIX\n\
\n\
Cleaning targets:\n\
clean - Remove videohubctrl generated files.\n\
distclean - Remove all generated files.\n\
\n\
make V=1 Enable verbose build\n\
make PREFIX=dir Set install prefix\n\n"