Home | History | Annotate | Line # | Download | only in mk
bsd.prog.mk revision 1.25
      1 #	from: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
      2 #	$Id: bsd.prog.mk,v 1.25 1993/08/15 19:37:10 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 .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0:
     11 	nroff -mandoc ${.IMPSRC} > ${.TARGET}
     12 
     13 CFLAGS+=	${COPTS}
     14 
     15 STRIP?=		-s
     16 
     17 BINGRP?=	bin
     18 BINOWN?=	bin
     19 BINMODE?=	555
     20 
     21 LIBCRT0?=	/usr/lib/crt0.o
     22 LIBC?=		/usr/lib/libc.a
     23 LIBCOMPAT?=	/usr/lib/libcompat.a
     24 .ifndef EXPORTABLE_SYSTEM
     25 LIBCRYPT?=	/usr/lib/libcrypt.a
     26 .endif
     27 LIBCURSES?=	/usr/lib/libcurses.a
     28 LIBDBM?=	/usr/lib/libdbm.a
     29 LIBDES?=	/usr/lib/libdes.a
     30 LIBL?=		/usr/lib/libl.a
     31 LIBKDB?=	/usr/lib/libkdb.a
     32 LIBKRB?=	/usr/lib/libkrb.a
     33 LIBM?=		/usr/lib/libm.a
     34 LIBMP?=		/usr/lib/libmp.a
     35 LIBPC?=		/usr/lib/libpc.a
     36 LIBPLOT?=	/usr/lib/libplot.a
     37 LIBRESOLV?=	/usr/lib/libresolv.a
     38 LIBRPC?=	/usr/lib/librpc.a
     39 LIBRPCSVC?=	/usr/lib/librpcsvc.a
     40 LIBTERM?=	/usr/lib/libterm.a
     41 LIBUTIL?=	/usr/lib/libutil.a
     42 
     43 .if defined(SHAREDSTRINGS)
     44 CLEANFILES+=strings
     45 .c.o:
     46 	${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
     47 	@${CC} ${CFLAGS} -c x.c -o ${.TARGET}
     48 	@rm -f x.c
     49 
     50 .cc.o:
     51 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     52 	@mv -f x.c x.cc
     53 	@${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
     54 
     55 .C.o:
     56 	${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
     57 	@mv -f x.c x.C
     58 	@${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET}
     59 .endif
     60 
     61 .if defined(PROG)
     62 .if defined(SRCS)
     63 
     64 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
     65 
     66 .if defined(LDONLY)
     67 
     68 ${PROG}: ${LIBCRT0} ${LIBC} ${OBJS} ${DPADD}
     69 	${LD} ${LDFLAGS} -o ${.TARGET} ${LIBCRT0} ${OBJS} ${LIBC} ${LDADD}
     70 
     71 .else defined(LDONLY)
     72 
     73 ${PROG}: ${OBJS} ${LIBC} ${DPADD}
     74 	${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}
     75 
     76 .endif
     77 
     78 .else defined(PROG)
     79 
     80 SRCS= ${PROG}.c
     81 
     82 ${PROG}: ${SRCS} ${LIBC} ${DPADD}
     83 	${CC} ${LDFLAGS} ${CFLAGS} -o ${.TARGET} ${.CURDIR}/${SRCS} ${LDADD}
     84 
     85 MKDEP=	-p
     86 
     87 .endif
     88 
     89 .if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
     90 	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
     91 	!defined(MAN7) && !defined(MAN8)
     92 MAN1=	${PROG}.0
     93 .endif
     94 .endif
     95 
     96 .if !defined(NOMAN)
     97 MANALL=	${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8}
     98 .endif
     99 
    100 _PROGSUBDIR: .USE
    101 .if defined(SUBDIR) && !empty(SUBDIR)
    102 	@for entry in ${SUBDIR}; do \
    103 		(echo "===> $$entry"; \
    104 		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
    105 			cd ${.CURDIR}/$${entry}.${MACHINE}; \
    106 		else \
    107 			cd ${.CURDIR}/$${entry}; \
    108 		fi; \
    109 		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
    110 	done
    111 .endif
    112 
    113 .MAIN: all
    114 all: ${PROG} ${MANALL} _PROGSUBDIR
    115 
    116 .if !target(clean)
    117 clean: _PROGSUBDIR
    118 	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
    119 .endif
    120 
    121 .if !target(cleandir)
    122 cleandir: _PROGSUBDIR
    123 	rm -f a.out [Ee]rrs mklog core ${PROG} ${OBJS} ${CLEANFILES}
    124 	rm -f .depend ${MANALL}
    125 .endif
    126 
    127 # some of the rules involve .h sources, so remove them from mkdep line
    128 .include <bsd.dep.mk>
    129 depend: _PROGSUBDIR
    130 
    131 .if !target(install)
    132 .if !target(beforeinstall)
    133 beforeinstall:
    134 .if defined(DESTDIR) || defined(BINDIR)
    135 	@install -d -o root -g wheel -m 755 ${DESTDIR}${BINDIR}
    136 .endif
    137 .endif
    138 .if !target(afterinstall)
    139 afterinstall:
    140 .endif
    141 
    142 .if !target(realinstall)
    143 realinstall: _PROGSUBDIR
    144 .if defined(PROG)
    145 	install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
    146 	    ${PROG} ${DESTDIR}${BINDIR}
    147 .endif
    148 .if defined(HIDEGAME)
    149 	(cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}; \
    150 	    chown games.bin ${PROG})
    151 .endif
    152 .endif
    153 
    154 install: maninstall
    155 .if defined(LINKS) && !empty(LINKS)
    156 	@set ${LINKS}; \
    157 	while test $$# -ge 2; do \
    158 		l=${DESTDIR}$$1; \
    159 		shift; \
    160 		t=${DESTDIR}$$1; \
    161 		shift; \
    162 		echo $$t -\> $$l; \
    163 		rm -f $$t; \
    164 		ln $$l $$t; \
    165 	done; true
    166 .endif
    167 
    168 maninstall: afterinstall
    169 afterinstall: realinstall
    170 realinstall: beforeinstall
    171 .endif
    172 
    173 .if !target(lint)
    174 lint: ${SRCS} _PROGSUBDIR
    175 .if defined(PROG)
    176 	@${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1
    177 .endif
    178 .endif
    179 
    180 .if !target(tags)
    181 tags: ${SRCS} _PROGSUBDIR
    182 .if defined(PROG)
    183 	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
    184 	    sed "s;\${.CURDIR}/;;" > tags
    185 .endif
    186 .endif
    187 
    188 .if !defined(NOMAN)
    189 .include <bsd.man.mk>
    190 .endif
    191 
    192 .include <bsd.obj.mk>
    193 obj: _PROGSUBDIR
    194