This commit is contained in:
Imbus 2023-12-02 07:12:56 +01:00
commit 5069b41630
7 changed files with 69 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.tar.gz
build

39
Justfile Normal file
View file

@ -0,0 +1,39 @@
run: build
./build/main
build: mkdir objects
gcc build/*.o -o build/main -O3
du -h build/main
objects: mkdir
cd build && gcc -c -I ../lib -Wall -Werror -fpic ../src/*.c -O3
du -h build/*.o
asm: mkdir
cd build && gcc -S -masm=intel -I ../lib -Wall -Werror -fpic ../src/*.c -O3
release: mkdir build
strip build/main
tar -czvf build.tar.gz build
mkdir:
mkdir build -p
clean:
rm *.tar.gz -f
rm -rf build
hex: build
objdump -M intel -d build/main
symbols: build
nm build/main
symbols2: build
readelf -s build/main
rodata: build
objdump -s -j .rodata build/main
fmt:
fd -e c -e h -x clang-format --verbose -i {}

3
lib/fib.h Normal file
View file

@ -0,0 +1,3 @@
#pragma once
int fib(int n);

3
lib/greet.h Normal file
View file

@ -0,0 +1,3 @@
#pragma once
void greet(const char *name);

7
src/fib.c Normal file
View file

@ -0,0 +1,7 @@
#include "fib.h"
int fib(int n) {
if (n < 2)
return n;
return fib(n - 1) + fib(n - 2);
}

8
src/greet.c Normal file
View file

@ -0,0 +1,8 @@
#include "greet.h"
#include "fib.h"
#include <stdio.h>
void greet(const char *name) {
printf("Hello %s!\n", name);
printf("Fibonacci of 10 is %d\n", fib(10));
}

7
src/main.c Normal file
View file

@ -0,0 +1,7 @@
#include "greet.h"
#include <stdio.h>
int main(void) {
greet("Template");
return 0;
}