diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 36 |
1 files changed, 25 insertions, 11 deletions
@@ -17,24 +17,38 @@ ## 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 +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ USERFLAGS = -CFLAGS += -I./include -I/usr/local/include -W -Wall -Wextra +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 -OBJS = daemon.o log.o misc.o +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 -all: $(PROGNAME) +print: + echo $(SRCS_C) + +all: print $(PROGNAME) $(PROGNAME): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) + $(CXX) -o $@ $(OBJS) $(LDFLAGS) clean: $(RM) $(OBJS) @@ -60,12 +74,12 @@ help: @echo " \t\t flag to gcc, you can also specify a level for said flag," @echo -.PHONY: all clean mrproper help -.PRECIOUS: %.c -.SUFFIXES: -.SUFFIXES: .o .c +.PHONY: all clean mrproper help print .DEFAULT_GOAL := .DEFAULT_GOAL := all -.c.o: - $(CC) -c -o $*.o $(CFLAGS) $(DEBUGFLAGS) $*.c +%.o: %.c + $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $^ + +%.o: %.cpp + $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $^ |