Skip to content
Snippets Groups Projects
Verified Commit 3c0c88d3 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

playground for makefiles

parent 4d129e98
No related branches found
No related tags found
No related merge requests found
*.o
main
CC = gcc
CFLAGS = -g -Wall -O0 -std=c11
LDFLAGS = -lm
# SOURCES = main.c foo.c bar.c
# means *.c
SOURCES = $(wildcard *.c)
# OBJECTS contient SOURCES avec .c -> .o
OBJECTS = $(SOURCES:.c=.o)
# OBJECTS := $(patsubst %.c,%.o,$(wildcard *.c))
# galaxy sera l'exécutable (galaxy.c contient le main)
TARGET = main
$(TARGET) : $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# main: main.o foo.o bar.o
# cc -o $@ $^ $(CFLAGS) $(LDFLAGS)
#
# foo.o: foo.h
# bar.o: bar.h
# main.o: foo.h
.PHONY: clean
clean:
rm -f $(TARGET) $(OBJECTS)
# clean:
# rm -f *.o main
\ No newline at end of file
#include "bar.h"
#include "foo.h"
void bar() {
foo();
}
\ No newline at end of file
#ifndef _BAR_H_
#define _BAR_H_
void bar();
#endif
#include "foo.h"
void foo() {
}
\ No newline at end of file
#ifndef _FOO_H_
#define _FOO_H_
void foo();
#endif
#include "foo.h"
int main() {
foo();
return 0;
}
\ No newline at end of file
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