view Makefile @ 99:2a0aa3efc228

The shell script will now theroretically load the program into memory, will not run it. The shell script loads a program into memory and displays the address but as of now does not jump to it (though it does display the address it would jump to) Added a memset function Added a python script (credit for its writing to Jeff) that sets up a filesystem
author Jonathan Pevarnek <>
date Sat, 14 May 2011 19:40:18 -0400
parents 28c230f0700e
children d8f21e4a75e3
line wrap: on
line source


MAKEFLAGS += -rR --no-print-directory
CFLAGS=-g -fno-strict-aliasing -fno-builtin -nostdinc -nostdlib -Wall -m64 -I include/ -O2
LDFLAGS=-m elf64_s390

BINS=sarpn dynamic testFS shell

sarpn_OBJS=src/sarpn.o src/std.o src/string.o src/stack.o src/operations.o src/math.o arch/arch.a
dynamic_OBJS=src/dynamic.o src/std.o src/string.o src/stack.o arch/arch.a
testFS_OBJS=src/testFS.o src/std.o src/string.o src/fs.o arch/arch.a
shell_OBJS=src/shell.o src/std.o src/fs.o src/string.o src/stdio.o arch/arch.a

ARCH_OBJS=arch/io.o arch/cons.o arch/ebcdic.o arch/fba.o arch/ioint.o \
	  arch/svc.o arch/svcint.o

.PHONY: all build clean tags

all: $(BINS) loader.bin
	@echo "Image is `stat -c %s sarpn` bytes"
	@echo "Loader is `stat -c %s loader.bin` bytes"

	rm -f $(sarpn_OBJS)
	rm -f $(dynamic_OBJS)
	rm -f $(testFS_OBJS)
	rm -f $(ARCH_OBJS)
	rm -f $(BINS)
	rm -f loader.bin ipl/*.o ipl/*.rto ipl/ipl_ccws.S cscope.out

	cscope -R -b
	ctags -R

sarpn: $(sarpn_OBJS)
	$(LD) $(LDFLAGS) -T scripts/linker.script -o $@ $^
dynamic: $(dynamic_OBJS)
	$(LD) $(LDFLAGS) -T scripts/linker.script -o $@ $^
testFS: $(testFS_OBJS)
	$(LD) $(LDFLAGS) -T scripts/linker.script -o $@ $^
shell: $(shell_OBJS)
	$(LD) $(LDFLAGS) -T scripts/linker.script -o $@ $^

arch/arch.a: $(ARCH_OBJS)
	$(AR) rc $@ $^

%.o: %.S
	$(CC) $(CFLAGS) -c -o $@ $<

%.o: %.c
	$(CC) $(CFLAGS) -include include/system.h -c -o $@ $<

%.o: %.cpp
	$(CXX) $(CXXFLAGS) -include include/system.h -c -o $@ $<

# IPL specific bits

.PRECIOUS: ipl/loader.o ipl/loader_c.o ipl/loader_asm.o ipl/setmode.o \
	ipl/ipl_ccws.o ipl/ipl.o

loader.bin: ipl/ipl.rto ipl/ipl_ccws.rto ipl/setmode.rto ipl/loader.rto
	cat $^ > $@
	( len=`stat -c %s "$@"`; dif=`expr $$len % 80`; if [ $$dif -ne 0 ]; then dif=`expr 80 - $$dif`; dd if=/dev/zero bs=1 count=$$dif 2> /dev/null >> "$@"; fi)

ipl/loader_asm.o: ipl/loader_asm.S
	$(AS) -m64 -o $@ $<

ipl/loader_c.o: ipl/loader.c
	$(CC) $(CFLAGS) -DBLOCK_SIZE=80 -c -o $@ $<

ipl/ipl_ccws.S: ipl/setmode.rto ipl/loader.rto
	bash scripts/ $@

ipl/loader.rto: ipl/loader.o
	$(OBJCOPY) -O binary -j .text -j .data -j .rodata $< $@

ipl/loader.o: ipl/loader_c.o ipl/loader_asm.o
	$(LD) -melf64_s390 -T ipl/linker.script -o $@ $^

ipl/%.rto: ipl/%.o
	$(OBJCOPY) -O binary -j .text $< $@

ipl/%.o: ipl/%.S
	$(AS) -m64 -o $@ $<

	makedepend -I include src/*.c


src/dynamic.o: include/std.h include/die.h include/string.h include/stack.h
src/fs.o: include/fs.h include/std.h include/die.h include/error.h
src/fs.o: include/string.h include/tod.h
src/operations.o: include/operations.h include/std.h include/die.h
src/operations.o: include/stack.h include/string.h include/math.h
src/sarpn.o: include/std.h include/die.h include/string.h
src/sarpn.o: include/operations.h include/stack.h
src/shell.o: include/std.h include/die.h include/string.h include/stdio.h
src/shell.o: include/error.h include/fs.h include/elf.h
src/stack.o: include/stack.h include/std.h include/die.h
src/std.o: include/std.h include/die.h include/string.h
src/stdio.o: include/stdio.h include/std.h include/die.h include/string.h
src/stdio.o: include/stdarg.h
src/testFS.o: include/std.h include/die.h include/fs.h include/error.h