Skip to content
Snippets Groups Projects
Commit 9aeef3d3 authored by Lucas Christesen Ahler's avatar Lucas Christesen Ahler
Browse files

Lecture 2 Makefile exercise

parent f4b092c3
No related branches found
No related tags found
No related merge requests found
CC = gcc
CFLAGS = -O -std=gnu11
LDLIBS = -lm
default: out.txt
cat out.txt
out.txt: hello
./hello > out.txt
hello: hello.o
$(CC) -o hello hello.o $(LDLIBS)
hello.o: hello.c
$(CC) $(CFLAGS) -c hello.c
clean:
$(RM) -f hello.o hello out.txt
test:
echo $(CC)
echo $(CDFLAGS)
echo $(LDLIB)
echo $(RM)
#include<stdio.h>
#include<math.h>
int main() {
double x = sqrt(2.0);
printf("Hello, sqrt(2)=%g\n", x);
return 0;
}
Hello, sqrt(2)=1.41421
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment