trrespass/drama/Makefile
2024-10-24 04:30:57 +00:00

59 lines
1001 B
Makefile

SDIR=src
IDIR=$(SDIR)/include
LDIR=lib
BUILD=obj
ODIR=src/.obj
CFLAGS+=-I$(IDIR) #-ggdb
# CXX=g++
LDFLAGS=-lpthread
OUT=tester
LDEPS=
GB_PAGE=/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
HUGEPAGE=/mnt/huge
all: $(OUT)
.PHONY: clean
SOURCES := $(wildcard $(SDIR)/*.c)
OBJECTS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(SOURCES))
$(ODIR)/%.o: $(SDIR)/%.c
mkdir -p $(ODIR)
$(CXX) -o $@ -c $< $(CFLAGS) $(LDFLAGS) $(LDEPS)
$(OUT): $(OBJECTS)
mkdir -p $(BUILD)
$(CXX) -o $(BUILD)/$@ $^ $(CFLAGS) $(LDFLAGS) $(LDEPS)
chmod +x $(BUILD)/$@
clean:
rm -rf $(BUILD)
rm -rf $(ODIR)
setup:
echo "Mounting hugetlbfs"
echo 1 | sudo tee -a $(GB_PAGE)
@if ! [ -d $(HUGEPAGE) ]; then\
sudo mkdir $(HUGEPAGE);\
sudo mount -t hugetlbfs -o pagesize=1G none $(HUGEPAGE);\
sudo chown pit:pit $(HUGEPAGE);\
fi
teardown:
@if [ -d $(HUGEPAGE) ]; then\
sudo umount -f $(HUGEPAGE);\
sudo rm -r $(HUGEPAGE);\
fi
echo 0 | sudo tee -a $(GB_PAGE)
run:
sudo $(BUILD)/$(OUT)