|
Revision 1858, 0.9 KB
(checked in by mwhitworth, 3 years ago)
|
|
Simplify build, add colored prints (easier to read).
|
| Line | |
|---|
| 1 | #Define DEPTH before including this file |
|---|
| 2 | |
|---|
| 3 | .PHONY: clean |
|---|
| 4 | .IGNORE: clean |
|---|
| 5 | |
|---|
| 6 | CC = gcc |
|---|
| 7 | CPP = gpp |
|---|
| 8 | ASM = nasm |
|---|
| 9 | RM = rm -f |
|---|
| 10 | SED = sed |
|---|
| 11 | override CFLAGS += -g -ffreestanding -fno-stack-protector -fno-builtin \ |
|---|
| 12 | -nostdlib -m32 -Wall -Wextra -Os -I$(DEPTH)include -Wno-unused-parameter |
|---|
| 13 | BE_VERBOSE = 0 |
|---|
| 14 | LD_R_FLAGS = -r -melf_i386 |
|---|
| 15 | |
|---|
| 16 | # Build the dependency list |
|---|
| 17 | DEPS := $(MODULES:%.sys=.deps/%.d) |
|---|
| 18 | DEPS += $(OBJS:%.o=.deps/%.d) |
|---|
| 19 | |
|---|
| 20 | %.o : %.c |
|---|
| 21 | @echo " \033[32mCC $*.c" |
|---|
| 22 | @tput sgr0 |
|---|
| 23 | @$(CC) $(CFLAGS) -c $*.c -o $*.o |
|---|
| 24 | @$(CC) -MM $(CFLAGS) -c $*.c > .deps/$*.d |
|---|
| 25 | |
|---|
| 26 | %.sys : %.c |
|---|
| 27 | @echo " \033[32mCC $*.c" |
|---|
| 28 | @tput sgr0 |
|---|
| 29 | @$(CC) $(CFLAGS) -DMODULE -fno-common -c $*.c -o $*.sys |
|---|
| 30 | @$(CC) -MM $(CFLAGS) -DMODULE -c $*.c > .deps/$*.d |
|---|
| 31 | @$(SED) -i "s/$*.o/$*.sys/" .deps/$*.d |
|---|
| 32 | |
|---|
| 33 | #gas assembly files |
|---|
| 34 | %.o : %.S |
|---|
| 35 | $(CC) -I$(DEPTH)include -ffreestanding -fleading-underscore -fno-builtin -m32 -c $*.S -o $*.o |
|---|
| 36 | # @echo "AS $*.S" |
|---|
| 37 | |
|---|
| 38 | ifneq ($(IGNORE_CLEAN), y) |
|---|
| 39 | clean: |
|---|
| 40 | -rm -f *.o *.sys .deps/*.d |
|---|
| 41 | endif |
|---|