-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
84 lines (65 loc) · 2.47 KB
/
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
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
80
81
82
83
84
DESTDIR =
PREFIX = /usr/local
tilemapstudio = tilemapstudio
tilemapstudiod = tilemapstudiod
CXX ?= g++
LD = $(CXX)
RM = rm -rf
srcdir = src
resdir = res
tmpdir = tmp
debugdir = tmp/debug
bindir = bin
CXXFLAGS = -std=c++17 -I$(srcdir) -I$(resdir) $(shell fltk-config --use-images --cxxflags)
LDFLAGS = $(shell fltk-config --use-images --ldflags) $(shell pkg-config --libs libpng xpm)
RELEASEFLAGS = -DNDEBUG -O3 -flto -march=native
DEBUGFLAGS = -DDEBUG -D_DEBUG -O0 -g -ggdb3 -Wall -Wextra -pedantic -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter
COMMON = $(wildcard $(srcdir)/*.h) $(wildcard $(resdir)/*.xpm)
SOURCES = $(wildcard $(srcdir)/*.cpp)
OBJECTS = $(SOURCES:$(srcdir)/%.cpp=$(tmpdir)/%.o)
DEBUGOBJECTS = $(SOURCES:$(srcdir)/%.cpp=$(debugdir)/%.o)
TARGET = $(bindir)/$(tilemapstudio)
DEBUGTARGET = $(bindir)/$(tilemapstudiod)
DESKTOP = "$(DESTDIR)$(PREFIX)/share/applications/Tilemap Studio.desktop"
.PHONY: all $(tilemapstudio) $(tilemapstudiod) release debug clean install uninstall
.SUFFIXES: .o .cpp
all: $(tilemapstudio)
$(tilemapstudio): release
$(tilemapstudiod): debug
release: CXXFLAGS += $(RELEASEFLAGS)
release: $(TARGET)
debug: CXXFLAGS += $(DEBUGFLAGS)
debug: $(DEBUGTARGET)
$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(LD) -o $@ $^ $(LDFLAGS)
$(DEBUGTARGET): $(DEBUGOBJECTS)
@mkdir -p $(@D)
$(LD) -o $@ $^ $(LDFLAGS)
$(tmpdir)/%.o: $(srcdir)/%.cpp $(COMMON)
@mkdir -p $(@D)
$(CXX) -c $(CXXFLAGS) -o $@ $<
$(debugdir)/%.o: $(srcdir)/%.cpp $(COMMON)
@mkdir -p $(@D)
$(CXX) -c $(CXXFLAGS) -o $@ $<
clean:
$(RM) $(TARGET) $(DEBUGTARGET) $(OBJECTS) $(DEBUGOBJECTS)
install: release
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp $(TARGET) $(DESTDIR)$(PREFIX)/bin/$(tilemapstudio)
mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps
cp $(resdir)/app.xpm $(DESTDIR)$(PREFIX)/share/pixmaps/tilemapstudio48.xpm
cp $(resdir)/app-icon.xpm $(DESTDIR)$(PREFIX)/share/pixmaps/tilemapstudio16.xpm
mkdir -p $(DESTDIR)$(PREFIX)/share/applications
echo "[Desktop Entry]" > $(DESKTOP)
echo "Name=Tilemap Studio" >> $(DESKTOP)
echo "Comment=Edit Game Boy, Color, and Advance tilemaps" >> $(DESKTOP)
echo "Icon=$(PREFIX)/share/pixmaps/tilemapstudio48.xpm" >> $(DESKTOP)
echo "Exec=$(PREFIX)/bin/$(tilemapstudio)" >> $(DESKTOP)
echo "Type=Application" >> $(DESKTOP)
echo "Terminal=false" >> $(DESKTOP)
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(tilemapstudio)
rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/tilemapstudio48.xpm
rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/tilemapstudio16.xpm
rm -f $(DESKTOP)