2 # This makefile system follows the structuring conventions
3 # recommended by Peter Miller in his excellent paper:
5 # Recursive Make Considered Harmful
6 # http://aegis.sourceforge.net/auug97.pdf
12 # try to infer the correct GCCPREFIX
14 GCCPREFIX := $(shell if objdump -i 2>&1 | grep 'elf32-i386' >/dev/null 2>&1; \
16 else echo "***" 1>&2; \
17 echo "*** Error: Couldn't find an i386-*-elf version of GCC/binutils." 1>&2; \
18 echo "*** Is the directory with i386-*-elf-gcc in your PATH?" 1>&2; \
19 echo "***" 1>&2; exit 1; fi)
22 CC := $(GCCPREFIX)gcc -pipe
23 GCC_LIB := $(shell $(CC) -print-libgcc-file-name)
27 OBJCOPY := $(GCCPREFIX)objcopy
28 OBJDUMP := $(GCCPREFIX)objdump
32 NCC := gcc $(CC_VER) -pipe
36 # -fno-builtin is required to avoid refs to undefined functions in the kernel.
37 # Only optimize to -O1 to discourage inlining, which complicates backtraces.
38 CFLAGS := $(CFLAGS) $(DEFS) $(LABDEFS) -O -fno-builtin -I$(TOP) -MD -Wall -Wno-format -Wno-unused -Werror -gstabs -fno-stack-protector -std=gnu99 -m32 -nostdlib
40 # Lists that the */Makefrag makefile fragments will add to
43 # Make sure that 'all' is the first target
46 # Eliminate default suffix rules
49 # Delete target files if there is an error (or make is interrupted)
52 # make it so that no intermediate .o files are ever deleted
53 .PRECIOUS: %.o $(OBJDIR)/boot/%.o $(OBJDIR)/kern/%.o \
54 $(OBJDIR)/lib/%.o $(OBJDIR)/fs/%.o $(OBJDIR)/user/%.o
56 KERN_CFLAGS := $(CFLAGS) -DARCANOS_KERNEL -gstabs
57 USER_CFLAGS := $(CFLAGS) -I usr/inc -DARCANOS_USER -gstabs
59 # Include Makefrags for subdirectories
61 include usr/lib/Makefrag
62 include usr/app/Makefrag
64 IMAGES = $(OBJDIR)/kern/bochs.img
66 # For deleting the build
70 # Auto-copy to boot disk image
73 ./tools/copy_to_image.sh