diff --git a/makefile b/makefile index 4164de0..dca13e2 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ -# C compiler to use -CC := gcc +# C++ compiler to use +CC := g++ # Directory mappings SRC_DIR := src @@ -9,12 +9,18 @@ OUT_DIR := out INC_DIR := include TST_DIR := test -# Map all object and source files -SRC_FILES := $(wildcard $(SRC_DIR)/**/*.c) $(wildcard $(LIB_DIR)/**/*.c) -OBJ_FILES := $(patsubst $(SRC_DIR)/**/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES)) +# Map all object and source files (C++) +SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard $(SRC_DIR)/**/*.cpp) $(wildcard $(LIB_DIR)/*.cpp) $(wildcard $(LIB_DIR)/**/*.cpp) +OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(SRC_DIR)/%.cpp,$(SRC_FILES))) \ + $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(SRC_DIR)/**/*.cpp,$(SRC_FILES))) \ + $(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/%.cpp,$(SRC_FILES))) \ + $(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/**/*.cpp,$(SRC_FILES))) -TST_FILES := $(wildcard $(TST_DIR)/*.c) $(wildcard $(LIB_DIR)/*.c) -OBJ_TST_FILES := $(patsubst $(TST_DIR)/%.c,$(OBJ_DIR)/%.o,$(TST_FILES)) +TST_FILES := $(wildcard $(TST_DIR)/*.cpp) $(wildcard $(TST_DIR)/**/*.cpp) $(wildcard $(LIB_DIR)/*.cpp) $(wildcard $(LIB_DIR)/**/*.cpp) +OBJ_TST_FILES := $(patsubst $(TST_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(TST_DIR)/%.cpp,$(TST_FILES))) \ + $(patsubst $(TST_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(TST_DIR)/**/*.cpp,$(TST_FILES))) \ + $(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/%.cpp,$(TST_FILES))) \ + $(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(filter $(LIB_DIR)/**/*.cpp,$(TST_FILES))) # All optional libs and Cflags to append to the final command LIBS := @@ -27,12 +33,12 @@ WARNFLAGS := -Wall -Wextra -Wconversion .PHONY: clean help .DEFAULT_GOAL := help -# Macro for creating object files -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c - $(CC) -c -o $@ $< +# Macro for creating object files (C++) +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp + $(CC) -c -o $@ $< $(CFLAGS) -$(OBJ_DIR)/%.o: $(TST_DIR)/%.c - $(CC) -c -o $@ $< +$(OBJ_DIR)/%.o: $(TST_DIR)/%.cpp + $(CC) -c -o $@ $< $(CFLAGS) ## All make commands ## help: ## Lists all commands diff --git a/src/main.c b/src/main.cpp similarity index 54% rename from src/main.c rename to src/main.cpp index b75c16d..ca75df1 100644 --- a/src/main.c +++ b/src/main.cpp @@ -2,12 +2,9 @@ /* Project description */ -#include -#include -#include - -#include "../../lib/util.h" +#include int main(int argc, char *argv[], char *env[]) { + std::cout << "yo!" << std::endl; return 0; }