From afe4fd5ed0c6693efcda8f276d611bcd737af6be Mon Sep 17 00:00:00 2001 From: heck Date: Sat, 10 Jun 2023 19:47:33 +0200 Subject: [PATCH] init - raw structure and makefiles from Orca-c Heck Fork --- .clang-format | 42 ++++++++++++++++++++++++ .gitignore | 26 +++++++++++++++ LICENSE.md | 21 ++++++++++++ Makefile | 13 ++++++++ Makefile.conf | 80 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + build.conf.example | 5 +++ src/Makefile | 32 +++++++++++++++++++ test/Makefile | 31 ++++++++++++++++++ 9 files changed, 251 insertions(+) create mode 100644 .clang-format create mode 100644 .gitignore create mode 100644 LICENSE.md create mode 100644 Makefile create mode 100644 Makefile.conf create mode 100644 README.md create mode 100644 build.conf.example create mode 100644 src/Makefile create mode 100644 test/Makefile diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..0fa41a7 --- /dev/null +++ b/.clang-format @@ -0,0 +1,42 @@ +BasedOnStyle: LLVM +ReflowComments: false + +MacroBlockBegin: "^BEGIN_OPERATOR" +MacroBlockEnd: "^END_OPERATOR" + +Language: Cpp +DerivePointerAlignment: true +SortIncludes: Never +PointerAlignment: Left +AlignAfterOpenBracket: AlwaysBreak +AlignOperands: AlignAfterOperator +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +BinPackArguments: false +BinPackParameters: false +ExperimentalAutoDetectBinPacking: true +BreakBeforeBraces: Custom +BraceWrapping: + AfterFunction: true +ColumnLimit: 100 +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +PenaltyBreakBeforeFirstCallParameter: 0 +PenaltyReturnTypeOnItsOwnLine: 1000000 +PenaltyBreakAssignment: 1000000 +PenaltyExcessCharacter: 10 +IndentCaseLabels: true +IndentWidth: 4 +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +SpaceAfterTemplateKeyword: false +AccessModifierOffset: -4 +AllowShortBlocksOnASingleLine: Always +IndentPPDirectives: BeforeHash +IndentExternBlock: Indent +Cpp11BracedListStyle: false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb9898e --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Build config +/build.conf +/.idea + +# Prerequisites +*.d + +# Object files +*.o + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.a + +# Executables + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +#Test \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9714691 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Hundredrabbits + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6d34a31 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: all test src clean + +all: test src + +src: + $(MAKE) -C src + +test: + $(MAKE) -C test + +clean: + $(MAKE) -C src clean + $(MAKE) -C test clean \ No newline at end of file diff --git a/Makefile.conf b/Makefile.conf new file mode 100644 index 0000000..a39d12e --- /dev/null +++ b/Makefile.conf @@ -0,0 +1,80 @@ +LIBNAME:=heck_log +LIB:=lib$(LIBNAME).a + +C_LANG_VERSION=c99 +CXX_LANG_VERSION=c++17 + +# Build option defaults +PREFIX?=$(HOME)/local +SYS_PREFIX?=/opt/local +DEBUG?=1 + +COMPILE_FLAGS:= -MMD + +CFLAGS:=-std=$(C_LANG_VERSION) +CFLAGS+=\ + -finput-charset=UTF-8 \ + -Wpedantic \ + -Wextra \ + -Wwrite-strings \ + -Wconversion \ + -Wshadow \ +# -Wstrict-prototypes \ +# -Werror=implicit-function-declaration \ + -Werror=implicit-int \ + -Werror=incompatible-pointer-types \ + -Werror=int-conversion \ + -Wno-missing-field-initializers \ + +CXXFLAGS:=-std=$(CXX_LANG_VERSION) +CXXFLAGS+=\ + -fPIC \ + -Wall \ + -Wextra \ + -pedantic + +ifneq (,$(findstring g++,$(CXX))) + COMPILE_FLAGS+=-fdiagnostics-color=always +else ifneq (,$(findstring clang,$(CXX))) + COMPILE_FLAGS+=-fcolor-diagnostics +endif + +LIBS:=-lstdc++ +#-lpEpCxx11 + +LDFLAGS+=$(LIBS) + +######### Overrides from build.conf ######### +HERE:=$(dir $(lastword $(MAKEFILE_LIST))) +-include $(HERE)build.conf + +COMPILE_FLAGS+=-isystem$(SYS_PREFIX)/include +COMPILE_FLAGS+=-I$(PREFIX)/include +LDFLAGS+=-L$(SYS_PREFIX)/lib +LDFLAGS+=-L$(PREFIX)/lib + +ifeq ($(DEBUG),1) + COMPILE_FLAGS+=-g -O0 -DDEBUG +# -fsanitize=address \ +# -fsanitize=undefined \ +# -fsanitize=float-divide-by-zero \ +# -fsanitize=implicit-conversion \ +# -fsanitize=unsigned-integer-overflow +else + COMPILE_FLAGS+=-DNDEBUG -O2 -g0 +endif + +ifeq ($(PORTMIDI_ENABLED),1) + COMPILE_FLAGS+= -DFEAT_PORTMIDI + LDFLAGS+= -lportmidi +endif + +ifeq ($(MOUSE_ENABLED),0) + COMPILE_FLAGS+=-DFEAT_NOMOUSE +endif + +CXXFLAGS+=$(COMPILE_FLAGS) +CFLAGS+=$(COMPILE_FLAGS) + +$(info C-Compiler: $(shell $(CC) --version)) +$(info C++-Compiler: $(shell $(CXX) --version)) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f3c1727 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Vulkan Hello World diff --git a/build.conf.example b/build.conf.example new file mode 100644 index 0000000..592a445 --- /dev/null +++ b/build.conf.example @@ -0,0 +1,5 @@ +# The following values reflect the defaults +# uncomment and adjust + +# DEBUG?=1 +# PREFIX=/opt/local diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..a38eee1 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,32 @@ +include ../Makefile.conf + +SRC:=$(wildcard *.c*) +SRC_EXE:=$(filter main_%, $(SRC)) +SRC_LIB=$(filter-out main_%, $(SRC)) +OBJS:=$(addsuffix .o, $(basename $(SRC))) +OBJS_LIB:=$(addsuffix .o, $(basename $(SRC_LIB))) +EXE:=$(basename $(SRC_EXE)) +DEPS:=$(addsuffix .d, $(basename $(SRC))) + +.PHONY: all install uninstall clean +.DEFAULT_GOAL:= all + +ifneq ($(MAKECMDGOALS),clean) + -include $(DEPS) +endif + +all: $(EXE) + +$(LIB): $(OBJS) + $(AR) -rc $@ $(OBJS_LIB) + +$(EXE) : $(LIB) + +clean: + rm -rf \ + $(OBJS) \ + $(EXE) \ + $(LIB) \ + *.d \ + *.dSYM \ + *.h.gch \ No newline at end of file diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..1363b54 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,31 @@ +include ../Makefile.conf + +SRC:=$(wildcard *.c*) +SRC_EXE:=$(filter test_%, $(SRC)) +EXE:=$(basename $(SRC_EXE)) + +$(info src exe: $(SRC_EXE)) +$(info lib: $(LIB)) +$(info exe: $(EXE)) + +LDFLAGS+=-L../src +CFLAGS+=-I../src +CXXFLAGS+=-I../src + +.PHONY: lib all clean ../src/$(LIB) +.DEFAULT_GOAL := all + +all: $(EXE) + +../src/$(LIB): + $(MAKE) -C ../src $(LIB) + +$(EXE): ../src/$(LIB) + +clean: + rm -rf \ + $(OBJS) \ + $(EXE) \ + *.d \ + *.dSYM \ + *.h.gch \ No newline at end of file