#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is Mobile Application Link.
#
# The Initial Developer of the Original Code is AvantGo, Inc.
# Portions created by AvantGo, Inc. are Copyright (C) 1997-1999
# AvantGo, Inc. All Rights Reserved.
#
# Makefile to build libmal.prc - mal syslib for PalmOS.
#
# created: djw@avantgo.com, March 18, 1999.
#
# Contributor(s):
#
.SUFFIXES: .prc .shlib

MAL_COMMON_DIR=../../../../common
MAL_COMMON_CLIENT_DIR=../../../common

LIBID =   MBln
PRCNAME = libmal

INCLUDES = -I$(MAL_COMMON_CLIENT_DIR) -I$(MAL_COMMON_DIR) -I.
CC = m68k-palmos-coff-gcc
CFLAGS = -Wall -O2 -g0 $(INCLUDES)
AR = m68k-palmos-coff-ar
BUILDPRC = build-prc
MULTILINK = multilink -basename $(PRCNAME) -fid $(LIBID)
MULTILINK_FLAGS = -stdlib -syslib -segmentsize 27k -deadstrip

MAL_COMMON_CLIENT_CFILES = \
	AGClientProcessor.c \
	AGMobileLinkSettings.c \
	AGSyncProcessor.c \
	AGCommandProcessor.c \
	AGSyncCommon.c \
#

MAL_COMMON_CFILES = \
	AGArray.c \
	AGBase64.c \
	AGBufferReader.c \
	AGBufferWriter.c \
	AGCollection.c \
	AGDBConfig.c \
	AGDesktopInfoPalm.c \
	AGDeviceInfo.c \
	AGDigest.c \
	AGHashTable.c \
	AGLocationConfig.c \
	AGMD5.c \
	AGMsg.c \
	AGNet.c \
	AGNetPilot.c \
	AGPalmProtocol.c \
	AGProtocol.c \
	AGProxy.c \
	AGReader.c \
	AGRecord.c \
	AGServerConfig.c \
	AGSynchronize.c \
	AGUserConfig.c \
	AGUtilPalmOS.c \
	AGUtilUnix.c \
	AGUtilWin.c \
	AGWriter.c \
	md5.c \
	AGProtectedMem.c \
#

MAL_COMMON_OFILES = $(MAL_COMMON_CFILES:.c=.o)
MAL_COMMON_CLIENTOFILES = $(MAL_COMMON_CLIENT_CFILES:.c=.o)

OFILES = $(MAL_COMMON_CLIENTOFILES) $(MAL_COMMON_OFILES)

all:	release

$(PRCNAME).a: $(OFILES) malglue.o
	$(AR) rcs $(PRCNAME).a $(OFILES)

.a.prc: malglue.o $*.a
	rm -f *.$(PRCNAME).grc
	$(MULTILINK) $(MULTILINK_FLAGS) malglue.o `$(AR) t $*.a`
	$(BUILDPRC) -f 'resource|backup' -L $*.prc \
	$* $(LIBID) *.$(PRCNAME).grc || \
	(rm -f $*.prc; false)

$(MAL_COMMON_CLIENT_CFILES):
	for f in $(MAL_COMMON_CLIENT_CFILES); do \
	    cp $(MAL_COMMON_CLIENT_DIR)/$$f $$f ;\
        done

$(MAL_COMMON_CFILES):
	for f in $(MAL_COMMON_CFILES); do \
            cp $(MAL_COMMON_DIR)/$$f $$f ;\
        done

release: $(PRCNAME).prc libmal.h
	mkdir -p ../Release
	cp $(PRCNAME).prc libmal.h ../Release
	chmod 644 ../Release/$(PRCNAME).prc ../Release/libmal.h

clean:
	rm -rf *.shlib *.prc *.glib *.prg *.grc *.bin *.o *.a xxx.c *.s *~ \
	$(MAL_COMMON_CLIENT_CFILES) $(MAL_COMMON_CFILES) o????

