# Makefile -- Copyright (c) 2002 Eberhard Mattes
#
# This file is part of epocemx.
#
# epocemx is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# epocemx is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with epocemx; see the file COPYING.  If not, write to the
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#

default: estlib.dll

ROOT=/usr/local/epocemx
LIB=../lib
ESTLIB=$(ROOT)/epocsdk/lib/libestlib.a
EMXDLLUID=101f3dcc
CC=arm-epoc-pe-gcc -shared

.cc.o:
	$(CC) -c $<

estlib.def missing.h: $(ESTLIB) helper estlib.o $(LIB)/emx.def
	./helper $(ESTLIB) $(LIB)/emx.def estlib.o estlib.def missing.h

estlib.dll: $(LIB)/emxdll.o estlib.o missing.o estlib.def emximp.a
	$(CC) -nostdlib -o estlib.dll $(LIB)/emxdll.o estlib.o missing.o \
		estlib.def emximp.a -leuser -uid3 0x100002c3

estlib.o: estlib.cc
missing.o: missing.cc missing.h

emximp.def: $(LIB)/emx.def emximp.awk
	awk -f emximp.awk $(LIB)/emx.def >emximp.def

emximp.a: emximp.def
	arm-epoc-pe-dlltool --output-lib emximp.a --input-def emximp.def \
		--dllname "emx[$(EMXDLLUID)].dll"

clean:
	rm -f emximp.sed emximp.def estlib.def missing.h
	rm -f emximp.a estlib.o missing.o estlib.dll
