Initial Commit

master
androiddrew 6 years ago
commit b07b9dc2fb

@ -0,0 +1,2 @@
all:
clang++ -std=c++11 main.cpp factorial.cpp hello.cpp -o hello

@ -0,0 +1,16 @@
all: hello
hello: main.o factorial.o hello.o
clang++ main.o factorial.o hello.o -o hello
main.o: main.cpp
clang++ -c main.cpp
factorial.o: factorial.cpp
clang++ -c factorial.cpp
hello.o: hello.cpp
clang++ -c hello.cpp
clean:
rm *o hello

@ -0,0 +1,23 @@
# I am a comment, and I want to stay that the variable CC will be the compiler to use
CC=clang++
# Hey CFLAGS will be the options I'll pass to the compiler
CFLAGS=-c -Wall
all: hello
hello: main.o factorial.o hello.o
$(CC) main.o factorial.o hello.o -o hello
main.o: main.cpp
$(CC) $(CFLAGS) main.cpp
factorial.o: factorial.cpp
$(CC) $(CFLAGS) factorial.cpp
hello.o: hello.cpp
$(CC) $(CFLAGS) hello.cpp
clean:
rm *o
rm hello

@ -0,0 +1,5 @@
# Make Tutorial
Just a simple 3 example tutorial on how to use Make files.
Source: https://opensource.com/article/18/8/what-how-makefile

@ -0,0 +1,9 @@
#include "functions.h"
int factorial(int n){
if(n!=1){
return(n * factorial(n-1));
}
else return 1;
}

@ -0,0 +1,2 @@
void print_hello();
int factorial(int n);

@ -0,0 +1,6 @@
#include <iostream>
#include "functions.h"
void print_hello(){
std::cout << "hello World";
}

@ -0,0 +1,9 @@
#include <iostream>
#include "functions.h"
int main(){
print_hello();
std::cout << std::endl;
std::cout << "The factorial of 5 is " << factorial(5) << std::endl;
return 0;
}
Loading…
Cancel
Save