O = 1 CC = ${PSMLDIR}/psml-bochs/toolchain/install/bin/i586-elf-gcc # set optimization level CFLAGS := -O${O} # i386-gcc pass -g so we do too ;-) CFLAGS := -g # set lang standard to c99 CFLAGS += -std=c99 # turn on all warnings CFLAGS += -Wall # force 32 bit code and address generation CFLAGS += -m32 # strip extraneous info from binary explicity ensure no comment section is # generated CFLAGS += -s # ensure no startup files are included CFLAGS += -nostartfiles # avoid generating exception frame (.eh_frame) support CFLAGS += -fno-asynchronous-unwind-tables # use a freestanding environment eg no standard libs no start (may want to remove this) CFLAGS += -ffreestanding # ensure that we only statically link things CFLAGS += --static # use custom vm linker script CFLAGS += -T ${LDS} # remove identity generation from the binary CFLAGS += -Wl,--build-id=none CFLAGS += -Wl,-M LIBSYSOBJS = sbrk.o read.o write.o isatty.o lseek.o close.o fstat.o _exit.o LIBSYS = libsys.a all: crt0.o ${LIBSYS} .PHONY: all crt0.o: crt0.s $(CC) $(CFLAGS) -c $< ${LIBSYS}: $(LIBSYSOBJS) ar -c -r $(LIBSYS) $(LIBSYSOBJS) read.o: read.c $(CC) $(CFLAGS) $< -c write.o: write.c $(CC) $(CFLAGS) $< -c sbrk.o: sbrk.c $(LDS) $(CC) $(CFLAGS) $< -c lseek.o: lseek.c $(CC) $(CFLAGS) $< -c isatty.o: isatty.c $(CC) $(CFLAGS) $< -c fstat.o: fstat.c $(CC) $(CFLAGS) $< -c _exit.o: _exit.c $(CC) $(CFLAGS) $< -c clean: -rm -rf *.o *.a *~