[BACK]Return to bsd.prog.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / mk

Annotation of src/share/mk/bsd.prog.mk, Revision 1.201

1.201   ! lukem       1: #      $NetBSD: bsd.prog.mk,v 1.200 2004/06/10 00:29:59 lukem Exp $
1.67      mikel       2: #      @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
1.1       cgd         3:
1.166     lukem       4: .ifndef HOSTPROG
                      5:
1.138     tv          6: .include <bsd.init.mk>
1.159     thorpej     7: .include <bsd.shlib.mk>
1.167     thorpej     8: .include <bsd.gcc.mk>
1.74      mycroft     9:
1.185     erh        10: .if defined(PROG_CXX)
                     11: PROG=  ${PROG_CXX}
                     12: .endif
                     13:
1.138     tv         14: ##### Basic targets
1.80      mycroft    15: realinstall:   proginstall scriptsinstall
1.132     tv         16: clean:         cleanprog
1.1       cgd        17:
1.185     erh        18: ##### PROG specific flags.
1.186     erh        19: COPTS+=     ${COPTS.${PROG}}
1.185     erh        20: CPPFLAGS+=  ${CPPFLAGS.${PROG}}
                     21: CXXFLAGS+=  ${CXXFLAGS.${PROG}}
                     22: LDADD+=     ${LDADD.${PROG}}
1.186     erh        23: LDFLAGS+=   ${LDFLAGS.${PROG}}
                     24: LDSTATIC+=  ${LDSTATIC.${PROG}}
1.185     erh        25:
1.138     tv         26: ##### Default values
1.142     thorpej    27: CPPFLAGS+=     ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include}
1.175     mrg        28: CXXFLAGS+=     ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++}
1.25      mycroft    29: CFLAGS+=       ${COPTS}
1.193     dsl        30: MKDEP_SUFFIXES?=       .o .ln
1.1       cgd        31:
1.162     thorpej    32: # ELF platforms depend on crti.o, crtbegin.o, crtend.o, and crtn.o
1.100     lukem      33: .if ${OBJECT_FMT} == "ELF"
1.153     pk         34: .ifndef LIBCRTBEGIN
1.167     thorpej    35: LIBCRTBEGIN=   ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGIN}
1.152     christos   36: .MADE: ${LIBCRTBEGIN}
1.153     pk         37: .endif
                     38: .ifndef LIBCRTEND
1.167     thorpej    39: LIBCRTEND=     ${_GCC_CRTEND} ${DESTDIR}/usr/lib/crtn.o
1.152     christos   40: .MADE: ${LIBCRTEND}
1.153     pk         41: .endif
1.144     lukem      42: _SHLINKER=     ${SHLINKDIR}/ld.elf_so
1.69      thorpej    43: .else
                     44: LIBCRTBEGIN?=
                     45: LIBCRTEND?=
1.144     lukem      46: _SHLINKER=     ${SHLINKDIR}/ld.so
1.69      thorpej    47: .endif
                     48:
1.153     pk         49: .ifndef LIBCRT0
                     50: LIBCRT0=       ${DESTDIR}/usr/lib/crt0.o
1.152     christos   51: .MADE: ${LIBCRT0}
1.153     pk         52: .endif
1.95      ross       53:
1.138     tv         54: ##### Build and install rules
1.1       cgd        55: .if defined(SHAREDSTRINGS)
                     56: CLEANFILES+=strings
                     57: .c.o:
                     58:        ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
                     59:        @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
                     60:        @rm -f x.c
1.18      mycroft    61:
1.173     lukem      62: .cc.o .cpp.o .cxx.o .C.o:
1.18      mycroft    63:        ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
                     64:        @mv -f x.c x.cc
                     65:        @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
1.26      mycroft    66:        @rm -f x.cc
1.146     thorpej    67: .endif
1.38      jtc        68:
1.1       cgd        69: .if defined(PROG)
1.146     thorpej    70: .if defined(PROG_CXX)
                     71: SRCS?=         ${PROG}.cc
                     72: .else
1.80      mycroft    73: SRCS?=         ${PROG}.c
1.146     thorpej    74: .endif
1.80      mycroft    75:
1.200     lukem      76: _YPSRCS=       ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
                     77:
                     78: DPSRCS+=       ${_YPSRCS}
                     79: CLEANFILES+=   ${_YPSRCS}
