AR	= ar
AS	=
AFLAGS	=
CC	= 
CF32	= gcc -m32 -D_PEKOE32_ -mpush-args
CF64	= xgcc -m64 -z nodefaultlib -mpush-args -falign-functions=2 
CFBASE	= -Wall -mno-red-zone -nostdlib -fno-exceptions -fno-builtin -fno-rtti -c -O3
CFLAGS	= $(CF64) $(CFBASE)
LD	= 
#LF32	= /bin/ld --format pe-i386 --oformat pe-i386 -m i386pe -e ___crtLeaf32 -T ../env/link32.txt
LF32	= /bin/ld -e ___crtLeaf32
LF64	= ld -e __crtLeaf64 -T ../env/link64.txt
LFBASE	=  --gc-sections
LFLAGS	= $(LF64) $(LFBASE)
MAKE	= make
BIM2BIN	= ../tools/bim2bin.exe
ELF2COM	= ../tools/elf2com.exe
BINDCOM	= ../tools/bindcom.exe
OBJCOPY	= objcopy

CFINCLUDE	= -Iinclude
STDLIB	= lib/pekoe64.a
CRT	= lib/crt64.o
TARGET	= lib/crt64.o lib/crt32.o tools/sfx64.bin tools/sfx32.bin

.cpp.o:
	$(CC) $(CFLAGS) $(CFINCLUDE) $*.cpp

all: $(TARGET)
	(cd lib64; $(MAKE))
	(cd lib32; $(MAKE))
	(cd system; $(MAKE))
	(cd user; $(MAKE))
	(cd private; $(MAKE))
	echo make is all over

clean:
	-rm -f $(TARGET) tools/*.bsc lib/*.a
	(cd lib64; $(MAKE) clean)
	(cd lib32; $(MAKE) clean)
	(cd system; $(MAKE) clean)
	(cd user; $(MAKE) clean)
	(cd private; $(MAKE) clean)

reclean: clean
	-rm Makefile src-lib/Makefile system/Makefile user/Makefile tools/*.bsc
	cp Makefile.null Makefile

tools/sfx32.bin: src/sfx32.nas
	nasm -f bin -o tools/sfx32.bin src/sfx32.nas

tools/sfx64.bin: src/sfx64.nas
	yasm -f bin -o tools/sfx64.bin src/sfx64.nas

lib/crt64.o: src/crt64.nas
	yasm -m amd64 -f elf -o lib/crt64.o src/crt64.nas

lib/crt32.o: src/crt32.nas
	nasm -f elf -o lib/crt32.o src/crt32.nas

