Skip to content

Commit 9f00048

Browse files
committed
<Upload> folder structure, Makefile and template code
1 parent 6cea410 commit 9f00048

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

bin/Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
include_dir = ../include
2+
src_dir = ../src
3+
4+
TARGET = prog
5+
CFLAGS = -c -MD $(addprefix -I,$(include_dir))
6+
7+
source_dirs = $(include_dir) $(src_dir)
8+
9+
src_search_wildcards = $(addsuffix /*.c,$(src_dir))
10+
11+
all: $(TARGET)
12+
13+
$(TARGET): $(notdir $(patsubst %.c,%.o,$(wildcard $(src_search_wildcards))))
14+
$(CC) $^ -o $@
15+
16+
vpath %.h $(include_dir)
17+
vpath %.c $(src_dir)
18+
19+
%.o: %.c
20+
$(CC) $(CFLAGS) $<
21+
22+
include $(wildcard *.d)
23+
24+
25+
.PHONY: clean
26+
27+
clean:
28+
rm $(TARGET) *.d *.o

include/module.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef _MODULE_H
2+
#define _MODULE_H
3+
4+
void module_func(int x);
5+
6+
#endif

src/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <stdio.h>
2+
3+
#include "module.h"
4+
5+
6+
int main() {
7+
printf("Hello, World!\n");
8+
9+
module_func(7);
10+
11+
return 0;
12+
}

src/module.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdio.h>
2+
3+
#include "module.h"
4+
5+
6+
void module_func(int x) {
7+
printf("\nIn module function! Argument: %d\n", x);
8+
}

0 commit comments

Comments
 (0)