1.80      mycroft    80:
1.108     eeh        81: .if !empty(SRCS:N*.h:N*.sh:N*.fth)
                     82: OBJS+=         ${SRCS:N*.h:N*.sh:N*.fth:R:S/$/.o/g}
1.80      mycroft    83: LOBJS+=                ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
1.45      cgd        84: .endif
1.1       cgd        85:
1.47      cgd        86: .if defined(OBJS) && !empty(OBJS)
1.200     lukem      87: .NOPATH: ${OBJS} ${PROG} ${_YPSRCS}
1.137     tv         88:
1.144     lukem      89: _PROGLDOPTS=
                     90: .if ${SHLINKDIR} != "/usr/libexec"     # XXX: change or remove if ld.so moves
1.161     itohy      91: .if ${OBJECT_FMT} == "ELF"
1.144     lukem      92: _PROGLDOPTS+=  -Wl,-dynamic-linker=${_SHLINKER}
1.161     itohy      93: .endif
1.144     lukem      94: .endif
1.187     lukem      95: .if ${SHLIBDIR} != "/usr/lib"
1.144     lukem      96: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
1.179     lukem      97:                -R${SHLIBDIR} \
1.144     lukem      98:                -L${DESTDIR}${SHLIBDIR}
1.187     lukem      99: .elif ${SHLIBINSTALLDIR} != "/usr/lib"
1.159     thorpej   100: _PROGLDOPTS+=  -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
                    101:                -L${DESTDIR}${SHLIBINSTALLDIR}
1.144     lukem     102: .endif
                    103:
1.145     thorpej   104: .if defined(PROG_CXX)
                    105: _CCLINK=       ${CXX}
1.177     lukem     106: .if ${USE_LIBSTDCXX} == "no"
1.174     mrg       107: _SUPCXX=       -lsupc++ -lm
                    108: .else
1.145     thorpej   109: _SUPCXX=       -lstdc++ -lm
1.174     mrg       110: .endif
1.145     thorpej   111: .else
                    112: _CCLINK=       ${CC}
                    113: .endif
                    114:
1.157     thorpej   115: .gdbinit:
                    116:        rm -f .gdbinit
                    117: .if defined(DESTDIR) && !empty(DESTDIR)
                    118:        echo "set solib-absolute-prefix ${DESTDIR}" > .gdbinit
                    119: .else
                    120:        touch .gdbinit
                    121: .endif
                    122: .for __gdbinit in ${GDBINIT}
                    123:        echo "source ${__gdbinit}" >> .gdbinit
                    124: .endfor
                    125:
1.182     lukem     126: ${OBJS} ${LOBJS}: ${DPSRCS}
                    127:
                    128: ${PROG}: .gdbinit ${LIBCRT0} ${OBJS} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD}
1.127     christos  129: .if !commands(${PROG})
1.194     lukem     130:        ${_MKTARGET_LINK}
1.181     lukem     131: .if defined(DESTDIR)
1.198     skrll     132:        ${_CCLINK} -Wl,-nostdlib \
                    133:            ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} \
                    134:            -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/  \
                    135:            ${OBJS} ${LDADD} \
                    136:            -L${_GCC_LIBGCCDIR} -L${DESTDIR}/usr/lib
1.46      mycroft   137: .else
1.145     thorpej   138:        ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD}
1.181     lukem     139: .endif # defined(DESTDIR)
                    140: .endif # !commands(${PROG})
1.183     dsl       141:
                    142: ${PROG}.ro: ${OBJS} ${DPADD}
                    143:        ${LD} -r -dc -o ${.TARGET} ${OBJS}
1.1       cgd       144:
1.47      cgd       145: .endif # defined(OBJS) && !empty(OBJS)
1.1       cgd       146:
1.100     lukem     147: .if !defined(MAN)
1.49      cgd       148: MAN=   ${PROG}.1
                    149: .endif # !defined(MAN)
                    150: .endif # defined(PROG)
1.11      mycroft   151:
1.107     mycroft   152: realall: ${PROG} ${SCRIPTS}
1.1       cgd       153:
1.197     lukem     154: cleanprog: .PHONY cleanobjs cleanextra
1.157     thorpej   155:        rm -f a.out [Ee]rrs mklog core *.core .gdbinit ${PROG}
1.134     tls       156:
1.197     lukem     157: cleanobjs: .PHONY
1.135     lukem     158: .if defined(OBJS) && !empty(OBJS)
1.134     tls       159:        rm -f ${OBJS} ${LOBJS}
1.135     lukem     160: .endif
1.134     tls       161:
1.197     lukem     162: cleanextra: .PHONY
1.135     lukem     163: .if defined(CLEANFILES) && !empty(CLEANFILES)
1.134     tls       164:        rm -f ${CLEANFILES}
1.59      cgd       165: .endif
1.27      mycroft   166:
1.74      mycroft   167: .if defined(PROG) && !target(proginstall)
1.114     mycroft   168: PROGNAME?=${PROG}
                    169:
