aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: d6ca4c94d39e467a3d270e5b27bd57b467631f35 (plain) (blame)
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
# Author Name: Matt Strapp
# Date: 25 April 2022
# x500: strap012
.DELETE_ON_ERROR:

CXX := g++
SRCDIR := src
INCLDIR := include
BUILDDIR := build

VERSION ?= prod
ifeq      ($(VERSION),debug)
	FLAGS := -Wall -Wextra -Wpedantic -pedantic -g 
else
	FLAGS := -w -O3
endif

CFLAGS := $(FLAGS) -I$(INCLDIR)


all: client server

client: $(BUILDDIR)/client.o
	$(CXX) $(CFLAGS) $(BUILDDIR)/client.o $(BUILDDIR)/util.o $(BUILDDIR)/comms.o -o client

server: $(BUILDDIR)/server.o
	$(CXX) $(CFLAGS) $(BUILDDIR)/server.o $(BUILDDIR)/util.o $(BUILDDIR)/comms.o -o server

$(BUILDDIR)/client.o: $(SRCDIR)/client.cpp $(INCLDIR)/client.hpp $(BUILDDIR)/comms.o $(BUILDDIR)/util.o
	$(CXX) $(CFLAGS) -c $(SRCDIR)/client.cpp -o $(BUILDDIR)/client.o

$(BUILDDIR)/server.o: $(SRCDIR)/server.cpp $(INCLDIR)/server.hpp $(BUILDDIR)/comms.o $(BUILDDIR)/util.o
	$(CXX) $(CFLAGS) -c $(SRCDIR)/server.cpp -o $(BUILDDIR)/server.o

$(BUILDDIR)/comms.o: $(SRCDIR)/comms.cpp $(INCLDIR)/comms.hpp $(BUILDDIR)/util.o
	$(CXX) $(CFLAGS) -c $(SRCDIR)/comms.cpp -o $(BUILDDIR)/comms.o

$(BUILDDIR)/util.o: $(SRCDIR)/util.cpp $(INCLDIR)/util.hpp
	$(CXX) $(CFLAGS) -c $(SRCDIR)/util.cpp -o $(BUILDDIR)/util.o	

clean:
	-rm -r client server $(BUILDDIR)/*.o files/ userDB fileDB 2> /dev/null || true

.PHONY: all clean