ROOTPATH=../../../../
-include $(ROOTPATH)Makefile.global
ifndef GLOBAL_MAKEFILE_INCLUDED
LINKECHO=@echo Linking $@ ...
LINKPREFIX=@
COMPILEECHO=@echo Compiling $@ ...
COMPILEPREFIX=@
CC=ppc-morphos-gcc
LD=ppc-morphos-ld
AS=ppc-morphos-as
STRIP=ppc-morphos-strip
CFLAGS=-O2 -Wall -noixemul
STRIPFLAGS=--strip-unneeded --remove-section=.comment

.c.o:
	$(COMPILEECHO)
	$(COMPILEPREFIX)$(CC) $(CFLAGS) -c $< -o $@
endif

SHELL	=	/bin/sh

#   $Id: source-Makefile,v 1.1 2016/01/02 21:22:27 piru Exp $
#   makefile for GCC
#
#   XAD library system for archive handling
#   Copyright (C) 1998 and later by Dirk Stcker <soft@dstoecker.de>
#
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU Lesser General Public
#   License as published by the Free Software Foundation; either
#   version 2.1 of the License, or (at your option) any later version.
#
#   This library 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
#   Lesser General Public License for more details.
#
#   You should have received a copy of the GNU Lesser General Public
#   License along with this library; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

ODIR = 

LDIR = ../
CDIR = $(LDIR)clients/
IDIR = $(LDIR)include/
ADIR = $(LDIR)amiga/

G_IPATH		=	-I$(IDIR) -I$(CDIR) -I$(ADIR) -I../../amiga/include/C
G_DEFINES	=	-DSDI_MORPHOSNOREG -DUSE_INLINE_STDARG
G_OPTFLAGS	=	-c -O2 -noixemul -fomit-frame-pointer -mcpu=603e
CFLAGS		=	$(G_CFLAGS) $(G_OPTFLAGS) $(G_DEBUG) $(G_DEFINES) $(G_IPATH)

LNOPT = -nostartfiles -noixemul
CCTO  = -o

LIBNAME		=	xadmaster.library

build:	$(LIBNAME)

HFILES   = \
	$(IDIR)ConvertE.c \
	$(IDIR)functions.h \
	$(IDIR)privdefs.h \
	$(IDIR)version.h \
	$(IDIR)xadmaster.h

CFILES = \
	$(CDIR)Ace.c \
	$(CDIR)AMPK.c \
	$(CDIR)bzip2.c \
	$(CDIR)CAB.c \
	$(CDIR)Cpio.c \
	$(CDIR)CrunchDisk.c \
	$(CDIR)DMS.c \
	$(CDIR)DCS.c \
	$(CDIR)IFF-CDAF.c \
	$(CDIR)FS_Amiga.c \
        $(CDIR)FS_FAT.c \
        $(CDIR)FS_SOS.c \
        $(CDIR)LhA.c \
	$(CDIR)LhF.c \
	$(CDIR)LZX.c \
	$(CDIR)MDC.c \
	$(CDIR)MXM-SimpleArc.c \
	$(CDIR)PackDev.c \
	$(CDIR)PackDisk.c \
	$(CDIR)RPM.c \
	$(CDIR)StuffIt.c \
	$(CDIR)SuperDuper3.c \
	$(CDIR)Tar.c \
	$(CDIR)xDisk.c \
	$(CDIR)xMash.c \
	$(CDIR)Zip.c \
	$(CDIR)Zoom.c \
	$(CDIR)xadIO_Compress.c \
	$(CDIR)xadIO_XPK.c \
	$(CDIR)xadIO.h \
	$(CDIR)xadIO.c

CHARSET = \
	$(LDIR)cs_atarist_to_unicode.c \
	$(LDIR)cs_c64_to_unicode.c \
	$(LDIR)cs_ibmcp437_to_unicode.c \
	$(LDIR)cs_macroman_to_unicode.c \
	$(LDIR)cs_unicode_to_iso8859-1.c \
	$(LDIR)cs_windowscp1252_to_unicod.c

FILES = $(LDIR)allxad.c \
	$(LDIR)clientfunc.c \
	$(LDIR)copymem.c \
	$(LDIR)crc.c \
	$(LDIR)dates.c \
	$(LDIR)diskfile.c \
	$(LDIR)diskunarc.c \
        $(LDIR)error.c \
        $(LDIR)filename.c \
        $(LDIR)fileunarc.c \
        $(LDIR)hook.c \
        $(ADIR)hook_disk.c \
        $(LDIR)hook_diskarc.c \
        $(ADIR)hook_fh.c \
        $(LDIR)hook_mem.c \
        $(LDIR)hook_splitted.c \
        $(LDIR)hook_stream.c \
        $(LDIR)info.c \
        $(LDIR)objects.c \
        $(LDIR)protection.c \
	$(HFILES) $(CHARSET)

# ******* object files *******

$(ODIR)libinit.o: $(HFILES) $(ADIR)libinit.c
	$(COMPILEECHO)
	$(COMPILEPREFIX)$(CC) $(ADIR)libinit.c $(CFLAGS) $(CPUOPTFLAGS) -c -o $@

$(ODIR)clients.o: $(HFILES) $(LDIR)clients.c $(CFILES)
	$(COMPILEECHO)
	$(COMPILEPREFIX)$(CC) $(LDIR)clients.c $(CFLAGS) $(CPUOPTFLAGS) -c -o $@

$(ODIR)allxad.o: $(FILES)
	$(COMPILEECHO)
	$(COMPILEPREFIX)$(CC) $(LDIR)allxad.c $(CFLAGS) $(CPUOPTFLAGS) -c -o $@

# ******* libraries creation *******

$(LIBNAME): $(ODIR)libinit.o $(ODIR)allxad.o $(ODIR)clients.o
	$(LINKECHO)
	$(LINKPREFIX)$(LD) -fl libnix $(ODIR)libinit.o $(ODIR)allxad.o $(ODIR)clients.o -o $@.db -labox -lc
	$(LINKPREFIX)$(STRIP) $(STRIPFLAGS) $@.db -o $@

install: build
	@echo installing $(LIBNAME) ..
	@cp $(LIBNAME) /mossys/Libs/$(LIBNAME)
	-flushlib xadmaster.library

clean:
	@-rm -f $(LIBNAME) *.db *.o

