Ajout d'un test intéressant d'un autre groupe
This commit is contained in:
parent
8ea9466dc4
commit
80bdd3c964
@ -0,0 +1,25 @@
|
|||||||
|
# Bakefile
|
||||||
|
|
||||||
|
# Define variables
|
||||||
|
SRC_DIR = .
|
||||||
|
BUILD_DIR = .
|
||||||
|
|
||||||
|
# Target to create directories
|
||||||
|
setup:
|
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
|
# Target to compile the C source files using a loop
|
||||||
|
compile: setup
|
||||||
|
for file in $(SRC_DIR)/*.c; do gcc -c $$file -o $(BUILD_DIR)/$(notdir $(basename $$file .c)).o; done
|
||||||
|
|
||||||
|
# Target to link the object files into an executable
|
||||||
|
link: compile
|
||||||
|
gcc -o $(BUILD_DIR)/test_program $(BUILD_DIR)/*.o
|
||||||
|
|
||||||
|
# Target to run the compiled program
|
||||||
|
run: link
|
||||||
|
$(BUILD_DIR)/test_program
|
||||||
|
|
||||||
|
# Clean target to remove created directories and files
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "utils1.h"
|
||||||
|
#include "utils2.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf("Main program started!\n");
|
||||||
|
print_hello_from_utils1();
|
||||||
|
print_hello_from_utils2();
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void print_hello_from_utils1() {
|
||||||
|
printf("Hello from Utils1!\n");
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef UTILS1_H
|
||||||
|
#define UTILS1_H
|
||||||
|
|
||||||
|
void print_hello_from_utils1();
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,5 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void print_hello_from_utils2() {
|
||||||
|
printf("Hello from Utils2!\n");
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef UTILS2_H
|
||||||
|
#define UTILS2_H
|
||||||
|
|
||||||
|
void print_hello_from_utils2();
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,25 @@
|
|||||||
|
# Makefile
|
||||||
|
|
||||||
|
# Define variables
|
||||||
|
SRC_DIR = .
|
||||||
|
BUILD_DIR = .
|
||||||
|
|
||||||
|
# Target to create directories
|
||||||
|
setup:
|
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
|
# Target to compile the C source files using a loop
|
||||||
|
compile: setup
|
||||||
|
for file in $(SRC_DIR)/*.c; do gcc -c $$file -o $(BUILD_DIR)/$(notdir $(basename $$file .c)).o; done
|
||||||
|
|
||||||
|
# Target to link the object files into an executable
|
||||||
|
link: compile
|
||||||
|
gcc -o $(BUILD_DIR)/test_program $(BUILD_DIR)/*.o
|
||||||
|
|
||||||
|
# Target to run the compiled program
|
||||||
|
run: link
|
||||||
|
$(BUILD_DIR)/test_program
|
||||||
|
|
||||||
|
# Clean target to remove created directories and files
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR)
|
@ -0,0 +1,10 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "utils1.h"
|
||||||
|
#include "utils2.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf("Main program started!\n");
|
||||||
|
print_hello_from_utils1();
|
||||||
|
print_hello_from_utils2();
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void print_hello_from_utils1() {
|
||||||
|
printf("Hello from Utils1!\n");
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef UTILS1_H
|
||||||
|
#define UTILS1_H
|
||||||
|
|
||||||
|
void print_hello_from_utils1();
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,5 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void print_hello_from_utils2() {
|
||||||
|
printf("Hello from Utils2!\n");
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef UTILS2_H
|
||||||
|
#define UTILS2_H
|
||||||
|
|
||||||
|
void print_hello_from_utils2();
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user