Home | History | Annotate | Line # | Download | only in mk
bsd.prog.mk revision 1.29
      1 #	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
      2 #	$Id: bsd.prog.mk,v 1.29 1993/08/17 17:00:39 mycroft Exp $
      3 
      4 .if exists(${.CURDIR}/../Makefile.inc)
      5 .include "${.CURDIR}/../Makefile.inc"
      6 .endif
      7 
      8 .SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
      9 
     10 CFLAGS+=	${COPTS}
     11 
     12 LIBCRT0?=	/usr/lib/crt0.o
     13 LIBC?=		/usr/lib/libc.a
     14 LIBCOMPAT?=	/usr/lib/libcompat.a
     15 .ifndef EXPORTABLE_SYSTEM
     16 LIBCRYPT?=	/usr/lib/libcrypt.a
     17 .endif
     18 LIBCURSES?=	/usr/lib/libcurses.a
     19 LIBDBM?=	/usr/lib/libdbm.a
     20 LIBDES?=	/usr/lib/libdes.a
     21 LIBL?=		/usr/lib/libl.a
     22 LIBKDB?=	/usr/lib/libkdb.a
     23 LIBKRB?=	/usr/lib/libkrb.a
     24 LIBM?=		/usr/lib/libm.a
     25 LIBMP?=		/usr/lib/libmp.a
     26 LIBPC?=		/usr/lib/libpc.a
     27 LIBPLOT?=	/usr/lib/libplot.a
     28 LIBRESOLV?=	/usr/lib/libresolv.a
     29 LIBRPC?=	/usr/lib/librpc.a
     30 LIBRPCSVC?=	/usr/lib/librpcsvc.a
     31 LIBTERM?=	/usr/lib/libterm.a
     32 LIBUTIL?=	/usr/lib/libutil.a
     33 
     34 .if defined(SHAREDSTRINGS)
     35 CLEANFILES+=strings
     36 .c.o:
     37 	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
     38 	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
     39 	@rm -f x.c
     40 
     41 .cc.o:
     42 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     43 	@mv -f x.c x.cc
     44 	@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
     45 	@rm -f x.cc
     46 
     47 .C.o:
     48 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     49 	@mv -f x.c x.C
     50 	@${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
     51 	@rm -f x.C
     52 .endif
     53 
     54 .if defined(PROG)
     55 .if defined(SRCS)
     56 
     57 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
     58 
     59 .if defined(LDONLY)
     60 
     61 ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
     62 	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDADD}
     63 
     64 .else defined(LDONLY)
     65 
     66 ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
     67 	${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
     68 
     69 .endif
     70 
     71 .else
     72 
     73 SRCS=	${PROG}.c
     74 
     75 ${PROG}: ${SRCS} ${LIBC} ${DPADD}
     76 	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
     77 
     78 MKDEP=	-p
     79 
     80 .endif
     81 
     82 .if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
     83 	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
     84 	!defined(MAN7) && !defined(MAN8)
     85 MAN1=	${PROG}.0
     86 .endif
     87 .endif
     88 
     89 .MAIN: all
     90 all: ${PROG}
     91 
     92 .if !target(clean)
     93 clean:
     94 	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
     95 .endif
     96 
     97 cleandir: clean
     98 
     99 .if !target(install)
    100 .if !target(beforeinstall)
    101 beforeinstall:
    102 .if defined(DESTDIR) || defined(BINDIR)
    103 	@install -d -o root -g wheel -m 755 ${DESTDIR}${BINDIR}
    104 .endif
    105 .endif
    106 .if !target(afterinstall)
    107 afterinstall:
    108 .endif
    109 
    110 .if !target(realinstall)
    111 realinstall:
    112 .if defined(PROG)
    113 	install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    114 	    ${PROG} ${DESTDIR}${BINDIR}
    115 .endif
    116 .if defined(HIDEGAME)
    117 	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
    118 	    chown games.bin ${PROG})
    119 .endif
    120 .endif
    121 
    122 install: maninstall _SUBDIRUSE
    123 .if defined(LINKS) && !empty(LINKS)
    124 	@set ${LINKS}; \
    125 	while test $$# -ge 2; do \
    126 		l=${DESTDIR}$$1; \
    127 		shift; \
    128 		t=${DESTDIR}$$1; \
    129 		shift; \
    130 		echo $$t -\> $$l; \
    131 		rm -f $$t; \
    132 		ln $$l $$t; \
    133 	done; true
    134 .endif
    135 
    136 maninstall: afterinstall
    137 afterinstall: realinstall
    138 realinstall: beforeinstall
    139 .endif
    140 
    141 .if !target(lint)
    142 lint: ${SRCS}
    143 .if defined(PROG)
    144 	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
    145 .endif
    146 .endif
    147 
    148 .if !defined(NOMAN)
    149 .include <bsd.man.mk>
    150 .endif
    151 
    152 .include <bsd.obj.mk>
    153 .include <bsd.dep.mk>
    154 .include <bsd.subdir.mk>
    155