forked from ImpactEntertainment/Emperor_vs_Aliens
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (56 loc) · 2.04 KB
/
Makefile
File metadata and controls
77 lines (56 loc) · 2.04 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
#version
MAJOR_VERSION=1
MINOR_VERSION=5
MICRO_VERSION=0
VERSION=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
export LD := $(CXX)
export OFILES := $(addprefix $(BUILD)/,$(CPPFILES:.cpp=.o))
CPPFILES := $(addprefix $(SOURCES)/,$(CPPFILES))
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \
-I$(CURDIR)/$(BUILD)
# Compiler
TARGET := $(notdir $(CURDIR))
# Object files
LIBS := -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf
# Flags
CPPFLAGS=-Wall -g -W -pedantic -ansi
# Linking flags
LDFLAGS= $(LIBS)
$(BUILD)/%.o:$(SOURCES)/%.cpp
@mkdir -p $(BUILD)
@echo building $^ ...
@$(LD) $(CPPFLAGS) -c $^ -o $@ $(INCLUDE)
main:$(OFILES)
@mkdir -p $(BUILD)
@echo linking ...
@$(LD) $(OFILES) $(CPPFLAGS) $(LDFLAGS) -o $(TARGET)
@echo "$(TARGET)-$(VERSION)"
# Cleanup
clean:
@echo clean ...
@rm -rf $(BUILD)
@rm -f $(TARGET)
install:
@sudo mkdir -p /opt/$(TARGET)
@sudo cp -Rf data /opt/$(TARGET)/
@sudo cp -f $(TARGET) /opt/$(TARGET)/$(TARGET)
@sudo ln -sf /opt/$(TARGET)/$(TARGET) /usr/local/bin/$(TARGET)
uninstall:
@sudo rm -rf /opt/$(TARGET)
@sudo rm -f /usr/local/bin/$(TARGET)