1 1.70 christos # $NetBSD: bsd.prog.mk,v 1.70 1997/04/18 14:30:25 christos Exp $ 2 1.67 mikel # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 3 1.1 cgd 4 1.1 cgd .if exists(${.CURDIR}/../Makefile.inc) 5 1.1 cgd .include "${.CURDIR}/../Makefile.inc" 6 1.1 cgd .endif 7 1.48 mycroft 8 1.48 mycroft .include <bsd.own.mk> 9 1.1 cgd 10 1.18 mycroft .SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0 11 1.1 cgd 12 1.25 mycroft CFLAGS+= ${COPTS} 13 1.1 cgd 14 1.69 thorpej # ELF platforms depend on crtbegin.o and crtend.o 15 1.69 thorpej .if (${MACHINE_ARCH} == "alpha") || \ 16 1.69 thorpej (${MACHINE_ARCH} == "powerpc") 17 1.69 thorpej LIBCRTBEGIN?= ${DESTDIR}/usr/lib/crtbegin.o 18 1.69 thorpej LIBCRTEND?= ${DESTDIR}/usr/lib/crtend.o 19 1.69 thorpej .else 20 1.69 thorpej LIBCRTBEGIN?= 21 1.69 thorpej LIBCRTEND?= 22 1.69 thorpej .endif 23 1.69 thorpej 24 1.46 mycroft LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o 25 1.46 mycroft LIBC?= ${DESTDIR}/usr/lib/libc.a 26 1.63 christos LIBC_PIC?= ${DESTDIR}/usr/lib/libc_pic.a 27 1.46 mycroft LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a 28 1.46 mycroft LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a 29 1.46 mycroft LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a 30 1.46 mycroft LIBDBM?= ${DESTDIR}/usr/lib/libdbm.a 31 1.46 mycroft LIBDES?= ${DESTDIR}/usr/lib/libdes.a 32 1.51 mycroft LIBEDIT?= ${DESTDIR}/usr/lib/libedit.a 33 1.46 mycroft LIBGCC?= ${DESTDIR}/usr/lib/libgcc.a 34 1.63 christos LIBGNUMALLOC?= ${DESTDIR}/usr/lib/libgnumalloc.a 35 1.46 mycroft LIBKDB?= ${DESTDIR}/usr/lib/libkdb.a 36 1.46 mycroft LIBKRB?= ${DESTDIR}/usr/lib/libkrb.a 37 1.46 mycroft LIBKVM?= ${DESTDIR}/usr/lib/libkvm.a 38 1.55 jtc LIBL?= ${DESTDIR}/usr/lib/libl.a 39 1.46 mycroft LIBM?= ${DESTDIR}/usr/lib/libm.a 40 1.46 mycroft LIBMP?= ${DESTDIR}/usr/lib/libmp.a 41 1.70 christos LIBNTP?= ${DESTDIR}/usr/lib/libntp.a 42 1.46 mycroft LIBPC?= ${DESTDIR}/usr/lib/libpc.a 43 1.58 mikel LIBPCAP?= ${DESTDIR}/usr/lib/libpcap.a 44 1.46 mycroft LIBPLOT?= ${DESTDIR}/usr/lib/libplot.a 45 1.46 mycroft LIBRESOLV?= ${DESTDIR}/usr/lib/libresolv.a 46 1.46 mycroft LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a 47 1.46 mycroft LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a 48 1.46 mycroft LIBTERMCAP?= ${DESTDIR}/usr/lib/libtermcap.a 49 1.63 christos LIBTELNET?= ${DESTDIR}/usr/lib/libtelnet.a 50 1.46 mycroft LIBUTIL?= ${DESTDIR}/usr/lib/libutil.a 51 1.57 mrg LIBWRAP?= ${DESTDIR}/usr/lib/libwrap.a 52 1.55 jtc LIBY?= ${DESTDIR}/usr/lib/liby.a 53 1.57 mrg LIBZ?= ${DESTDIR}/usr/lib/libz.a 54 1.1 cgd 55 1.1 cgd .if defined(SHAREDSTRINGS) 56 1.1 cgd CLEANFILES+=strings 57 1.1 cgd .c.o: 58 1.1 cgd ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - 59 1.1 cgd @${CC} ${CFLAGS} -c x.c -o ${.TARGET} 60 1.1 cgd @rm -f x.c 61 1.18 mycroft 62 1.18 mycroft .cc.o: 63 1.18 mycroft ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c - 64 1.18 mycroft @mv -f x.c x.cc 65 1.18 mycroft @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET} 66 1.26 mycroft @rm -f x.cc 67 1.18 mycroft 68 1.18 mycroft .C.o: 69 1.18 mycroft ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c - 70 1.18 mycroft @mv -f x.c x.C 71 1.18 mycroft @${CXX} ${CXXFLAGS} -c x.C -o ${.TARGET} 72 1.26 mycroft @rm -f x.C 73 1.1 cgd .endif 74 1.1 cgd 75 1.38 jtc 76 1.1 cgd .if defined(PROG) 77 1.40 cgd SRCS?= ${PROG}.c 78 1.45 cgd .if !empty(SRCS:N*.h:N*.sh) 79 1.52 cgd OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g} 80 1.52 cgd LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} 81 1.45 cgd .endif 82 1.1 cgd 83 1.47 cgd .if defined(OBJS) && !empty(OBJS) 84 1.46 mycroft .if defined(DESTDIR) 85 1.4 nate 86 1.69 thorpej ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD} 87 1.69 thorpej ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib -L${DESTDIR}/usr/lib ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD} -lgcc -lc -lgcc ${LIBCRTEND} 88 1.4 nate 89 1.46 mycroft .else 90 1.4 nate 91 1.69 thorpej ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD} 92 1.32 cgd ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD} 93 1.1 cgd 94 1.47 cgd .endif # defined(DESTDIR) 95 1.47 cgd .endif # defined(OBJS) && !empty(OBJS) 96 1.1 cgd 97 1.49 cgd .if !defined(MAN) 98 1.49 cgd MAN= ${PROG}.1 99 1.49 cgd .endif # !defined(MAN) 100 1.49 cgd .endif # defined(PROG) 101 1.11 mycroft 102 1.1 cgd .MAIN: all 103 1.43 cgd all: ${PROG} _SUBDIRUSE 104 1.1 cgd 105 1.1 cgd .if !target(clean) 106 1.60 cgd cleanprog: 107 1.53 cgd rm -f a.out [Ee]rrs mklog core *.core \ 108 1.53 cgd ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES} 109 1.1 cgd 110 1.60 cgd clean: _SUBDIRUSE cleanprog 111 1.60 cgd cleandir: _SUBDIRUSE cleanprog 112 1.60 cgd .else 113 1.43 cgd cleandir: _SUBDIRUSE clean 114 1.60 cgd .endif 115 1.59 cgd 116 1.59 cgd .if defined(SRCS) 117 1.59 cgd afterdepend: .depend 118 1.59 cgd @(TMP=/tmp/_depend$$$$; \ 119 1.59 cgd sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \ 120 1.59 cgd < .depend > $$TMP; \ 121 1.59 cgd mv $$TMP .depend) 122 1.59 cgd .endif 123 1.27 mycroft 124 1.1 cgd .if !target(install) 125 1.1 cgd .if !target(beforeinstall) 126 1.1 cgd beforeinstall: 127 1.1 cgd .endif 128 1.1 cgd .if !target(afterinstall) 129 1.1 cgd afterinstall: 130 1.1 cgd .endif 131 1.1 cgd 132 1.14 mycroft .if !target(realinstall) 133 1.63 christos 134 1.1 cgd .if defined(PROG) 135 1.63 christos PROGNAME?= ${PROG} 136 1.63 christos proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME} 137 1.63 christos .if !defined(UPDATE) 138 1.63 christos .PHONY: ${DESTDIR}${BINDIR}/${PROGNAME} 139 1.63 christos .endif 140 1.63 christos .if !defined(BUILD) 141 1.63 christos ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE 142 1.63 christos .endif 143 1.63 christos 144 1.63 christos ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} 145 1.69 thorpej ${INSTALL} ${COPY} ${STRIPFLAG} -o ${BINOWN} -g ${BINGRP} \ 146 1.69 thorpej -m ${BINMODE} ${.ALLSRC} ${.TARGET} 147 1.23 mycroft .endif 148 1.23 mycroft 149 1.63 christos .if defined(SCRIPTS) 150 1.65 mycroft SCRIPTSDIR?=${BINDIR} 151 1.65 mycroft SCRIPTSOWN?=${BINOWN} 152 1.65 mycroft SCRIPTSGRP?=${BINGRP} 153 1.65 mycroft SCRIPTSMODE?=${BINMODE} 154 1.63 christos .for S in ${SCRIPTS} 155 1.65 mycroft SCRIPTSDIR_${S}?=${SCRIPTSDIR} 156 1.65 mycroft SCRIPTSOWN_${S}?=${SCRIPTSOWN} 157 1.65 mycroft SCRIPTSGRP_${S}?=${SCRIPTSGRP} 158 1.65 mycroft SCRIPTSMODE_${S}?=${SCRIPTSMODE} 159 1.63 christos .if defined(SCRIPTSNAME) 160 1.63 christos SCRIPTSNAME_${S} ?= ${SCRIPTSNAME} 161 1.63 christos .else 162 1.63 christos SCRIPTSNAME_${S} ?= ${S:T:R} 163 1.63 christos .endif 164 1.65 mycroft SCRIPTSDIR_${S} ?= ${SCRIPTSDIR} 165 1.65 mycroft proginstall:: ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}} 166 1.63 christos .if !defined(UPDATE) 167 1.65 mycroft .PHONY: ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}} 168 1.63 christos .endif 169 1.63 christos .if !defined(BUILD) 170 1.65 mycroft ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}}: .MADE 171 1.63 christos .endif 172 1.63 christos 173 1.65 mycroft ${DESTDIR}${SCRIPTSDIR_${S}}/${SCRIPTSNAME_${S}}: ${S} 174 1.65 mycroft ${INSTALL} ${COPY} -o ${SCRIPTSOWN_${S}} -g ${SCRIPTSGRP_${S}} \ 175 1.65 mycroft -m ${SCRIPTSMODE_${S}} ${.ALLSRC} ${.TARGET} 176 1.63 christos .endfor 177 1.14 mycroft .endif 178 1.1 cgd 179 1.63 christos .if target(proginstall) 180 1.66 christos realinstall: proginstall filesinstall 181 1.63 christos .else 182 1.66 christos realinstall: filesinstall 183 1.63 christos .endif 184 1.63 christos .endif 185 1.63 christos 186 1.63 christos install: ${MANINSTALL} _SUBDIRUSE linksinstall 187 1.63 christos 188 1.63 christos ${MANINSTALL}: afterinstall 189 1.1 cgd afterinstall: realinstall 190 1.1 cgd realinstall: beforeinstall 191 1.1 cgd .endif 192 1.1 cgd 193 1.1 cgd .if !target(lint) 194 1.52 cgd lint: ${LOBJS} 195 1.52 cgd .if defined(LOBJS) && !empty(LOBJS) 196 1.52 cgd @${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD} 197 1.1 cgd .endif 198 1.1 cgd .endif 199 1.1 cgd 200 1.1 cgd .if !defined(NOMAN) 201 1.1 cgd .include <bsd.man.mk> 202 1.50 jtc .endif 203 1.50 jtc 204 1.50 jtc .if !defined(NONLS) 205 1.50 jtc .include <bsd.nls.mk> 206 1.1 cgd .endif 207 1.24 mycroft 208 1.24 mycroft .include <bsd.obj.mk> 209 1.63 christos .include <bsd.links.mk> 210 1.66 christos .include <bsd.files.mk> 211 1.63 christos .include <bsd.inc.mk> 212 1.26 mycroft .include <bsd.dep.mk> 213 1.28 mycroft .include <bsd.subdir.mk> 214 1.54 christos .include <bsd.sys.mk> 215