Compare commits

...

10 Commits

Author SHA1 Message Date
Stephan Rehfeld
f4d5c3eba9 Added LICENSE file 2025-11-03 17:36:06 +01:00
Stephan Rehfeld
179152cf5b Added Debug and Release mode to Makefile 2025-11-03 17:34:09 +01:00
Stephan Rehfeld
c75ed48cc6 Made project name adjustable 2025-11-03 17:31:01 +01:00
Stephan Rehfeld
652828c29d Changed makefile so that the compiler writed dependencies to disk
and that dependencies are included into Makefile
2025-11-03 17:28:42 +01:00
Stephan Rehfeld
0de00b46fb Added feature bar 2025-11-03 17:21:50 +01:00
Stephan Rehfeld
eaaca7b281 Adjusted Makefile rule to be more intelligent 2025-11-03 17:17:11 +01:00
Stephan Rehfeld
611ed74150 Made compiler adjustable in Makefile 2025-11-03 17:15:21 +01:00
Stephan Rehfeld
1848235551 Split compilation in smaller units 2025-11-03 17:14:05 +01:00
Stephan Rehfeld
80b550e6ec Added .gitignore file to project. 2025-11-03 17:10:46 +01:00
Stephan Rehfeld
8bfba44ede Implemented feature foo 2025-11-03 17:09:48 +01:00
8 changed files with 70 additions and 4 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
a.out
example
*.swp
*.o
*.d

8
LICENSE Normal file
View File

@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright © 2025 Stephan Rehfeld
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.

View File

@ -1,7 +1,29 @@
example: main.c PROJECT = example
cc main.c -o example
.PHONY: clean CFLAGS += -Wall -Wextra -pedantic -Werror -std=c23
# For Debug Build
CFLAGS += -g -O0
# For Release Build
#CFLAGS += -O3 -DNDEBUG
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
DEPENDS = $(SOURCES:.c=.d)
DEPFLAGS = -MMD -MP
$(PROJECT): $(OBJECTS)
$(CC) $(OBJECTS) -o $@
%.o: %.c
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
-include $(DEPENDS)
.PHONY: clean all
all: $(PROJECT)
clean: clean:
rm -f example rm -f $(PROJECT) $(OBJECTS) $(DEPENDS)

7
bar.c Normal file
View File

@ -0,0 +1,7 @@
#include "bar.h"
#include <stdio.h>
void bar(void) {
puts("Hello World from bar().");
}

6
bar.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef BAR_H
#define BAR_H
void bar(void);
#endif

7
foo.c Normal file
View File

@ -0,0 +1,7 @@
#include "foo.h"
#include <stdio.h>
void foo(void) {
puts("Hello World from foo().");
}

6
foo.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef FOO_H
#define FOO_H
void foo(void);
#endif

5
main.c
View File

@ -1,7 +1,12 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "foo.h"
#include "bar.h"
int main(void) { int main(void) {
puts("Hello World"); puts("Hello World");
foo();
bar();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }