-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
79 lines (59 loc) · 2.15 KB
/
makefile
File metadata and controls
79 lines (59 loc) · 2.15 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
74
75
76
77
78
79
# TARGET := cengine
SLIB := libcengine.so
SDL2 := `sdl2-config --cflags --libs` -l SDL2_image -l SDL2_ttf
MATH := -lm
PTHREAD := -l pthread
# development
DEVELOPMENT := -D CENGINE_DEBUG
CLIENT_DEFINES := -D CERVER_DEBUG -D CLIENT_DEBUG -D PACKETS_DEBUG -D AUTH_DEBUG
DEFINES = $(DEVELOPMENT) $(CLIENT_DEFINES)
CC := gcc
SRCDIR := src
INCDIR := include
BUILDDIR := objs
TARGETDIR := bin
SRCEXT := c
DEPEXT := d
OBJEXT := o
CFLAGS := -g $(DEFINES) -Wall -Wno-unknown-pragmas -Wfatal-errors -fPIC
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)
all: directories $(SLIB)
# run:
# ./$(TARGETDIR)/$(TARGET)
install: $(SLIB)
install -m 644 ./bin/libcengine.so /usr/local/lib/
cp -R ./include/cengine /usr/local/include
uninstall:
rm /usr/local/lib/libcengine.so
rm -r /usr/local/include/cengine
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
clean:
@$(RM) -rf $(BUILDDIR) @$(RM) -rf $(TARGETDIR)
@$(RM) -rf ./examples/bin
# pull in dependency info for *existing* .o files
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
# link
# $(TARGET): $(OBJECTS)
# $(CC) $^ $(LIB) -o $(TARGETDIR)/$(TARGET)
$(SLIB): $(OBJECTS)
$(CC) $^ $(LIB) -shared -o $(TARGETDIR)/$(SLIB)
# compile
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INC) $(LIB) -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
examples: ./examples/welcome.c
@mkdir -p ./examples/bin
$(CC) -I ./include -L ./bin ./examples/welcome.c -o ./examples/bin/welcome -l cengine
.PHONY: all clean examples