lots of rework should be much cleaner
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 26 Sep 1989 09:17:22 +0000 (01:17 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 26 Sep 1989 09:17:22 +0000 (01:17 -0800)
SCCS-vsn: share/mk/bsd.prog.mk 5.4

usr/src/share/mk/bsd.prog.mk

index fb76838..daa821a 100644 (file)
@@ -1,5 +1,6 @@
 
 MAKE=  pmake   # for now...
 
 MAKE=  pmake   # for now...
+CPP=   newcpp
 
 # libraries used for dependency lines
 LIBUTIL=       /usr/lib/libutil.a
 
 # libraries used for dependency lines
 LIBUTIL=       /usr/lib/libutil.a
@@ -21,9 +22,9 @@ MANALL=       ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
 # the target "all".  Machine dependent subdirectories take precedence
 # over standard subdirectories.
 .if defined(SUBDIR)
 # the target "all".  Machine dependent subdirectories take precedence
 # over standard subdirectories.
 .if defined(SUBDIR)
-all depend clean cleandir lint tags:
+all depend clean cleandir lint install tags:
        @for entry in ${SUBDIR}; do
        @for entry in ${SUBDIR}; do
-               (echo  "==> $$entry"
+               (echo "====> $$entry"
                if test -d $${entry}.${MACHINE}; then
                        cd $${entry}.${MACHINE}
                else
                if test -d $${entry}.${MACHINE}; then
                        cd $${entry}.${MACHINE}
                else
@@ -75,15 +76,18 @@ all: ${PROGC} ${PROGO}
 .if defined(PROGC)
 SRCS=  ${PROGC}.c
 
 .if defined(PROGC)
 SRCS=  ${PROGC}.c
 
-.if !defined(MANALL)
+.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8)
 MAN1=  ${PROGC}.0
 .endif
 
 ${PROGC}: ${SRCS} ${LIBC} ${SRCLIB}
        ${CC} ${CFLAGS} -o ${.TARGET} ${SRCS} ${LDLIB}
 
 MAN1=  ${PROGC}.0
 .endif
 
 ${PROGC}: ${SRCS} ${LIBC} ${SRCLIB}
        ${CC} ${CFLAGS} -o ${.TARGET} ${SRCS} ${LDLIB}
 
-depend: ${SRCS}
-       mkdep -p ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC}
+.depend: ${SRCS}
+       set -
+       ${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC} |
+               sed "s/^/${PROGC}: /" > ${DEPENDFILE}.new
+       mv ${DEPENDFILE}.new ${DEPENDFILE}
 
 .endif # PROGC
 
 
 .endif # PROGC
 
@@ -95,29 +99,38 @@ depend: ${SRCS}
 
 OBJS=  ${SRCS:.c=.o}
 
 
 OBJS=  ${SRCS:.c=.o}
 
-.if !defined(MANALL)
+.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && !defined(MAN7) && !defined(MAN8)
 MAN1=  ${PROGO}.0
 .endif
 
 ${PROGO}: ${OBJS} ${LIBC} ${SRCLIB}
        ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDLIB}
 
 MAN1=  ${PROGO}.0
 .endif
 
 ${PROGO}: ${OBJS} ${LIBC} ${SRCLIB}
        ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDLIB}
 
-depend: ${SRCS}
-       mkdep ${CFLAGS:M-[ID]*} ${.INCLUDES} ${.ALLSRC}
+.depend: ${SRCS}
+       set -
+       set ${OBJS}
+       rm -f ${DEPENDFILE}.new
+       for entry in ${.ALLSRC}; do
+               ${CPP} -M ${CFLAGS:M-[ID]*} ${.INCLUDES} $$entry |
+                       sed "s/^/$$1: /" >> ${DEPENDFILE}.new
+               shift
+       done
+       mv ${DEPENDFILE}.new ${DEPENDFILE}
 
 ${OBJS}: ${.PREFIX}.c
 
 .endif # PROGO
 
 
 ${OBJS}: ${.PREFIX}.c
 
 .endif # PROGO
 
+depend: .depend
+
 # user defines:
 #      CLEANFILES      -- list of files to be removed for the target clean;
 #                         used, for example, to specify .c's produced from
 #                         .y's.
 # user defines:
 #      CLEANFILES      -- list of files to be removed for the target clean;
 #                         used, for example, to specify .c's produced from
 #                         .y's.
-JUNKFILES=     Errs errs mklog core
+JUNKFILES=     a.out Errs errs mklog core
 clean:
 clean:
