-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.in
38 lines (30 loc) · 875 Bytes
/
Makefile.in
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
CC = riscv64-linux-gnu-gcc
CFLAGS = -O1 \
-fno-ipa-pure-const \
-fno-inline-functions-called-once \
-fno-stack-protector \
-Wall -Werror -march=rv64g
DIRS = $(shell ls -l| grep -v build | grep ^d |awk '{print $$9}')
TARGET_DEST = $(addprefix build/,$(DIRS))
FILES = $(basename $(notdir $(shell find . -maxdepth 1 -name "*.c")))
TARGET_FILE = $(addprefix build/,$(FILES))
TARGET = $(notdir $(shell pwd))
$(shell touch $(DIRS) .)
all: $(TARGET_FILE) $(TARGET_DEST)
@echo $(FILES)
@echo $(DIRS)
$(TARGET_FILE) : %:%.o
@mkdir -p build
@$(CC) $(CFLAGS) $^ -o $@
%.o: %.s
@$(CC) $(CFLAGS) $^ -c -o $@
build/%.s: %.c
@mkdir -p build
@$(CC) $(CFLAGS) $^ -S -o $@
$(TARGET_DEST) : build/%: %
@mkdir -p build
@echo "include ../../Makefile-dir.in" > $^/Makefile
@mkdir -p $^/build
-@make -C $^ TARGET=../$@
@rm $^/Makefile
.NOTINTERMEDIATE: $(TARGET_FILE:%=%.s)