-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (33 loc) · 1023 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
APP := bin
CCFLAGS := -Wall -pedantic
CFLAGS := $(CCFLAGS)
CC := g++
C := gcc
LIBS := -lSDL2 -lSDL2_image -lSDL2_ttf
MKDIR := mkdir -p
SRC := source
OBJ := obj
ALLCS := $(shell find $(SRC) -type f -iname *.c)
ALLCSOBJ := $(patsubst %.c,%.o,$(ALLCS))
ALLCPPS := $(shell find $(SRC) -type f -iname *.cpp)
ALLCPPSOBJ := $(patsubst %.cpp,%.o,$(ALLCPPS))
SUBDIRS := $(shell find $(SRC) -type d)
OBJSUBDIRS := $(patsubst $(SRC)%,$(OBJ)%,$(SUBDIRS))
.PHONY: dir
$(APP) : $(OBJSUBDIRS) $(ALLCPPSOBJ) $(ALLCPPSOBJ)
$(CC) -o $(APP) $(patsubst $(SRC)%,$(OBJ)%,$(ALLCPPSOBJ) $(ALLCSOBJ)) $(LIBS)
%.o : %.c
$(C) -o $(patsubst $(SRC)%,$(OBJ)%,$@) -c $^ $(CFLAGS)
%.o : %.cpp
$(CC) -o $(patsubst $(SRC)%,$(OBJ)%,$@) -c $^ $(CCFLAGS)
#dir no es un fichero de salida
#dir es un objetivo .PHONY - esto se lanza solo cuando está desactualizado
dir:
$(info $(SUBDIRS))
$(info $(OBJSUBDIRS))
$(info $(ALLCS))
$(info $(ALLCSOBJ))
$(info $(ALLCPPS))
$(info $(ALLCPPSOBJ))
$(OBJSUBDIRS):
$(MKDIR) $(OBJSUBDIRS)