Home | History | Annotate | Line # | Download | only in mk
bsd.lib.mk revision 1.84
      1  1.84     perry #	$NetBSD: bsd.lib.mk,v 1.84 1997/03/13 02:46:00 perry Exp $
      2  1.50       cgd #	@(#)bsd.lib.mk	5.26 (Berkeley) 5/2/91
      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.54       cgd 
      8  1.54       cgd .include <bsd.own.mk>				# for 'NOPIC' definition
      9   1.1       cgd 
     10  1.35        pk .if exists(${.CURDIR}/shlib_version)
     11  1.37       cgd SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
     12  1.37       cgd SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
     13  1.35        pk .endif
     14  1.35        pk 
     15   1.1       cgd .MAIN: all
     16   1.1       cgd 
     17  1.58       cgd # prefer .S to a .c, add .po, remove stuff not used in the BSD libraries.
     18  1.58       cgd # .so used for PIC object files.  .ln used for lint output files.
     19   1.1       cgd .SUFFIXES:
     20  1.58       cgd .SUFFIXES: .out .o .po .so .S .s .c .cc .C .f .y .l .ln .m4
     21  1.82     mikel 
     22  1.82     mikel CFLAGS+=	${COPTS}
     23   1.1       cgd 
     24   1.1       cgd .c.o:
     25  1.80  christos 	@echo ${COMPILE.c:Q} ${.IMPSRC}
     26  1.62  christos 	@${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
     27  1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     28  1.62  christos 	@rm -f ${.TARGET}.o
     29   1.1       cgd 
     30   1.1       cgd .c.po:
     31  1.80  christos 	@echo ${COMPILE.c:Q} -pg ${.IMPSRC} -o ${.TARGET}
     32  1.68       cgd 	@${COMPILE.c} -pg ${.IMPSRC} -o ${.TARGET}.o
     33  1.62  christos 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
     34  1.62  christos 	@rm -f ${.TARGET}.o
     35  1.17   mycroft 
     36  1.27        pk .c.so:
     37  1.80  christos 	@echo ${COMPILE.c:Q} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}
     38  1.62  christos 	@${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
     39  1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     40  1.62  christos 	@rm -f ${.TARGET}.o
     41  1.27        pk 
     42  1.58       cgd .c.ln:
     43  1.58       cgd 	${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
     44  1.58       cgd 
     45  1.18   mycroft .cc.o .C.o:
     46  1.80  christos 	@echo ${COMPILE.cc:Q} ${.IMPSRC}
     47  1.62  christos 	@${COMPILE.cc} ${.IMPSRC} -o ${.TARGET}.o
     48  1.63       jtc 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     49  1.62  christos 	@rm -f ${.TARGET}.o
     50  1.17   mycroft 
     51  1.18   mycroft .cc.po .C.po:
     52  1.80  christos 	@echo ${COMPILE.cc:Q} -pg ${.IMPSRC} -o ${.TARGET}
     53  1.68       cgd 	@${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}.o
     54  1.62  christos 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
     55  1.62  christos 	@rm -f ${.TARGET}.o
     56  1.28       cgd 
     57  1.28       cgd .cc.so .C.so:
     58  1.80  christos 	@echo ${COMPILE.cc:Q} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}
     59  1.62  christos 	@${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
     60  1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     61  1.62  christos 	@rm -f ${.TARGET}.o
     62   1.1       cgd 
     63  1.40       cgd .S.o .s.o:
     64  1.80  christos 	@echo ${COMPILE.S:Q} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
     65  1.69       jtc 	@${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
     66  1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     67  1.62  christos 	@rm -f ${.TARGET}.o
     68   1.1       cgd 
     69  1.40       cgd .S.po .s.po:
     70  1.80  christos 	@echo ${COMPILE.S:Q} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
     71  1.75       jtc 	@${COMPILE.S} -DGPROF -DPROF ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
     72  1.62  christos 	@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
     73  1.62  christos 	@rm -f ${.TARGET}.o
     74   1.1       cgd 
     75  1.40       cgd .S.so .s.so:
     76  1.80  christos 	@echo ${COMPILE.S:Q} ${PICFLAG} -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
     77  1.70       jtc 	@${COMPILE.S} ${PICFLAG} -DPIC ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
     78  1.62  christos 	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
     79  1.62  christos 	@rm -f ${.TARGET}.o
     80  1.27        pk 
     81  1.58       cgd .if !defined(PICFLAG)
     82  1.58       cgd PICFLAG=-fpic
     83  1.58       cgd .endif
     84  1.58       cgd 
     85   1.1       cgd .if !defined(NOPROFILE)
     86   1.1       cgd _LIBS=lib${LIB}.a lib${LIB}_p.a
     87   1.1       cgd .else
     88   1.1       cgd _LIBS=lib${LIB}.a
     89   1.1       cgd .endif
     90   1.1       cgd 
     91  1.27        pk .if !defined(NOPIC)
     92  1.27        pk _LIBS+=lib${LIB}_pic.a
     93  1.37       cgd .if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
     94  1.37       cgd _LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
     95  1.27        pk .endif
     96  1.35        pk .endif
     97  1.27        pk 
     98  1.58       cgd .if !defined(NOLINT)
     99  1.58       cgd _LIBS+=llib-l${LIB}.ln
    100  1.27        pk .endif
    101  1.27        pk 
    102  1.58       cgd all: ${_LIBS} _SUBDIRUSE
    103   1.1       cgd 
    104  1.21   mycroft OBJS+=	${SRCS:N*.h:R:S/$/.o/g}
    105   1.1       cgd 
    106   1.1       cgd lib${LIB}.a:: ${OBJS}
    107   1.1       cgd 	@echo building standard ${LIB} library
    108   1.1       cgd 	@rm -f lib${LIB}.a
    109  1.67   mycroft 	@${AR} cq lib${LIB}.a `lorder ${OBJS} | tsort -q`
    110  1.13       cgd 	${RANLIB} lib${LIB}.a
    111   1.1       cgd 
    112   1.1       cgd POBJS+=	${OBJS:.o=.po}
    113   1.1       cgd lib${LIB}_p.a:: ${POBJS}
    114   1.1       cgd 	@echo building profiled ${LIB} library
    115   1.1       cgd 	@rm -f lib${LIB}_p.a
    116  1.67   mycroft 	@${AR} cq lib${LIB}_p.a `lorder ${POBJS} | tsort -q`
    117  1.13       cgd 	${RANLIB} lib${LIB}_p.a
    118   1.1       cgd 
    119  1.27        pk SOBJS+=	${OBJS:.o=.so}
    120  1.27        pk lib${LIB}_pic.a:: ${SOBJS}
    121  1.27        pk 	@echo building shared object ${LIB} library
    122  1.27        pk 	@rm -f lib${LIB}_pic.a
    123  1.67   mycroft 	@${AR} cq lib${LIB}_pic.a `lorder ${SOBJS} | tsort -q`
    124  1.27        pk 	${RANLIB} lib${LIB}_pic.a
    125  1.27        pk 
    126  1.42   mycroft lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD}
    127  1.38       cgd 	@echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
    128  1.37       cgd 	@rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
    129  1.72       cgd .if (${MACHINE_ARCH} != "alpha")
    130  1.53        pk 	$(LD) -x -Bshareable -Bforcearchive \
    131  1.42   mycroft 	    -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} lib${LIB}_pic.a ${LDADD}
    132  1.72       cgd .else
    133  1.77       cgd 	$(LD) -shared -o lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
    134  1.83       cgd 	    -soname lib${LIB}.so.${SHLIB_MAJOR} /usr/lib/crtbeginS.o \
    135  1.77       cgd 	    --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
    136  1.83       cgd 	    /usr/lib/crtendS.o
    137  1.72       cgd .endif
    138  1.35        pk 
    139  1.58       cgd LOBJS+=	${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
    140  1.58       cgd LLIBS?=	-lc
    141  1.58       cgd llib-l${LIB}.ln: ${LOBJS}
    142  1.58       cgd 	@echo building llib-l${LIB}.ln
    143  1.58       cgd 	@rm -f llib-l${LIB}.ln
    144  1.58       cgd 	@${LINT} -C${LIB} ${LOBJS} ${LLIBS}
    145   1.1       cgd 
    146   1.1       cgd .if !target(clean)
    147  1.81       cgd cleanlib:
    148  1.48   mycroft 	rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
    149  1.59       cgd 	rm -f lib${LIB}.a ${OBJS}
    150  1.59       cgd 	rm -f lib${LIB}_p.a ${POBJS}
    151  1.61       cgd 	rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
    152  1.59       cgd 	rm -f llib-l${LIB}.ln ${LOBJS}
    153   1.1       cgd 
    154  1.81       cgd clean: _SUBDIRUSE cleanlib
    155  1.81       cgd cleandir: _SUBDIRUSE cleanlib
    156  1.81       cgd .else
    157  1.49       cgd cleandir: _SUBDIRUSE clean
    158  1.81       cgd .endif
    159  1.25   mycroft 
    160  1.26   mycroft .if defined(SRCS)
    161  1.64  christos afterdepend: .depend
    162   1.1       cgd 	@(TMP=/tmp/_depend$$$$; \
    163  1.79       cgd 	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
    164  1.58       cgd 	      < .depend > $$TMP; \
    165   1.1       cgd 	    mv $$TMP .depend)
    166  1.26   mycroft .endif
    167   1.1       cgd 
    168   1.1       cgd .if !target(install)
    169   1.1       cgd .if !target(beforeinstall)
    170   1.1       cgd beforeinstall:
    171   1.1       cgd .endif
    172   1.1       cgd 
    173  1.11   mycroft realinstall:
    174  1.13       cgd #	ranlib lib${LIB}.a
    175  1.73   thorpej 	${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
    176   1.1       cgd 	    ${DESTDIR}${LIBDIR}
    177   1.1       cgd 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
    178  1.56       cgd 	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
    179  1.12       cgd .if !defined(NOPROFILE)
    180  1.13       cgd #	ranlib lib${LIB}_p.a
    181  1.73   thorpej 	${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
    182   1.1       cgd 	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
    183   1.1       cgd 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    184  1.56       cgd 	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
    185  1.32        pk .endif
    186  1.39        pk .if !defined(NOPIC)
    187  1.32        pk #	ranlib lib${LIB}_pic.a
    188  1.73   thorpej 	${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
    189  1.32        pk 	    lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
    190  1.32        pk 	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    191  1.56       cgd 	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
    192  1.33        pk .endif
    193  1.37       cgd .if !defined(NOPIC) && defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
    194  1.73   thorpej 	${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    195  1.37       cgd 	    lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} ${DESTDIR}${LIBDIR}
    196  1.83       cgd .if (${MACHINE_ARCH} == "alpha")
    197  1.83       cgd 	rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
    198  1.83       cgd 	ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
    199  1.83       cgd 	    ${DESTDIR}${LIBDIR}/lib${LIB}.so.${SHLIB_MAJOR}
    200  1.83       cgd 	rm -f ${DESTDIR}${LIBDIR}/lib${LIB}.so
    201  1.83       cgd 	ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
    202  1.83       cgd 	    ${DESTDIR}${LIBDIR}/lib${LIB}.so
    203  1.83       cgd .endif
    204  1.12       cgd .endif
    205  1.58       cgd .if !defined(NOLINT)
    206  1.73   thorpej 	${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
    207  1.58       cgd 	    llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
    208  1.58       cgd .endif
    209   1.1       cgd .if defined(LINKS) && !empty(LINKS)
    210   1.1       cgd 	@set ${LINKS}; \
    211   1.1       cgd 	while test $$# -ge 2; do \
    212   1.1       cgd 		l=${DESTDIR}$$1; \
    213   1.1       cgd 		shift; \
    214   1.1       cgd 		t=${DESTDIR}$$1; \
    215   1.1       cgd 		shift; \
    216   1.1       cgd 		echo $$t -\> $$l; \
    217   1.1       cgd 		rm -f $$t; \
    218   1.1       cgd 		ln $$l $$t; \
    219  1.84     perry 	done; true
    220  1.84     perry .endif
    221  1.84     perry .if defined(SYMLINKS) && !empty(SYMLINKS)
    222  1.84     perry 	@set ${SYMLINKS}; \
    223  1.84     perry 	while test $$# -ge 2; do \
    224  1.84     perry 		l=${DESTDIR}$$1; \
    225  1.84     perry 		shift; \
    226  1.84     perry 		t=${DESTDIR}$$1; \
    227  1.84     perry 		shift; \
    228  1.84     perry 		echo $$t -\> $$l; \
    229  1.84     perry 		rm -f $$t; \
    230  1.84     perry 		ln -s $$l $$t; \
    231   1.1       cgd 	done; true
    232   1.1       cgd .endif
    233   1.1       cgd 
    234  1.49       cgd install: maninstall _SUBDIRUSE
    235  1.11   mycroft maninstall: afterinstall
    236  1.11   mycroft afterinstall: realinstall
    237  1.11   mycroft realinstall: beforeinstall
    238   1.1       cgd .endif
    239   1.1       cgd 
    240  1.10   mycroft .if !defined(NOMAN)
    241   1.1       cgd .include <bsd.man.mk>
    242  1.57       jtc .endif
    243  1.57       jtc 
    244  1.57       jtc .if !defined(NONLS)
    245  1.57       jtc .include <bsd.nls.mk>
    246  1.10   mycroft .endif
    247  1.10   mycroft 
    248  1.22   mycroft .include <bsd.obj.mk>
    249  1.24   mycroft .include <bsd.dep.mk>
    250  1.49       cgd .include <bsd.subdir.mk>
    251  1.66  christos .include <bsd.sys.mk>
    252