1 |
rakinar2 |
47 |
ARCH_LIST = x86_64 |
2 |
|
|
LIB = lib/libc.a |
3 |
|
|
BIN = bin-exec |
4 |
|
|
|
5 |
|
|
export AS = as |
6 |
|
|
export CC = gcc |
7 |
|
|
export CFLAGS = -g -Wall -Wextra -Werror -std=c99 -pedantic -O2 -static -nostdlib -nostartfiles -ffreestanding |
8 |
|
|
export LDFLAGS = -g -static -nostdlib -nostartfiles -e _start -ffreestanding |
9 |
|
|
export ASFLAGS = -g |
10 |
|
|
export RM = rm -f |
11 |
|
|
|
12 |
|
|
all: $(BIN) |
13 |
|
|
|
14 |
|
|
$(BIN): $(ARCH_LIST) lib |
15 |
|
|
@echo " CCLD $@" |
16 |
|
|
$(CC) $(LDFLAGS) -o $@ $(patsubst %,%/*.o,$(ARCH_LIST)) $(LIB) |
17 |
|
|
|
18 |
|
|
lib: |
19 |
|
|
$(MAKE) -C lib |
20 |
|
|
|
21 |
|
|
.PHONY: lib $(ARCH_LIST) $(BIN) |
22 |
|
|
|
23 |
|
|
$(ARCH_LIST): |
24 |
|
|
$(MAKE) -C $@ |
25 |
|
|
|
26 |
|
|
clean: |
27 |
|
|
$(RM) *.o $(patsubst %,%/*.o,$(ARCH_LIST)) |
28 |
|
|
$(MAKE) -C lib clean |
29 |
|
|
|
30 |
|
|
for dir in $(ARCH_LIST); do \ |
31 |
|
|
if [ -f $$dir/Makefile ]; then \ |
32 |
|
|
$(MAKE) -C $$dir clean; \ |
33 |
|
|
fi; \ |
34 |
|
|
done |