view Makefile @ 61:5e1d4b26c2ef

Added the ability to write an arbitrary block of data to some file First, I also fixed some memory leaks with the file reading function Second, there seems to be a lot of code duplication at the moment, taking care of it is now my next priority I removed the blankFile function, it was absolutely useless (and unless I am mistaken, it can now be duplicated with setFileData(fid, NULL, 0); I added the setFileSize function, it will set the size of a file to be equal to some specified amount. It will not alter the data in any blocks so if downsizing everything under that point will be the same. If increasing the size, everything over that point will most likely be garbage. The function setFileData will now set the data stored in some file to be equal to data passed by the user. TODO: fix duplication, add creating files
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sat, 16 Apr 2011 20:17:51 -0400
parents eda059d74100
children 36e6fc4a0487
line wrap: on
line source

CROSS_COMPILE=s390x-linux-
AS=$(CROSS_COMPILE)as
CC=$(CROSS_COMPILE)gcc
CXX=$(CROSS_COMPILE)g++
LD=$(CROSS_COMPILE)ld
AR=$(CROSS_COMPILE)ar
OBJCOPY=$(CROSS_COMPILE)objcopy

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

BINS=sarpn dynamic testFS

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

ARCH_OBJS=arch/io.o arch/cons.o arch/ebcdic.o arch/fba.o arch/ioint.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"

clean:
	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

tags:
	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 $@ $^

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

%.o: %.S
	$(AS) -m64 -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/gen_ccws.sh $@

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 $@ $<

depend:
	makedepend -I include src/*.c

# DO NOT DELETE

src/dynamic.o: include/std.h include/die.h include/operations.h
src/dynamic.o: include/stack.h
src/fs.o: include/fs.h include/std.h include/die.h
src/operations.o: include/operations.h include/std.h include/die.h
src/operations.o: include/stack.h include/math.h
src/sarpn.o: include/std.h include/die.h include/operations.h include/stack.h
src/stack.o: include/stack.h include/std.h include/die.h
src/std.o: include/std.h include/die.h
src/testFS.o: include/std.h include/die.h include/fs.h