-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (39 loc) · 803 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# compiler e linker
CC := gcc
# eseguibile
EXECUTABLE := program
# cartelle
SRCDIR := src
INCDIR := inc
OBJDIR := obj
BINDIR := bin
# flags
CPPFLAGS := -I./$(INCDIR)
CFLAGS := -Wall
LDFLAGS :=
LDLIBS := -lgsl -lgslcblas -lm
# file sorgente
SRC := $(wildcard $(SRCDIR)/*.c)
# file oggetto
OBJ := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))
# default
all: $(EXECUTABLE)
# remake
remake: cleaner all
# link
$(EXECUTABLE): $(OBJ) | $(BINDIR)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $(BINDIR)/$@
# compile
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# crea cartelle
$(BINDIR) $(OBJDIR):
@mkdir -p $@
# rimuove solo oggetti
clean:
@$(RM) -rv $(OBJDIR)
# rimuove tutto
cleaner: clean
@$(RM) -rv $(BINDIR)
# non-file targets
.PHONY: all remake clean cleaner