-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (57 loc) · 1.92 KB
/
Makefile
File metadata and controls
66 lines (57 loc) · 1.92 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
# Variables
CC := g++
LDFLAGS := -std=c++11 -Wall -fPIC
SOURCE := $(wildcard src/*.cpp)
OUTPUT := $(patsubst src/%.cpp, bin/%.o, $(SOURCE))
ifeq ($(OS), Windows_NT)
LIBS := -Iinclude -Llib/SDL2 -lm -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer
EXTLIB := dll
EXTEXE := exe
TARGET := libmuffin.$(EXTLIB)
else
LIBS := -lm -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer
EXTLIB := so
EXTEXE := bin
TARGET := libmuffin.$(EXTLIB)
endif
.PHONY: make all link clean docs examples
# Compiling
all: $(OUTPUT) link
bin/%.o: src/%.cpp
@echo [ Building $<... ]
@$(CC) $(LDFLAGS) -c $^ -o $@ $(LIBS)
# Linking
link:
@echo [ Linking... ]
@$(CC) -g -shared $(LDFLAGS) $(OUTPUT) -o $(TARGET) $(LIBS)
# Install (linux only)
install:
ifeq ($(OS), Windows_NT)
@echo 'Instalation is not avaliable on Windows platforms.'
else
@echo [ Installing... ]
@cp -fr src/*.hpp /usr/local/include/muffin
@cp -fr *.so /usr/local/lib/
@echo /usr/local/lib/ | tee /etc/ld.so.conf.d/muffin.conf
@ldconfig
endif
# Examples
examples:
@echo [ Building examples... ]
@$(CC) $(LDFLAGS) -g examples/1_hello_world/main.cpp -o examples/bin/1_hello_world.$(EXTEXE) -lm -lmuffin
@$(CC) $(LDFLAGS) -g examples/2_shapes/main.cpp -o examples/bin/2_shapes.$(EXTEXE) -lm -lmuffin
@$(CC) $(LDFLAGS) -g examples/3_images/main.cpp -o examples/bin/3_images.$(EXTEXE) -lm -lmuffin
@$(CC) $(LDFLAGS) -g examples/4_music/main.cpp -o examples/bin/4_music.$(EXTEXE) -lm -lmuffin
@$(CC) $(LDFLAGS) -g examples/5_data/main.cpp -o examples/bin/5_data.$(EXTEXE) -lm -lmuffin
@$(CC) $(LDFLAGS) -g examples/6_input/main.cpp -o examples/bin/6_input.$(EXTEXE) -lm -lmuffin
# Doxygen
docs:
@doxygen Doxyfile
# Cleaning
clean:
@echo [ Cleaning... ]
ifeq ($(OS), Windows_NT)
@del /S "bin\*.o" "examples\bin\*.exe" "examples\bin\*.out" "*.so" "*.dll"
else
@rm -fr bin/*.o examples/bin/*.exe examples/bin/*.out *.so
endif