|
Revision 655, 1.0 kB
(checked in by mwhitworth, 6 months ago)
|
|
Create generic clean target, update build system with support for dependencies.
|
| 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 += -fomit-frame-pointer -ffreestanding -fno-stack-protector -fno-builtin \ |
|---|
| 12 | -nostdlib -m32 -Wall -Wextra -O2 -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 "CC $*.c" |
|---|
| 22 | @$(CC) $(CFLAGS) -c $*.c -o $*.o |
|---|
| 23 | @$(CC) -MM $(CFLAGS) -c $*.c > .deps/$*.d |
|---|
| 24 | |
|---|
| 25 | .SUFFIXES: .sys .c |
|---|
| 26 | .c.sys: |
|---|
| 27 | @echo "CC $*.c" |
|---|
| 28 | @$(CC) $(CFLAGS) -DMODULE -fno-common -c $*.c -o $*.sys |
|---|
| 29 | @$(CC) -MM $(CFLAGS) -DMODULE -c $*.c > .deps/$*.d |
|---|
| 30 | @$(SED) -i "s/$*.o/$*.sys/" .deps/$*.d |
|---|
| 31 | |
|---|
| 32 | #nasm assembly files |
|---|
| 33 | |
|---|
| 34 | .asm: |
|---|
| 35 | $(ASM) -f bin $*.asm -o |
|---|
| 36 | @echo "Compiling $*.asm" |
|---|
| 37 | |
|---|
| 38 | .s.o: |
|---|
| 39 | $(ASM) -f elf $*.s -o $*.o |
|---|
| 40 | @echo "Compiling $*.s" |
|---|
| 41 | |
|---|
| 42 | #gas assembly files |
|---|
| 43 | .S.o: |
|---|
| 44 | @$(CC) -ffreestanding -fleading-underscore -fno-builtin -m32 -c $*.S -o $*.o |
|---|
| 45 | @echo "AS $*.S" |
|---|
| 46 | |
|---|
| 47 | ifneq ($(IGNORE_CLEAN), y) |
|---|
| 48 | clean: |
|---|
| 49 | -rm -f *.o *.sys .deps/*.d |
|---|
| 50 | endif |
|---|