add helloworld-c-make
This commit is contained in:
parent
2d29797403
commit
7c891b99e8
14
helloworld-c-make/.clang-format
Normal file
14
helloworld-c-make/.clang-format
Normal file
@ -0,0 +1,14 @@
|
||||
BasedOnStyle: WebKit
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 80
|
||||
IndentCaseLabels: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterFunction: true
|
||||
SplitEmptyFunction: false
|
||||
AlignAfterOpenBracket: BlockIndent
|
||||
AlignOperands: AlignAfterOperator
|
||||
BreakBeforeBinaryOperators: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
|
5
helloworld-c-make/.clangd
Normal file
5
helloworld-c-make/.clangd
Normal file
@ -0,0 +1,5 @@
|
||||
CompileFlags:
|
||||
CompilationDatabase: build/compile_flags.txt
|
||||
Remove:
|
||||
- -Wempty-translation-unit
|
||||
|
3
helloworld-c-make/.gitignore
vendored
Normal file
3
helloworld-c-make/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
build/
|
||||
.cache/
|
||||
|
41
helloworld-c-make/Makefile
Normal file
41
helloworld-c-make/Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
EXECUTABLE = helloworld-c-make
|
||||
|
||||
INSTALL_PREFIX = /usr/local
|
||||
|
||||
CFLAGS = -std=c17 -Wall -Wextra -pedantic -pedantic-errors -O2
|
||||
LFLAGS =
|
||||
|
||||
LD=gcc
|
||||
CC=gcc
|
||||
|
||||
SOURCE_FILES = \
|
||||
src/main.c
|
||||
|
||||
OBJECT_FILES = $(patsubst src/%.c, build/%.o, $(SOURCE_FILES))
|
||||
|
||||
HEADER_FILES = $(shell find src/ -name *.h)
|
||||
|
||||
all: build/$(EXECUTABLE) build/compile_flags.txt
|
||||
|
||||
install: build/$(EXECUTABLE)
|
||||
cp build/$(EXECUTABLE) $(INSTALL_PREFIX)/bin/$(EXECUTABLE)
|
||||
|
||||
build/$(EXECUTABLE): $(OBJECT_FILES)
|
||||
$(LD) -o $@ $(LFLAGS) $^
|
||||
|
||||
build/%.o: src/%.c $(HEADER_FILES) build-folder
|
||||
$(CC) -c -o $@ $(CFLAGS) $<
|
||||
|
||||
build-folder:
|
||||
mkdir -p build/
|
||||
|
||||
clean:
|
||||
$(RM) build/
|
||||
|
||||
build/compile_flags.txt:
|
||||
echo -xc $(CFLAGS) \
|
||||
| tr ' ' '\n' \
|
||||
> $@
|
||||
|
||||
|
18
helloworld-c-make/README.md
Normal file
18
helloworld-c-make/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
# helloworld-c-make
|
||||
|
||||
```
|
||||
make
|
||||
./build/helloworld-c-make
|
||||
```
|
||||
|
||||
```
|
||||
make
|
||||
|
||||
sudo make install
|
||||
# or
|
||||
sudo make INSTALL_PREFIX=/usr/local install
|
||||
|
||||
helloworld-c-make
|
||||
```
|
||||
|
3
helloworld-c-make/src/main.c
Normal file
3
helloworld-c-make/src/main.c
Normal file
@ -0,0 +1,3 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) { printf("Hello, world!\n"); }
|
Loading…
Reference in New Issue
Block a user