From cc2432fc2766cecbf7d396f36720e947f5cfd4bb Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Sun, 27 Oct 2019 13:04:07 +0100 Subject: [PATCH] Initial commit --- .gitignore | 3 +++ .vscode/tasks.json | 33 +++++++++++++++++++++++ Makefile | 66 ++++++++++++++++++++++++++++++++++++++++++++++ src/main.cc | 7 +++++ 4 files changed, 109 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/tasks.json create mode 100644 Makefile create mode 100644 src/main.cc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6f63c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin/ +obj/ + diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..32725cd --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "type": "shell", + "command": "make", + "echoCommand": true, + "problemMatcher": { + "base": "$gcc", + }, + "presentation": { + "focus": true, + "reveal": "always", + "panel": "shared", + "clear": true, + }, + "tasks": [ + { + "label": "all", + "args": ["all"], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "clean", + "args": ["clean"], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b47e0be --- /dev/null +++ b/Makefile @@ -0,0 +1,66 @@ +CROSS_COMPILE ?= + +TARGET_FILE ?= test + +C_FLAGS += -Wall -Werror -DGNU -D__GNU__ -D__GCC__ +C_FLAGS += -Os +C_FLAGS += -ffunction-sections +C_FLAGS += -fdata-sections +C_FLAGS += -std=c18 +C_FLAGS += -pedantic +C_FLAGS += -pedantic-errors +C_FLAGS += -ggdb3 +C_FLAGS += -Iinclude + +CXXFLAGS += -Os +CXXFLAGS += -ggdb3 +CXXFLAGS += -std=c++17 +CXXFLAGS += -pedantic +CXXFLAGS += -pedantic-errors +CXXFLAGS += -ffunction-sections -fdata-sections +CXXFLAGS += -fno-implicit-inline-templates + + +LD_LIBS := -lc -lgcc + +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ + +OBJ_DIR := obj +BIN_DIR := bin +SRC_DIR := src + +CC_SRCS = $(wildcard $(SRC_DIR)/*.cc) + +CC_OBJS = $(patsubst %.cc,$(OBJ_DIR)/%.o,$(notdir $(CC_SRCS))) + +OBJS = $(CC_OBJS) +TARGET = $(BIN_DIR)/$(TARGET_FILE) + + +.PHONY: all +all: $(TARGET) + +$(TARGET): $(OBJS) Makefile + @mkdir -p $(BIN_DIR) + $(CXX) $(LD_FLAGS) $(OBJS) $(LD_LIBS) -o $@ + +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc + @mkdir -p $(dir $@) + @$(call makedep,$<,$@,$(patsubst %.cc,%.d,$(OBJ_DIR)/$(notdir $<)),$(CXXFLAGS)) + $(CXX) -c $(CXXFLAGS) -o $@ $< + +.PHONY: clean +clean: + rm -rf \ + $(OBJS) \ + $(patsubst %.o,%.d,$(OBJS)) \ + $(TARGET) + +define makedep + $(CXX) -MM -MF $3 -MP -MT $2 $4 $1 +endef + +ifneq ($(MAKECMDGOALS),clean) +-include $($(subst .o,.d,$(OBJS)) +endif diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..1f1c385 --- /dev/null +++ b/src/main.cc @@ -0,0 +1,7 @@ +#include + +int main(void) { + std::cout << "Hello World!!!" << std::endl; + + return 0; +}