## Copyright (C) 2014-2016 ## Olivier Gayot ## Bartosz Golaszewski ## Olivier Gayot ## ## 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) $^