-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (56 loc) · 1.52 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
# Copyright (C) 2023-4 Ethan Uppal. All rights reserved.
SRCDIR := ./src
INCLUDEDIR := ./src
CC := $(shell which g++ || which clang)
CFLAGS := -std=c++17 -pedantic -Wall -Wextra -I $(INCLUDEDIR)
CDEBUG := -g
CRELEASE := -O2 -DRELEASE_BUILD
TARGET := sdlwrapper
REALTARGET := lib$(TARGET).a
INSTLIB := /usr/local/lib
INSTHEA := /usr/local/include/$(TARGET)
# CFLAGS += $(CRELEASE)
CFLAGS += $(CDEBUG)
# use SDL
CFLAGS += $(shell sdl2-config --cflags --libs)
SRC := $(shell find $(SRCDIR) -name "*.cpp" -type f -not -path "$(SRCDIR)/demo/*")
OBJ := $(SRC:.cpp=.o)
DEPS := $(OBJS:.o=.d)
# NOT MY CODE
# Customizes ar for macOS
ifeq ($(shell uname), Darwin)
AR := /usr/bin/libtool
AR_OPT := -static -o
else
AR := ar
AR_OPT := rcs -o
endif
$(REALTARGET): $(OBJ)
$(AR) $(AR_OPT) $@ $^
%.o: %.cpp
@echo 'Compiling $@'
$(CC) $(CFLAGS) -MMD -MP $< -c -o $@
-include $(DEPS)
.PHONY: clean
clean:
rm -rf demo $(OBJ) $(REALTARGET) $(DEPS) $(shell find . -name "*.dSYM") $(shell find . -name "*.d")
.PHONY: demo
demo: $(REALTARGET)
$(CC) $(CFLAGS) $(SRCDIR)/demo/demo_view.cpp $(SRCDIR)/demo/main.cpp -L. -l$(TARGET) -o demo
install: $(REALTARGET)
mv $(REALTARGET) $(REALTARGET).bak
make clean
mv $(REALTARGET).bak $(REALTARGET)
mkdir -p $(INSTLIB)
mkdir -p $(INSTHEA)
mv $(REALTARGET) $(INSTLIB)
cp -a $(SRCDIR) $(INSTHEA)/
mv $(INSTHEA)/$(SRCDIR)/* $(INSTHEA)/
chmod +rw $(INSTHEA)/gui
chmod +rw $(INSTHEA)/gui/*
uninstall:
rm -r $(INSTLIB)/$(REALTARGET) \
$(INSTHEA)
reinstall:
make uninstall
make install