-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathMakefile
43 lines (29 loc) · 1023 Bytes
/
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
CURR_DIR = $(shell pwd)
SOURCES = $(wildcard $(CURR_DIR)/src/*)
BUILDDIR = $(subst /src/,/build/,$(SOURCES))
PROGS = $(subst $(CURR_DIR)/src/,,$(SOURCES))
CLEAN_PROGS = $(subst $(CURR_DIR)/src/,clean-,$(SOURCES))
CTYPE = gcc
.PHONY: all dir compile $(SOURCES)
all: dir compile
intel: CTYPE = intel
intel: dir compile
inteltogether: CTYPE = inteltogether
inteltogether: dir compile
dir:
@echo Setting up directories
@mkdir -p dist
@mkdir -p $(BUILDDIR)
compile: $(SOURCES)
$(SOURCES): $(CURR_DIR)/src/% : $(CURR_DIR)/src/%/makefile
@cd $@ && make $(CTYPE) SOURCEDIR=$@ BUILDDIR=$(CURR_DIR)/build/$* EXECUTABLE=$(CURR_DIR)/dist/$*
clean:
rm -rf $(BUILDDIR)
rm -rf dist/*
$(PROGS): % : $(CURR_DIR)/src/%/makefile
@mkdir -p $(CURR_DIR)/build/$@
@cd $(CURR_DIR)/src/$@ && make $(CTYPE) SOURCEDIR=$(CURR_DIR)/src/$@ BUILDDIR=$(CURR_DIR)/build/$@ EXECUTABLE=$(CURR_DIR)/dist/$@
$(CLEAN_PROGS): clean-% : $(CURR_DIR)/src/%/makefile
rm -rf build/$(subst clean-,,$@)
rm -rf dist/$(subst clean-,,$@)
#@echo $@