-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
119 lines (90 loc) · 3.38 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#
# Copyright (c) 2022 jdeokkim
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
.PHONY: all clean
_COLOR_BEGIN := $(shell tput setaf 13)
_COLOR_END := $(shell tput sgr0)
RAYLIB_PATH ?= lib/raylib-slim
PROJECT_NAME := play
PROJECT_FULL_NAME := mindou/raylib_dev
PROJECT_PREFIX := $(_COLOR_BEGIN)$(PROJECT_FULL_NAME):$(_COLOR_END)
BINARY_PATH := bin
INCLUDE_PATH := include
LIBRARY_PATH := lib
SOURCE_PATH := src
RESOURCE_PATH := res
INCLUDE_PATH += $(RAYLIB_PATH)/src
LIBRARY_PATH += $(RAYLIB_PATH)/src
SOURCES := $(wildcard $(SOURCE_PATH)/*.c)
OBJECTS := $(SOURCES:.c=.o)
TARGETS := $(BINARY_PATH)/$(PROJECT_NAME).out
HOST_PLATFORM := UNKNOWN
ifeq ($(OS),Windows_NT)
ifeq "$(findstring ;,$(PATH))" ";"
PROJECT_PREFIX := $(PROJECT_FULL_NAME):
endif
# MINGW-W64 or MSYS2...?
HOST_PLATFORM := WINDOWS
else
UNAME = $(shell uname 2>/dev/null)
ifeq ($(UNAME),Linux)
HOST_PLATFORM = LINUX
endif
endif
ifeq ($(PLATFORM),WINDOWS)
LIBRARY_PATH += $(RAYLIB_PATH)/src
endif
CC := gcc
CFLAGS := -D_DEFAULT_SOURCE -g $(INCLUDE_PATH:%=-I%) -O2 -std=gnu99
LDFLAGS := $(LIBRARY_PATH:%=-L%) --static #-Wl,--subsystem,windows # <-- if you want disalbe console screen insert it!
LDLIBS := -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
PLATFORM := $(HOST_PLATFORM)
ifeq ($(PLATFORM),WINDOWS)
TARGETS := $(BINARY_PATH)/$(PROJECT_NAME).exe
ifneq ($(HOST_PLATFORM),WINDOWS)
CC := x86_64-w64-mingw32-gcc
endif
LDLIBS := -lraylib -lopengl32 -lgdi32 -lwinmm -lpthread
else ifeq ($(PLATFORM),WEB)
TARGETS := $(BINARY_PATH)/$(PROJECT_NAME).html
CC := emcc
# https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
WEBFLAGS := -s ASYNCIFY -s FORCE_FILESYSTEM -s INITIAL_MEMORY=67108864 -s USE_GLFW=3
WEBFLAGS += --preload-file $(RESOURCE_PATH) --shell-file $(RESOURCE_PATH)/html/shell.html
endif
all: pre-build build post-build
pre-build:
@echo "$(PROJECT_PREFIX) Using: '$(CC)' to build this project."
build: $(TARGETS)
$(SOURCE_PATH)/%.o: $(SOURCE_PATH)/%.c
@echo "$(PROJECT_PREFIX) Compiling: $@ (from $<)"
@$(CC) -c $< -o $@ $(CFLAGS)
$(TARGETS): $(OBJECTS)
@mkdir -p $(BINARY_PATH)
@echo "$(PROJECT_PREFIX) Linking: $(TARGETS)"
@$(CC) $(OBJECTS) -o $(TARGETS) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(WEBFLAGS)
post-build:
@echo "$(PROJECT_PREFIX) Build complete."
clean:
@echo "$(PROJECT_PREFIX) Cleaning up."
@rm -rf $(BINARY_PATH)/*.out
@rm -rf $(BINARY_PATH)/*.exe
@rm -rf $(SOURCE_PATH)/*.o