-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
executable file
·39 lines (30 loc) · 972 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
SRCDIR = src
INCDIR = src/include
OBJDIR = obj
BINDIR = bin
OUTNAME = clfc
CC = gcc
CFLAGS = -std=c99 -g -Wall -I. -I$(INCDIR) -v
LINKER = gcc -o
LFLAGS = -Wall -g -I. -lm -v
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
SOURCES := $(wildcard $(SRCDIR)/*.c) $(wildcard $(SRCDIR)/*/*.c)
HEADERS := $(wildcard $(INCDIR)/*.h) $(wildcard $(INCDIR)/*/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
RMCMD := rm -rf
compile: $(OBJECTS)
@$(LINKER) $(BINDIR)/$(OUTNAME) $(LFLAGS) $(OBJECTS)
@echo "Linking ok!"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@$(CC) $(CFLAGS) -c $< -o $@
echo "\nArquivo "$<" compilado com sucesso."
clean:
@$(shell find $(OBJDIR)/ -iname "*.o" | xargs -0 /bin/rm -f)
@$(shell find $(BINDIR)/ | xargs -0 /bin/rm -f)
clear
@echo "\nCompilador LFC\n"
@echo "Limpeza realizada com sucesso!"
ls:
@echo "Sources: $(SOURCES)"
@echo "Headers: $(HEADERS)"
@echo "Objects: $(OBJECTS)"