+DESTDIR=
+CFLAGS= -O
+SRC_MFLAGS= -k
+
+LIBDIR= lib usr.lib
+# order is important, old and man must be #1 and #2
+SRCDIR= old man bin etc games local new ucb usr.bin
+
+all: ${LIBDIR} ${SRCDIR}
+
+libthenall: buildlib1 buildlib3 ${SRCDIR}
+
+build: clean depend buildlib1 buildlib2 buildlib3 ${SRCDIR}
+
+lib: FRC
+ cd lib/libc; make ${MFLAGS} ${LIBCDEFS}
+ cd lib; make ${MFLAGS} pcc cpp c2
+
+usr.lib ${SRCDIR}: FRC
+ cd $@; make ${MFLAGS} ${SRC_MFLAGS}
+
+buildlib1: FRC
+ @echo installing /usr/include
+ cd include; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ @echo
+ @echo compiling libc.a
+ cd lib/libc; make ${MFLAGS} ${LIBCDEFS}
+ @echo installing /lib/libc.a
+ cd lib/libc; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ @echo
+ @echo compiling C compiler
+ cd lib; make ${MFLAGS} pcc cpp c2
+ @echo installing C compiler
+ cd lib/pcc; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ cd lib/cpp; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ cd lib/c2; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ @echo
+
+buildlib2: FRC
+ cd lib; make ${MFLAGS} clean
+ @echo re-compiling libc.a
+ cd lib/libc; make ${MFLAGS} ${LIBCDEFS}
+ @echo re-installing /lib/libc.a
+ cd lib/libc; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ @echo
+ @echo re-compiling C compiler
+ cd lib; make ${MFLAGS} pcc cpp c2
+ @echo re-installing C compiler
+ cd lib/pcc; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ cd lib/cpp; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ cd lib/c2; make ${MFLAGS} DESTDIR=${DESTDIR} install
+ @echo
+
+buildlib3: FRC
+ @echo compiling usr.lib
+ cd usr.lib; make ${MFLAGS} ${SRC_MFLAGS}
+ @echo installing /usr/lib
+ cd usr.lib; make ${MFLAGS} ${SRC_MFLAGS} DESTDIR=${DESTDIR} install
+ @echo
+
+install: FRC
+ -for i in ${LIBDIR} ${SRCDIR}; do \
+ (cd $$i; \
+ make ${MFLAGS} ${SRC_MFLAGS} DESTDIR=${DESTDIR} install); \
+ done
+
+installsrc: FRC
+ -for i in ${SRCDIR}; do \
+ (cd $$i; \
+ make ${MFLAGS} ${SRC_MFLAGS} DESTDIR=${DESTDIR} install); \
+ done