-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
73 lines (54 loc) · 1.86 KB
/
makefile
File metadata and controls
73 lines (54 loc) · 1.86 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
TARGET := cimage
SDL2 := `sdl2-config --cflags --libs` -l SDL2_image -l SDL2_ttf
MATH := -lm
PTHREAD := -l pthread
# FFMPEG := -l avutil -l avformat -l avcodec -l avutil -l swresample
# development
DEVELOPMENT = -D CENGINE_DEBUG
# additional cimage info
CIMAGE_DEBUG = -D CIMAGE_DEBUG
DEFINES = $(CIMAGE_DEBUG) $(DEVELOPMENT)
CC := gcc
SRCDIR := src
INCDIR := include
BUILDDIR := objs
TARGETDIR := bin
SRCEXT := c
DEPEXT := d
OBJEXT := o
CFLAGS := -g $(DEFINES)
# LIB := $(MATH) $(PTHREAD) $(SDL2) $(FFMPEG)
LIB := $(MATH) $(PTHREAD) $(SDL2)
INC := -I $(INCDIR) -I /usr/local/include
INCDEP := -I $(INCDIR)
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
all: directories $(TARGET)
run:
./$(TARGETDIR)/$(TARGET)
remake: clean all
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
# clean only Objecst
clean:
@$(RM) -rf $(BUILDDIR) @$(RM) -rf $(TARGETDIR)
# full Clean, Objects and Binaries
cleaner: clean
@$(RM) -rf $(TARGETDIR)
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
# link
$(TARGET): $(OBJECTS)
$(CC) $^ $(LIB) -o $(TARGETDIR)/$(TARGET)
# compile
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(dir $@)
$(CC) $(LIB) $(CFLAGS) $(INC) -c -o $@ $<
@$(CC) $(CFLAGS) $(INCDEP) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp
@sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT)
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT)
@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp
# non-file Targets
.PHONY: all remake clean cleaner resources