aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 7a5122a1bfce770db7191a356a6b07ade0a897b0 (plain)
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
TRUECOLOR	:= 1
EXTCOLOR	:= 0
VGACOLOR	:= 0

PWD			:= $(shell pwd)

SRCDIR		:= $(PWD)/src
INCDIR		:= $(PWD)/include
SRCFILES	:= $(wildcard $(SRCDIR)/*.cpp)
SRCFILES 	+= $(wildcard $(SRCDIR)/*/*.cpp)

OBJFILES	:= $(patsubst %.cpp,%.o,$(SRCFILES))

TARGET_NAME		:= postmodern
TARGET_PREFIX	:= $(PWD)/bin
TARGET			:= $(TARGET_PREFIX)/$(TARGET_NAME)

WARNINGS	:= -Wall \
			   -Wextra \
			   -Wformat-signedness \
			   -Wlogical-op \
			   -Wmissing-declarations \
			   -Wmissing-noreturn \
			   -Wnon-virtual-dtor \
			   -Wold-style-cast \
			   -Woverloaded-virtual \
			   -Wpedantic \
			   -Wsuggest-override \
			   -Wunused-macros \
			   -Wzero-as-null-pointer-constant 

CPP			:= g++
CPPFLAGS	:= -std=gnu++20 $(WARNINGS) -I$(INCDIR) -g
LIBS		:= -L$(TARGET_PREFIX) -l:libboxii.so

ifeq ($(TRUECOLOR), 1)
	CPPFLAGS	+= -DTRUECOLOR
else ifeq ($(EXTCOLOR), 1)
	CPPFLAGS	+= -DEXTCOLOR
else ifeq ($(VGACOLOR), 1)
	CPPFLAGS	+= -DVGACOLOR
else
	CPPFLAGS	+= -DNOCOLOR
endif

.PHONY: all
all: $(OBJFILES) $(TARGET_PREFIX)/libboxii.so
	$(CPP) $(CPPFLAGS) $(LIBS) $(OBJFILES) -o $(TARGET)

run:
	cd $(TARGET_PREFIX); ./run.sh

clean:
	rm $(OBJFILES)
	rm $(TARGET)
	rm $(TARGET_PREFIX)/libboxii.so
	$(MAKE) -C $(PWD)/boxii clean

%.o:%.cpp $(INCDIR)/boxii
	$(CPP) $(CPPFLAGS) -c $< -o $@

$(INCDIR)/boxii:
	ln -s $(PWD)/boxii/include $(INCDIR)/boxii

.PHONY: $(TARGET_PREFIX)/libboxii.so
$(TARGET_PREFIX)/libboxii.so:
	$(MAKE) -C $(PWD)/boxii TRUECOLOR=$(TRUECOLOR) EXTCOLOR=$(EXTCOLOR) VGACOLOR=$(VGACOLOR)
	mv $(PWD)/boxii/bin/libboxii.so $(TARGET_PREFIX)

#  vim: set ts=4 sw=0 tw=0 noet :