#
# $Id: Makefile,v 1.14 2020/03/27 03:23:16 piru Exp $
#
# :ts=8
#
# SMB file system for MorphOS Makefile
#
# Copyright (C) 2003-2009 by Nicholai 'Nadir' Benalal,
# Sigbjrn 'CISC' Skjret and Harry 'Piru' Sintonen <sintonen@iki.fi>
#
# This program 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 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

CC		=	ppc-morphos-gcc
STRIP		=	ppc-morphos-strip

LIB		=	/gg/morphos/lib
G_LIB		=	-L$(LIB)
G_CFLAGS	=	-noixemul
G_LDFLAGS	=	-nostartfiles
G_OPTFLAGS	=	-O2
#G_DEFINES	=	
G_DEFINES	=	-D__MOSDOS64__ #-DDUMP_SMB
G_WARN		=	-Wall
G_IPATH		=	-I./include
OUTPUT = smbfs

.PHONY: all clean install install-iso dist

.c.o:
	@echo "Making $@..."
	@$(CC) $(G_CFLAGS) $(G_OPTFLAGS) $(G_WARN) $(G_DEBUG) $(G_DEFINES) $(G_IPATH) -c -o $*.o $*.c

all: smbfs

OBJS = main.o proc.o sock.o smb_abstraction.o crypt.o assert.o gui.o dump_smb.o errno.o

assert.o:          assert.c
crypt.o:           crypt.c smbfs.h
dump_smb.o:        dump_smb.c system_headers.h assert.h smbfs.h dump_smb.h Makefile
main.o:            main.c smbfs.h smb_abstraction.h smbfs_rev.h dump_smb.h Makefile
proc.o:            proc.c smbfs.h
smb_abstraction.o: smb_abstraction.c smbfs.h smb_abstraction.h
sock.o:            sock.c smbfs.h smb_abstraction.h dump_smb.h Makefile
system_headers.o:  system_headers.c system_headers.h


smbfs: $(OBJS)
	@echo "Making $@..."
	@$(CC) $(G_CFLAGS) $(G_LDFLAGS) $(G_LIB) $(OBJS) -labox -ldebug -lsyscall -o $@.db
	@$(STRIP) --strip-unneeded --remove-section .comment $@.db -o $@
	@chmod u+x smbfs

clean:
	@rm -f smbfs *.db *.o *~

install: all
	mkdir -p /MOSSYS/C
	cp $(OUTPUT) /MOSSYS/C/SmbFS

install-iso: $(OUTPUT)
	mkdir -p $(ISOPATH)MorphOS/C
	cp $(OUTPUT) $(ISOPATH)MorphOS/C/SmbFS
	mkdir -p $(ISOPATH)MorphOS/Locale/Help/english
	cp doc/smbfs.doc $(ISOPATH)MorphOS/Locale/Help/english/SmbFS.txt

dist: all
	@rm -rf /t/smbfs-mos /t/smbfs-mos.lha
	@mkdir -p /t/smbfs-mos
	@mkdir -p /t/smbfs-mos/source
	@cp -r . /t/smbfs-mos/source/
	@rm -f /t/smbfs-mos/source/*.o /t/smbfs-mos/source/*.db /t/smbfs-mos/source/.cvsignore
	@find /t/smbfs-mos/source/ -name 'CVS' | xargs rm -rf --
	@mv /t/smbfs-mos/source/smbfs /t/smbfs-mos/
	@mv /t/smbfs-mos/source/ChangeLog /t/smbfs-mos/
	@mv /t/smbfs-mos/source/doc/* /t/smbfs-mos/
	@rm -rf /t/smbfs-mos/source/doc/
	@lha -I -q -2 -x -r a t:smbfs-mos.lha t: smbfs-mos
	@rm -rf /t/smbfs-mos
	@echo "t:smbfs-mos.lha ready for distribution"

source:
	(cd .. && tar --exclude CVS --exclude .cvsignore --transform "s,^smbfs,&-handler," -cf $(SOURCEPATH)smbfs-handler.tar smbfs)
