# # This makefile system follows the structuring conventions # recommended by Peter Miller in his excellent paper: # # Recursive Make Considered Harmful # http://aegis.sourceforge.net/auug97.pdf # OBJDIR := obj TOP = . # try to infer the correct GCCPREFIX ifndef GCCPREFIX GCCPREFIX := $(shell if objdump -i 2>&1 | grep 'elf32-i386' >/dev/null 2>&1; \ then echo ''; \ else echo "***" 1>&2; \ echo "*** Error: Couldn't find an i386-*-elf version of GCC/binutils." 1>&2; \ echo "*** Is the directory with i386-*-elf-gcc in your PATH?" 1>&2; \ echo "***" 1>&2; exit 1; fi) endif CC := $(GCCPREFIX)gcc -pipe GCC_LIB := $(shell $(CC) -print-libgcc-file-name) AS := $(GCCPREFIX)as AR := $(GCCPREFIX)ar LD := $(GCCPREFIX)ld OBJCOPY := $(GCCPREFIX)objcopy OBJDUMP := $(GCCPREFIX)objdump NM := $(GCCPREFIX)nm # Native commands NCC := gcc $(CC_VER) -pipe TAR := gtar # Compiler flags # -fno-builtin is required to avoid refs to undefined functions in the kernel. # Only optimize to -O1 to discourage inlining, which complicates backtraces. CFLAGS := $(CFLAGS) $(DEFS) $(LABDEFS) -O -fno-builtin -I$(TOP) -MD -Wall -Wno-format -Wno-unused -Werror -gstabs -fno-stack-protector -std=gnu99 -m32 -nostdlib # Lists that the */Makefrag makefile fragments will add to OBJDIRS := # Make sure that 'all' is the first target all: # Eliminate default suffix rules .SUFFIXES: # Delete target files if there is an error (or make is interrupted) .DELETE_ON_ERROR: # make it so that no intermediate .o files are ever deleted .PRECIOUS: %.o $(OBJDIR)/boot/%.o $(OBJDIR)/kern/%.o \ $(OBJDIR)/lib/%.o $(OBJDIR)/fs/%.o $(OBJDIR)/user/%.o KERN_CFLAGS := $(CFLAGS) -DARCANOS_KERNEL -gstabs USER_CFLAGS := $(CFLAGS) -I usr/inc -DARCANOS_USER -gstabs # Include Makefrags for subdirectories include kern/Makefrag include usr/lib/Makefrag include usr/app/Makefrag IMAGES = $(OBJDIR)/kern/bochs.img # For deleting the build clean: rm -rf $(OBJDIR) # Auto-copy to boot disk image load: all mkdir -p mnt ./tools/copy_to_image.sh EMULATOR=bochs run: all $(EMULATOR) -q always: @: .PHONY: all always \ clean