1.63      christos  170: proginstall:: ${DESTDIR}${BINDIR}/${PROGNAME}
1.114     mycroft   171: .PRECIOUS: ${DESTDIR}${BINDIR}/${PROGNAME}
                    172:
1.115     mycroft   173: __proginstall: .USE
1.192     lukem     174:        ${_MKTARGET_INSTALL}
1.139     tv        175:        ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
1.160     perry     176:                ${STRIPFLAG} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   177:
1.172     lukem     178: .if ${MKUPDATE} == "no"
1.154     mycroft   179: ${DESTDIR}${BINDIR}/${PROGNAME}! ${PROG} __proginstall
                    180: .if !defined(BUILD) && !make(all) && !make(${PROG})
                    181: ${DESTDIR}${BINDIR}/${PROGNAME}! .MADE
                    182: .endif
                    183: .else
                    184: ${DESTDIR}${BINDIR}/${PROGNAME}: ${PROG} __proginstall
1.103     fredb     185: .if !defined(BUILD) && !make(all) && !make(${PROG})
1.63      christos  186: ${DESTDIR}${BINDIR}/${PROGNAME}: .MADE
                    187: .endif
1.154     mycroft   188: .endif
1.23      mycroft   189: .endif
                    190:
1.74      mycroft   191: .if !target(proginstall)
                    192: proginstall::
                    193: .endif
1.197     lukem     194: .PHONY:                proginstall
1.74      mycroft   195:
                    196: .if defined(SCRIPTS) && !target(scriptsinstall)
1.65      mycroft   197: SCRIPTSDIR?=${BINDIR}
                    198: SCRIPTSOWN?=${BINOWN}
                    199: SCRIPTSGRP?=${BINGRP}
                    200: SCRIPTSMODE?=${BINMODE}
1.113     mycroft   201:
                    202: scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.114     mycroft   203: .PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@}
1.113     mycroft   204:
1.115     mycroft   205: __scriptinstall: .USE
1.192     lukem     206:        ${_MKTARGET_INSTALL}
1.139     tv        207:        ${INSTALL_FILE} \
1.116     mycroft   208:            -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \
                    209:            -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \
                    210:            -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \
1.160     perry     211:            ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
1.115     mycroft   212:
1.130     sommerfe  213: .for S in ${SCRIPTS:O:u}
1.172     lukem     214: .if ${MKUPDATE} == "no"
1.154     mycroft   215: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall
                    216: .if !defined(BUILD) && !make(all) && !make(${S})
                    217: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE
                    218: .endif
                    219: .else
                    220: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall
1.103     fredb     221: .if !defined(BUILD) && !make(all) && !make(${S})
1.113     mycroft   222: ${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE
1.63      christos  223: .endif
1.154     mycroft   224: .endif
1.63      christos  225: .endfor
1.14      mycroft   226: .endif
1.1       cgd       227:
1.74      mycroft   228: .if !target(scriptsinstall)
                    229: scriptsinstall::
1.1       cgd       230: .endif
1.197     lukem     231: .PHONY:                scriptsinstall
1.1       cgd       232:
1.52      cgd       233: lint: ${LOBJS}
                    234: .if defined(LOBJS) && !empty(LOBJS)
1.196     lukem     235:        ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[  ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}
1.1       cgd       236: .endif
                    237:
1.138     tv        238: ##### Pull in related .mk logic
1.1       cgd       239: .include <bsd.man.mk>
1.50      jtc       240: .include <bsd.nls.mk>
1.66      christos  241: .include <bsd.files.mk>
1.63      christos  242: .include <bsd.inc.mk>
1.83      mycroft   243: .include <bsd.links.mk>
1.180     lukem     244: .include <bsd.sys.mk>
1.26      mycroft   245: .include <bsd.dep.mk>
1.88      mycroft   246:
1.138     tv        247: ${TARGETS}:    # ensure existence
1.166     lukem     248:
                    249: .endif # HOSTPROG

CVSweb <webmaster@jp.NetBSD.org>