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
|
## Copyright (C) 2014-2016
## Olivier Gayot <ogayot@baylibre.com>
## Bartosz Golaszewski <bgolaszewski@baylibre.com>
## Olivier Gayot <olivier.gayot@sigexec.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
USERFLAGS =
CPPFLAGS += -I./include -I/usr/local/include
CFLAGS += -W -Wall -Wextra
CFLAGS += -D_GNU_SOURCE $(USERFLAGS)
CXXFLAGS += -W -Wall -Wextra
LDFLAGS += -L./lib -L/usr/local/lib -lwebsockets -lconfig $(USERFLAGS)
PROGNAME = caod
SRCS = daemon.c log.c misc.c
SRCS_C = $(filter %.c,$(SRCS))
SRCS_C++ = $(filter %.cpp,$(SRCS))
OBJS_C = $(SRCS_C:.c=.o)
OBJS_C++ = $(SRCS_C++:.cpp=.o)
OBJS = $(OBJS_C) $(OBJS_C++)
ifdef DEBUG
CFLAGS += -g$(DEBUG) -D CONFIG_DEBUG -O0
CXXFLAGS += -g$(DEBUG) -D CONFIG_DEBUG -O0
else
CFLAGS += -O2
CXXFLAGS += -O2
endif
print:
echo $(SRCS_C)
all: print $(PROGNAME)
$(PROGNAME): $(OBJS)
$(CXX) -o $@ $(OBJS) $(LDFLAGS)
clean:
$(RM) $(OBJS)
$(RM) $(PROGNAME)
mrproper: clean
help:
@echo "CAO daemon Makefile targets:"
@echo
@echo "Build:"
@echo " all\t\t- build all cao objects, libraries and executables,"
@echo
@echo "Cleaning:"
@echo " clean\t\t- remove caod objects and executables,"
@echo " libclean\t- remove external library build files,"
@echo " mrproper\t- clean everything,"
@echo
@echo "Makefile variables:"
@echo " CROSS_COMPILE\t- cross-toolchain prefix,"
@echo " ARCH\t\t- build architecture,"
@echo " DEBUG\t\t- compile additional debug messages and pass the -g"
@echo " \t\t flag to gcc, you can also specify a level for said flag,"
@echo
.PHONY: all clean mrproper help print
.DEFAULT_GOAL :=
.DEFAULT_GOAL := all
%.o: %.c
$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $^
%.o: %.cpp
$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $^
|