1#ident "@(#)rules.pkg	1.8 21/04/28 "
2###########################################################################
3# Written 2005 by J. Schilling
4###########################################################################
5#
6# Rules for creating binary tar packages
7#
8###########################################################################
9# Copyright (c) J. Schilling
10###########################################################################
11# The contents of this file are subject to the terms of the
12# Common Development and Distribution License, Version 1.0 only
13# (the "License").  You may not use this file except in compliance
14# with the License.
15#
16# See the file CDDL.Schily.txt in this distribution for details.
17# A copy of the CDDL is also available via the Internet at
18# http://www.opensource.org/licenses/cddl1.txt
19#
20# When distributing Covered Code, include this CDDL HEADER in each
21# file and include the License file CDDL.Schily.txt from this distribution.
22###########################################################################
23
24###########################################################################
25# If we are included before rules.dir, this will stop to propagate
26# the targets "pkg1" & "pkg" to sub makes but handle packaging at this
27# directory bundling level.
28###########################################################################
29PKGTARGETS=
30
31PROTODIR=	proto/$(OARCH)
32$(PROTODIR):
33		$(MKDIR) -p $@
34
35_TARGETAR=	$(TARGET_AR:%=$(OTARSDIR)/%)
36__TARGETAR=	$(_UNIQ)$(_TARGETAR)
37___TARGETAR=	$(__TARGETAR:$(_UNIQ)=$(PROTODIR))
38TARGETAR=	$(___TARGETAR:$(_UNIQ)%=%)
39
40_MCS_PROJECT=	$(_UNIQ)$(PROJECTNAME)
41__MCS_PROJECT=	$(_MCS_PROJECT:$(_UNIQ)=SPS-Generic)
42MCS_PROJECTNAME= $(__MCS_PROJECT:$(_UNIQ)%=%)
43
44ta:
45	echo "'$(TARGETAR)'"
46	echo "'$(TARGETAR).tar'"
47
48pkg: $(PROTODIR) pkg1 package
49
50pkg1:
51	rm -rf $(PROTODIR)
52	mkdir -p $(PROTODIR) $(PROTODIR)/$(INSBASE)/bin $(PROTODIR)/$(INSBASE)/sbin $(PROTODIR)/$(INSBASE)/etc \
53		$(PROTODIR)/$(INSBASE)/lib $(PROTODIR)/$(INSBASE)/share/man
54	ln -s share/man $(PROTODIR)/$(INSBASE)/man
55	if [ ."$(PRE_INST_CMDS)" != . ]; then cd $(PROTODIR) && eval "$(PRE_INST_CMDS)" ; fi
56	"$(MAKE)" $(MAKE_FILE) DESTDIR=`pwd`/$(PROTODIR) install
57	if [ ."$(POST_INST_CMDS)" != . ]; then cd $(PROTODIR) && eval "$(POST_INST_CMDS)" ; fi
58	-if [ ."$(STRIPLIST)" != . ];  then chmod u+w $(STRIPLIST:%=$(PROTODIR)/%); strip $(STRIPLIST:%=$(PROTODIR)/%); fi
59	-if [ ."$(STRIPXLIST)" != . ]; then chmod u+w $(STRIPXLIST:%=$(PROTODIR)/%); strip -x $(STRIPXLIST:%=$(PROTODIR)/%); fi
60	-if [ ."$(MCSLIST)" != . ];    then chmod u+w $(MCSLIST:%=$(PROTODIR)/%); mcs -d -a "$(MCS_PROJECTNAME)" $(MCSLIST:%=$(PROTODIR)/%); fi
61	if [ ."$(POST_STRIP_CMDS)" != . ]; then cd $(PROTODIR) && eval "$(POST_STRIP_CMDS)" ; fi
62	##find $(PROTODIR) -print | sort > /tmp/so.$$; diff filelist /tmp/so.$$; rm -f /tmp/so.$$
63	#echo 'i pkginfo'	>  SV-pkglist
64	#echo 'i depend'		>> SV-pkglist
65	#echo 'i copyright'	>> SV-pkglist
66
67	#cd $(PROTODIR); find . -print | sort | pkgproto | sed 's/joerg bs/root bin/' >> ../../SV-pkglist
68
69_PKGDEF_DIR=	$(_UNIQ)$(PKGTYPE)
70__PKGDEF_DIR=	$(_PKGDEF_DIR:$(_UNIQ)=default)
71PKGDEF_DIR=	$(__PKGDEF_DIR:$(_UNIQ)%=%)
72
73package:
74	echo PKGDEF_DIR $(PKGDEF_DIR)
75	echo DIRNAME: $(DIRNAME) CURWDIR: $(CURWDIR)
76	#pkgmk -o -b `pwd`/$(PROTODIR)/ -d `pwd`/PKGS -f SV-pkglist
77	#star -C $(PROTODIR)/ pkglist=pkglist -cP > $(TARGETAR).tar
78	#bzip2 -9f $(TARGETAR).tar
79	#rm -rf $(PROTODIR)
80
81	$(NOECHO)list="";								\
82	if [ -d $(SRCROOT)/pkgdefs/$(PKGDEF_DIR) ]; then			\
83		list=`echo $(SRCROOT)/pkgdefs/$(PKGDEF_DIR)/*` ;		\
84	fi;									\
85	for DIR in $${list} ;							\
86	do									\
87		(								\
88		echo "	==> MAKING \"$@\" ON SUBDIRECTORY \"$(CURWDIR)/$$DIR\"";\
89		if [ -d ./$$DIR -a -r ./$$DIR/Makefile ] ; then			\
90			cd ./$$DIR && "$(MAKE)" $(MAKEMACS) XARCH=$(XARCH) DIRNAME=$(CURWDIR)/$$DIR all;	\
91		else								\
92			echo "NOTICE: Partial source ($(CURWDIR)/$$DIR) missing";\
93		fi								\
94		);								\
95	done
96