1 |
CC = gcc |
CC = gcc |
2 |
CFLAGS = -std=c99 -g -O2 -I. -Wall -Wextra -Werror -pedantic -DHAVE_CONFIG_H -DNDEBUG |
CFLAGS = -std=c99 -g -O2 -I. -I../include -Wall -Wextra -Werror -pedantic -DHAVE_CONFIG_H -DNDEBUG -DHAVE_PLIBC |
3 |
|
LDLIBS = -lm |
4 |
|
RM = rm -f |
5 |
|
AS = as |
6 |
|
ASFLAGS = -g |
7 |
|
|
8 |
all: uar |
all: uar bin-exec |
9 |
uar: uar.o main.o xmalloc.o |
|
10 |
|
uar: libuar.a main.o |
11 |
|
@echo " CCLD $@" |
12 |
|
@$(CC) $(CFLAGS) -o $@ main.o -L. -luar $(LDLIBS) |
13 |
|
|
14 |
|
bin-exec: selfext.o selfext_entry.o |
15 |
|
@echo " CCLD $@" |
16 |
|
@$(CC) $(CFLAGS) -ffreestanding -nostdlib -e _start -o $@ selfext.o selfext_entry.o ../plibc/lib/libc.a ../plibc/x86_64/libx86_64.a -L. $(LDLIBS) |
17 |
|
|
18 |
|
libuar.a selfext.o selfext_entry.o: CFLAGS += -ffreestanding -nostdlib -I../plibc/lib |
19 |
|
|
20 |
|
%.o: %.s |
21 |
|
@echo " AS $@" |
22 |
|
@$(AS) $(ASFLAGS) -c -o $@ $< |
23 |
|
|
24 |
|
%.o: %.c |
25 |
|
@echo " CC $@" |
26 |
|
$(CC) $(CFLAGS) -c -o $@ $< |
27 |
|
|
28 |
|
libuar.a: uar.o xmalloc.o |
29 |
|
@echo " AR $@" |
30 |
|
@ar rcs $@ $^ |
31 |
|
|
32 |
clean: |
clean: |
|
rm -f uar *.o |
|
33 |
|
@echo " RM bin-exec" |
34 |
|
@echo " RM uar" |
35 |
|
@echo " RM *.o" |
36 |
|
@$(RM) uar *.o bin-exec *.a |