-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (32 loc) · 1 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
OS := $(shell uname)
ifeq ($(OS),Darwin)
CC = clang
FIND = gfind
else
CC = gcc
FIND = find
LFLAGS = -lm
endif
CFLAGS = -g -Wall -Werror -std=gnu99
INCLUDE="."
BUILDIR = $(shell pwd)/build
SUBDIRS = caches helpers queueing
2LRU_OBJ = $(addprefix $(BUILDIR)/,2lru.o)
FOG_SIM_OBJ = $(addprefix $(BUILDIR)/,fog_simulator.o)
6CN_OBJ = $(addprefix $(BUILDIR)/,6cn.o)
HSOURCES = $(shell find $(SUBDIRS) -type f -iname '*.c')
HOBJECTS = $(addprefix $(BUILDIR)/,$(notdir $(HSOURCES:%.c=%.o)))
.PHONY: clean create_dir
fog_sim: create_dir $(HOBJECTS) $(FOG_SIM_OBJ)
$(CC) -I$(INCLUDE) $(FOG_SIM_OBJ) $(HOBJECTS) -o fog_simulator $(LFLAGS)
2lru: create_dir $(HOBJECTS) $(2LRU_OBJ)
$(CC) -I$(INCLUDE) $(2LRU_OBJ) $(HOBJECTS) -o 2lru_sim $(LFLAGS)
6cn: create_dir $(HOBJECTS) $(6CN_OBJ)
$(CC) -I$(INCLUDE) $(6CN_OBJ) $(HOBJECTS) -o ats_lru $(LFLAGS)
.SECONDEXPANSION:
$(BUILDIR)/%.o: $$(shell $(FIND) -name $$*.c)
$(CC) $(CFLAGS) -I$(INCLUDE) -o $@ -c $^
create_dir:
mkdir -pm 777 $(BUILDIR)
clean:
rm -fr $(BUILDIR)