# Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details
# Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
BIN=../../dosbin
#INC=../../include
INC=.
CFLAGS=-O3 -MD
PREFIX=/usr/i386-go32/bin
XCC=gcc -b i386-go32
XC_INCLUDE_PATH := ../../include
XLIBRARY_PATH := ../../lib
CC=$(XCC) $(CFLAGS) -I$(XC_INCLUDE_PATH) -L$(XLIBRARY_PATH)

all :: \
	$(BIN)/djasm.exe \
	$(BIN)/go32-v2.exe \
	$(BIN)/stubedit.exe \
	$(BIN)/stubify.exe \
	$(BIN)/exe2coff.exe \
	$(INC)/stubinfo.h \
	$E

$(BIN)/% : %
	cp $< $@

sbrk16.ah : sbrk16.asm djasm.exe
	$(PREFIX)/djasm sbrk16.asm sbrk16.ah

stubify.exe : stubify
	$(PREFIX)/strip stubify
	$(PREFIX)/stubify stubify

exe2coff.exe : exe2coff
	$(PREFIX)/strip exe2coff
	$(PREFIX)/stubify exe2coff

stubify.o : stub.h

$(INC)/stubinfo.h : stub.asm stub.map stub2inc
	stub2inc stub.map stub.asm $(INC)/stubinfo.h

stub.h stub.map : stub.asm $(BIN)/djasm.exe
	$(PREFIX)/djasm stub.asm stub.h stub.map

djasm.exe : djasm
	$(PREFIX)/strip djasm
	$(PREFIX)/stubify djasm

$(BIN)/go32-v2.exe : go32-v2.c
	$(CC) -s $(CFLAGS) go32-v2.c -o $(BIN)/go32-v2.exe -ldbg

#
# This one compiled by Linux gcc !
# Override C_INCLUDE_PATH & LIBRARY_PATH again ...
#
stub2inc :
	rm -f stub2inc.d
	gcc -o stub2inc stub2inc.c

stubedit.exe : stubedit $(INC)/stubinfo.h
	$(PREFIX)/strip stubedit
	$(PREFIX)/stubify stubedit

clean ::
	-rm -f *.exe djasm stub.h stub.map stubedit stubify *.o stub2inc *.d

DEPS := $(wildcard *.d)
ifneq ($(DEPS),)
include $(DEPS)
endif
