-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (41 loc) · 1.56 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
#
# FVCode - Fast and easy code editor
# Copyright (C) 2023-2024 FVCode Developers
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
CC = gcc
CFLAGS = -O3 -std=c2x -I./include $(shell pkg-config --cflags sdl2) -Wno-deprecated-declarations
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LIBFLAGS = $(shell pkg-config --libs sdl2) -lSDL2_ttf -lm -rdynamic
endif
ifeq ($(UNAME_S),Darwin)
LIBFLAGS = $(shell pkg-config --libs sdl2 sdl2_ttf) -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
endif
SRC_DIR = ./src
OBJ_DIR = ./obj
EXECUTABLE = fvcode
SRC_FILES = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/**/*.c) $(wildcard $(SRC_DIR)/**/**/*.c)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))
$(EXECUTABLE): $(OBJ_FILES)
$(CC) $(LIBFLAGS) $(CFLAGS) $^ -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
clean:
rm -rf $(OBJ_DIR) $(EXECUTABLE)
.PHONY: clean