[go: up one dir, main page]

Menu

[592f53]: / Makefile  Maximize  Restore  History

Download this file

60 lines (43 with data), 1.4 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
#Output directories
SRC_DIR := src
OBJ_DIR := obj
BIN_DIR := bin
#TARGET
TARGET := $(BIN_DIR)/psx-combine
#Source files
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
#Objects derived from Sources
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
#Compiler
CC := g++
win32CC := i686-w64-mingw32-g++
win64CC := x86_64-w64-mingw32-g++
#Flags
CPPFLAGS := -Iinclude -O2 -MMD -MP -Wall -Wextra -Wsign-conversion -Wmissing-declarations -Wconversion -Wshadow -Wlogical-op -Wfloat-equal -Wunused -Wuninitialized -Wformat -Wunused-result -Wtype-limits
CFLAGS := -Wall
LDLIBS := -lm
winCFLAGS := -O2 -Wall -static-libgcc -static-libstdc++
winLDLIBS := -lm -static
# Windows needs -static link and static cflags
.PHONY: all win32 win64 install clean
all: $(TARGET)
#Change the compiler and linker flags then run all
win32:
$(MAKE) CC=$(win32CC) CFLAGS="$(winCFLAGS)" LDLIBS="$(winLDLIBS)" all
win64:
$(MAKE) CC=$(win64CC) CFLAGS="$(winCFLAGS)" LDLIBS="$(winLDLIBS)" all
#Make binary
$(TARGET): $(OBJS) | $(BIN_DIR)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
#Make objects
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
#Create obj and bin directory if they don't exist
$(BIN_DIR) $(OBJ_DIR):
mkdir -p $@
install: $(TARGET)
mv ./$(TARGET) /usr/local/bin/
#Remove objects and binary
clean:
@$(RM) -rv $(BIN_DIR) $(OBJ_DIR)
-include $(OBJ:.o=.d)