1*b30d1939SAndy Fiddaman/*
2*b30d1939SAndy Fiddaman * command library -- commands small enough to be builtins
3*b30d1939SAndy Fiddaman */
4*b30d1939SAndy Fiddaman
5*b30d1939SAndy Fiddaman:PACKAGE: ast
6*b30d1939SAndy Fiddaman
7*b30d1939SAndy FiddamanLICENSE = since=1992,author=gsf+dgk
8*b30d1939SAndy Fiddaman
9*b30d1939SAndy FiddamanCCFLAGS = $(CC.SUFFIX.DEBUG:+$(CC.DEBUG)) $(CC.OPTIMIZE) $(CC.DLL)
10*b30d1939SAndy Fiddaman
11*b30d1939SAndy Fiddaman/* 2009-04-15 ld.so experiment -- may become a default for all plugins */
12*b30d1939SAndy FiddamanCC.DLL.ORIGIN = $(CC.LD.ORIGIN:C,/.*,,)
13*b30d1939SAndy FiddamanLDFLAGS = $(CC.DLL.ORIGIN)
14*b30d1939SAndy Fiddaman
15*b30d1939SAndy FiddamanCP = $(STDCP|"cp")
16*b30d1939SAndy FiddamanCHMOD = $(STDCHMOD|"chmod")
17*b30d1939SAndy Fiddaman
18*b30d1939SAndy FiddamanHOSTTYPE == "$(CC.HOSTTYPE)"
19*b30d1939SAndy Fiddaman
20*b30d1939SAndy Fiddamancmd 1.2 :LIBRARY: RELEASE cmdinit.c \
21*b30d1939SAndy Fiddaman	cmd.h rev.h wc.h \
22*b30d1939SAndy Fiddaman	basename.c cat.c chgrp.c chmod.c chown.c cksum.c cmp.c \
23*b30d1939SAndy Fiddaman	comm.c cp.c cut.c dirname.c date.c expr.c fds.c fmt.c fold.c \
24*b30d1939SAndy Fiddaman	getconf.c head.c id.c join.c ln.c logname.c md5sum.c mkdir.c \
25*b30d1939SAndy Fiddaman	mkfifo.c mktemp.c mv.c paste.c pathchk.c pids.c rev.c rm.c \
26*b30d1939SAndy Fiddaman	rmdir.c stty.c sum.c sync.c tail.c tee.c tty.c uname.c uniq.c \
27*b30d1939SAndy Fiddaman	vmstate.c wc.c revlib.c wclib.c sumlib.o \
28*b30d1939SAndy Fiddaman	fts_fix.c lib.c \
29*b30d1939SAndy Fiddaman	-lfsg -lmd -lutil
30*b30d1939SAndy Fiddaman
31*b30d1939SAndy Fiddamansumlib.o : +lsum
32*b30d1939SAndy Fiddaman	$(AR) x $(*:O=1) $(<)
33*b30d1939SAndy Fiddaman
34*b30d1939SAndy Fiddaman$(INCLUDEDIR) :INSTALLPROTO: cmd.h cmdext.h cmdlist.h
35*b30d1939SAndy Fiddaman
36*b30d1939SAndy Fiddaman"win32*" :NOOPTIMIZE: id.c
37*b30d1939SAndy Fiddaman
38*b30d1939SAndy Fiddamansrc = $(*$(*$(*cmd)):N=*.c:T=F)
39*b30d1939SAndy Fiddaman
40*b30d1939SAndy Fiddamancmdext.h : (src) $$(-mam:+$$(src))
41*b30d1939SAndy Fiddaman	{
42*b30d1939SAndy Fiddaman	cat <<!
43*b30d1939SAndy Fiddaman	$("#")pragma prototyped
44*b30d1939SAndy Fiddaman	$("/")*
45*b30d1939SAndy Fiddaman	$(" ")* -lcmd extern function prototypes
46*b30d1939SAndy Fiddaman	$(" ")*/
47*b30d1939SAndy Fiddaman
48*b30d1939SAndy Fiddaman	$("#")include <shcmd.h>
49*b30d1939SAndy Fiddaman
50*b30d1939SAndy Fiddaman	!
51*b30d1939SAndy Fiddaman	$(SED) \
52*b30d1939SAndy Fiddaman		-e '/^b_[a-z_][a-z_0-9]*(/!d' \
53*b30d1939SAndy Fiddaman		-e 's/^b_//' \
54*b30d1939SAndy Fiddaman		-e 's/(.*//' \
55*b30d1939SAndy Fiddaman		-e 's/.*/extern int	b_&(int, char**, Shbltin_t*);/' \
56*b30d1939SAndy Fiddaman		$($(~:O=1)) |
57*b30d1939SAndy Fiddaman	$(SORT) -u
58*b30d1939SAndy Fiddaman	} > 1.$(tmp).h
59*b30d1939SAndy Fiddaman	if	$(CMP) $(CMPFLAGS) 1.$(tmp).h $(<)
60*b30d1939SAndy Fiddaman	then	$(RM) $(RMFLAGS) 1.$(tmp).h
61*b30d1939SAndy Fiddaman	else	$(MV) 1.$(tmp).h $(<)
62*b30d1939SAndy Fiddaman	fi
63*b30d1939SAndy Fiddaman
64*b30d1939SAndy Fiddamancmdlist.h : (src) $$(-mam:+$$(src))
65*b30d1939SAndy Fiddaman	{
66*b30d1939SAndy Fiddaman	cat <<!
67*b30d1939SAndy Fiddaman	$("#")pragma prototyped
68*b30d1939SAndy Fiddaman	$("/")*
69*b30d1939SAndy Fiddaman	$(" ")* -lcmd function list -- define your own CMDLIST()
70*b30d1939SAndy Fiddaman	$(" ")*/
71*b30d1939SAndy Fiddaman
72*b30d1939SAndy Fiddaman	!
73*b30d1939SAndy Fiddaman	$(SED) \
74*b30d1939SAndy Fiddaman		-e '/^b_[a-z_][a-z_0-9]*(/!d' \
75*b30d1939SAndy Fiddaman		-e 's/^b_//' \
76*b30d1939SAndy Fiddaman		-e 's/(.*//' \
77*b30d1939SAndy Fiddaman		-e 's/.*/CMDLIST(&)/' \
78*b30d1939SAndy Fiddaman		$($(~):T=F) |
79*b30d1939SAndy Fiddaman	$(SORT) -u
80*b30d1939SAndy Fiddaman	} > 1.$(tmp).h
81*b30d1939SAndy Fiddaman	if	$(CMP) $(CMPFLAGS) 1.$(tmp).h $(<)
82*b30d1939SAndy Fiddaman	then	$(RM) $(RMFLAGS) 1.$(tmp).h
83*b30d1939SAndy Fiddaman	else	$(MV) 1.$(tmp).h $(<)
84*b30d1939SAndy Fiddaman	fi
85*b30d1939SAndy Fiddaman
86*b30d1939SAndy Fiddamanif CC.HOSTTYPE == "sun4"
87*b30d1939SAndy Fiddaman	pathsetlink == symlink	/* ld.so workaround */
88*b30d1939SAndy Fiddamanend
89*b30d1939SAndy Fiddaman
90*b30d1939SAndy Fiddamanignore dlldefs.h /* prevents bootstrap double build */
91