-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (46 loc) · 1.5 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
# CSE 375/475 Assignment #1
# Fall 2021
#
# Description: This makefile allows you to build the assignment by typing
# 'make'. Note that typing "BITS=64 make" will build a 64-bit executable
# instead of a 32-bit executable.
#
# Note: It's worth understanding how this Makefile works
#
# This defaults bits to 32, but allows it to be overridden on the command
# line
BITS = 32
# Output directory
ODIR = obj32
tmp := $(shell mkdir -p $(ODIR))
# Basic compiler configuration and flags
CXX = g++
CXXFLAGS = -MMD -ggdb -std=c++17 -m$(BITS) -fgnu-tm
LDFLAGS = -m$(BITS) -lpthread -lrt -fgnu-tm
# The basenames of the c++ files that this program uses
CXXFILES = driver concurrent sequential transactional
# The executable we will build
TARGET = $(ODIR)/driver
# Create the .o names from the CXXFILES
OFILES = $(patsubst %, $(ODIR)/%.o, $(CXXFILES))
# Create .d files to store dependency information, so that we don't need to
# clean every time before running make
DFILES = $(patsubst %.o, %.d, $(OFILES))
# Default rule builds the executable
all: $(TARGET)
# clean up everything by clobbering the output folder
clean:
@echo cleaning up...
@rm -rf $(ODIR)
# build an .o file from a .cc file
$(ODIR)/%.o: %.cpp
@echo [CXX] $< "-->" $@
@$(CXX) $(CXXFLAGS) -c -o $@ $<
# Link rule for building the target from .o files
$(TARGET): $(OFILES)
@echo [LD] $^ "-->" $@
@$(CXX) -o $@ $^ $(LDFLAGS)
# Remember that 'all' and 'clean' aren't real targets
.PHONY: all clean
# Pull in all dependencies
-include $(DFILES)