Initial commit

This commit is contained in:
Thomas Klaehn 2019-10-27 13:04:07 +01:00
commit cc2432fc27
4 changed files with 109 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
bin/
obj/

33
.vscode/tasks.json vendored Normal file
View File

@ -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
}
}
]
}

66
Makefile Normal file
View File

@ -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

7
src/main.cc Normal file
View File

@ -0,0 +1,7 @@
#include <iostream>
int main(void) {
std::cout << "Hello World!!!" << std::endl;
return 0;
}