-       rm -f ${JUNKFILE} ${PROGC} ${PROGO} ${OBJS} ${CLEANFILES}
+       rm -f ${PROGC} ${PROGO} ${OBJS} ${CLEANFILES} ${JUNKFILES}
 
 
-DEPENDFILE=    .depend
 TAGSFILE=      tags
 cleandir: clean
        rm -f ${MANALL} ${TAGSFILE} ${DEPENDFILE}
 TAGSFILE=      tags
 cleandir: clean
        rm -f ${MANALL} ${TAGSFILE} ${DEPENDFILE}
@@ -130,13 +143,13 @@ tags: ${SRCS}
        ctags ${.ALLSRC}
 
 # user defines:
        ctags ${.ALLSRC}
 
 # user defines:
-#      MDIR    -- default manual page installtion directory
+#      MDIR    -- default manual page installation directory
 #      MANMODE -- default manual page installation mode
 #      STRIP   -- default strip flag
 #      BINMODE -- default binary installation mode
 #      BINOWN  -- default binary owner
 #      BINGRP  -- default binary group
 #      MANMODE -- default manual page installation mode
 #      STRIP   -- default strip flag
 #      BINMODE -- default binary installation mode
 #      BINOWN  -- default binary owner
 #      BINGRP  -- default binary group
-MDIR?=         /usr/man/cat
+MDIR?=         /usr/share/man/cat
 MANMODE?=      444
 STRIP?=                -s
 BINMODE?=      755
 MANMODE?=      444
 STRIP?=                -s
 BINMODE?=      755
@@ -181,45 +194,47 @@ install: ${MANALL}
            ${DESTDIR}${MDIR}8
 .endif
 # user defines:
            ${DESTDIR}${MDIR}8
 .endif
 # user defines:
-#      LINKS   -- list of manual page links of the form "link target
+#      LINKS   -- list of binary links of the form "link target
+#                 link target"; for example, "/bin/[ /usr/bin/test"
+#                 would link /bin/[ to /usr/bin/test"; not particularly
+#                 labor saving, but prevents needing your own install
+#                 target.
+#      MLINKS  -- list of manual page linkes of the form "link target
 #                 link target"; for example, "a.1 b.2 c.3 d.4" would
 #                 link ${MDIR}1/a.0 to ${MDIR}2/b.0 and ${MDIR}3/c.0
 #                 to ${MDIR}4/d.0.
 .if defined(LINKS)
 #                 link target"; for example, "a.1 b.2 c.3 d.4" would
 #                 link ${MDIR}1/a.0 to ${MDIR}2/b.0 and ${MDIR}3/c.0
 #                 to ${MDIR}4/d.0.
 .if defined(LINKS)
-       @set ${LINKS} 
+       @set ${LINKS}
+       @while :; do
+               if `test $$# -lt 2`; then
+                       break;
+               fi
+               t=$$1
+               shift
+               l=$$1
+               shift
+               echo $$l -\> $$t
+               rm -f $$t
+               ln ${DESTDIR}$$l ${DESTDIR}$$t
+       done
+.endif # LINKS
+.if defined(MLINKS)
+       @set ${MLINKS}
        @while :; do
                if `test $$# -lt 2`; then
                        break;
                fi
                name=$$1
        @while :; do
                if `test $$# -lt 2`; then
                        break;
                fi
                name=$$1
-               case $$name in
-                       *.1)    dir=${MDIR}1;;
-                       *.2)    dir=${MDIR}2;;
-                       *.3)    dir=${MDIR}3;;
-                       *.4)    dir=${MDIR}4;;
-                       *.5)    dir=${MDIR}5;;
-                       *.6)    dir=${MDIR}6;;
-                       *.7)    dir=${MDIR}7;;
-                       *.8)    dir=${MDIR}8;;
-               esac
-               t=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0
                shift
                shift
+               dir=${MDIR}`expr $$name : '[^\.]*\.\(.*\)'`
+               t=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0
                name=$$1
                name=$$1
-               case $$name in
-                       *.1)    dir=${MDIR}1;;
-                       *.2)    dir=${MDIR}2;;
-                       *.3)    dir=${MDIR}3;;
-                       *.4)    dir=${MDIR}4;;
-                       *.5)    dir=${MDIR}5;;
-                       *.6)    dir=${MDIR}6;;
-                       *.7)    dir=${MDIR}7;;
-                       *.8)    dir=${MDIR}8;;
-               esac
+               shift
+               dir=${MDIR}`expr $$name : '[^\.]*\.\(.*\)'`
                l=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0
                l=${DESTDIR}$${dir}/`expr $$name : '\([^\.]*\)'`.0
-               rm -f $$t
                echo $$l -\> $$t
                echo $$l -\> $$t
+               rm -f $$t
                ln $$l $$t
                ln $$l $$t
-               shift
        done
        done
-.endif # LINKS
+.endif # MLINKS
 .endif # SUBDIR
 .endif # SUBDIR