-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile.tmpl
More file actions
24 lines (15 loc) · 766 Bytes
/
Makefile.tmpl
File metadata and controls
24 lines (15 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
current_algo := $(strip $(patsubst .%, %, $(current_dir)))
header := $(strip $(patsubst %, "\"%.h\"", $(current_algo)))
DEPS= $(patsubst %.o, ../%.c, $(OBJ)) ../$(current_algo).c
CURR_OBJS= $(OBJ) $(current_algo).o
.PHONY: all cp
all: makefile.dep $(current_algo) cp
makefile.dep:
@(for i in $(DEPS); do ${CC} -MM "$${i}" -D ALGO_H=$(header) | sed '$$s/$$/ Makefile ..\/Makefile/'; /bin/echo -e "\t\$$(CC) \$$(CFLAGS) -c \$$< -D ALGO_H=\$$(header) -o \$$@"; done > makefile.dep)
-include makefile.dep
cp: $(current_algo)
@cp $(current_algo) ../
$(current_algo): $(CURR_OBJS)
$(CC) $(CFLAGS) $(CURR_OBJS) -o $(current_algo) $(LDFLAGS)