Makefile 1.85 KB
Newer Older
iker_martin's avatar
iker_martin committed
1
2
3
CC = gcc
MCC = mpicc
#C_FLAGS_ALL = -Wall -Wextra -Wshadow -Wfatal-errors -Wconversion -Wpedantic
4
C_FLAGS =
iker_martin's avatar
iker_martin committed
5
6
7
LD_FLAGS = -lm -pthread
DEF =

8
9
10
11
12
13
14
15
USE_MAL_SLURM ?= 1
USE_MAL_BARRIERS ?= 0
USE_MAL_DEBUG ?= 0

ifeq ($(USE_MAL_SLURM),1)
    LD_FLAGS += -lslurm
endif
DEF = -DUSE_MAL_SLURM=$(USE_MAL_SLURM) -DUSE_MAL_BARRIERS=$(USE_MAL_BARRIERS) -DUSE_MAL_DEBUG=$(USE_MAL_DEBUG)
iker_martin's avatar
iker_martin committed
16
17
18
19
20
21
22
23
24
25
26
27
28

.PHONY : clean clear install install_slurm

# MKL MonoHebra 
MKL_FSINGLE = -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread -lm
LIBMONO = -L$(DIR_MKL) $(MKL_FSINGLE)

# Final binary
BIN = a.out
# Put all auto generated stuff to this build dir.
BUILD_DIR = ./build

# List of all directories where source files are located
29
SRCDIRS = Main malleability malleability/spawn_methods malleability/distribution_methods
iker_martin's avatar
iker_martin committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43

# List of all .c source files.
C_FILES = $(foreach dire, $(SRCDIRS), $(wildcard $(dire)/*.c))

# All .o files go to build dir.
OBJ = $(C_FILES:%.c=$(BUILD_DIR)/%.o)
# Gcc will create these .d files containing dependencies.
DEP = $(OBJ:%.o=%.d)

# Default target named after the binary.
$(BIN) : $(BUILD_DIR)/$(BIN)

# Actual target of the binary - depends on all .o files.
$(BUILD_DIR)/$(BIN) : $(OBJ)
44
	$(MCC) $(C_FLAGS) $^ -o $@ $(LD_FLAGS)
45
46
	@ echo "dirCG=\"$$(pwd)/\"" > Exec/config.txt
	@ mkdir -p Results
47
#	$(MCC) $(C_FLAGS) $^ -o $@ $(LD_FLAGS) $(LIBMONO)
iker_martin's avatar
iker_martin committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

# Include all .d files
# .d files are used for knowing the dependencies of each source file
-include $(DEP)

# Build target for every single object file.
# The potential dependency on header files is covered
# by calling `-include $(DEP)`.
# The -MMD flags additionaly creates a .d file with
# the same name as the .o file.
$(BUILD_DIR)/%.o : %.c
	mkdir -p $(@D)
	$(MCC) $(C_FLAGS) $(DEF) -MMD -c $< -o $@

clean:
	-rm $(BUILD_DIR)/$(BIN) $(OBJ) $(DEP)
clear:
	-rm -rf $(BUILDDIR)


install: $(BIN)
	echo "Done"