Merge branch 'vendor/BMAKE'
[dragonfly.git] / gnu / usr.bin / cc80 / Makefile.intcxx_lib
1 # This does the same job as bsd.hostlib.mk except .c files are bult with c++
2 # and it does not contain "afterdepend: all" which forces everything to be
3 # built under the "depend" target
4
5 .include <bsd.init.mk>
6
7 .SUFFIXES:
8 .SUFFIXES: .out .no .c .cc .cpp .cxx .C .y .l
9
10 .c.no .cc.no .C.no .cpp.no .cxx.no:
11         ${NXCXX} ${_${.IMPSRC}_FLAGS} ${NXCXXFLAGS:N-std=*:N-flto} -c ${.IMPSRC} -o ${.TARGET}
12         @${NXLD} -o ${.TARGET}.tmp -x -r ${.TARGET}
13         @mv ${.TARGET}.tmp ${.TARGET}
14
15 all: objwarn
16
17 .if defined(LIB) && !empty(LIB) && !empty(SRCS)
18 OBJS+=  ${SRCS:N*.h:R:S/$/.no/g}
19 .endif
20
21 .if defined(LIB) && !empty(LIB)
22 _LIBS=          lib${LIB}.na
23
24 lib${LIB}.na: ${OBJS} ${STATICOBJS}
25         @${ECHO} building native static ${LIB} library
26         rm -f ${.TARGET}
27         ${NXAR} ${ARFLAGS} ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
28         ${NXRANLIB} ${.TARGET}
29 .endif
30
31 all: ${_LIBS}
32
33 ##
34 #  HEAD: embedded equivalent bsd.dep.mk
35 ##
36
37 CTAGS?=         gtags
38 MKDEPCMD?=      CC=c++ mkdep
39 DEPENDFILE?=    .depend
40 GTAGSFLAGS?=    -o
41 CTAGSFLAGS?=
42 HTAGSFLAGS?=
43
44 .if !target(tags) && defined(SRCS) && !defined(NOTAGS)
45 tags: ${SRCS}
46 . if ${CTAGS:T} == "ctags"
47         @${CTAGS} ${CTAGSFLAGS} -f /dev/stdout \
48             ${.ALLSRC:N*.h} | sed "s;${.CURDIR}/;;" > ${.TARGET}
49 . elif ${CTAGS:T} == "gtags"
50         @cd ${.CURDIR} && ${CTAGS} ${GTAGSFLAGS} ${.OBJDIR}
51 .  if defined(HTML)
52         @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
53 .  endif
54 . endif
55 .endif
56
57 .if defined(SRCS)
58
59 CLEANFILES?=
60
61 . for _LSRC in ${SRCS:M*.l:N*/*}
62 .  for _LC in ${_LSRC:R}.c
63 ${_LC}: ${_LSRC}
64         ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET}
65 SRCS:=  ${SRCS:S/${_LSRC}/${_LC}/}
66 CLEANFILES+= ${_LC}
67 .  endfor
68 . endfor
69
70 . for _YSRC in ${SRCS:M*.y:N*/*}
71 .  for _YC in ${_YSRC:R}.c
72 SRCS:=  ${SRCS:S/${_YSRC}/${_YC}/}
73 CLEANFILES+= ${_YC}
74 .   if !empty(YFLAGS:M-d) && !empty(SRCS:My.tab.h)
75 .ORDER: ${_YC} y.tab.h
76 ${_YC} y.tab.h: ${_YSRC}
77         ${YACC} ${YFLAGS} ${.ALLSRC}
78         cp y.tab.c ${_YC}
79 CLEANFILES+= y.tab.c y.tab.h
80 .   elif !empty(YFLAGS:M-d)
81 .     for _YH in ${_YC:S/.c/.h/}
82 ${_YH}: ${_YC}
83 ${_YC}: ${_YSRC}
84         ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
85 SRCS+= ${_YH}
86 CLEANFILES+= ${_YH}
87 .     endfor
88 .   else
89 ${_YC}: ${_YSRC}
90         ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
91 .   endif
92 .  endfor
93 . endfor
94 .endif
95
96 .if !target(depend)
97 . if defined(SRCS)
98 depend: beforedepend _dependincs ${DEPENDFILE} afterdepend
99
100 .NOPATH: ${DEPENDFILE}
101
102 __FLAGS=
103 __FLAGS_FILES=  ${SRCS}
104 .  for _FG in ${FLAGS_GROUPS}
105 .   for _FFILE in ${${_FG}_FLAGS_FILES}
106 __FLAGS_FILES:= ${__FLAGS_FILES:N${_FFILE}}
107 .   endfor
108 .  endfor
109
110 _DEPENDFILES=   ${FLAGS_GROUPS:S/^/.depend_/g}
111
112 ${DEPENDFILE}: ${_DEPENDFILES}
113
114 _ALL_DEPENDS=${__FLAGS_FILES:N*.[sS]:N*.c:N*.cc:N*.C:N*.cpp:N*.cpp:N*.cxx:N*.m}
115
116 .  for _FG in _ ${FLAGS_GROUPS}
117 .depend${_FG:S/^/_/:N__}: ${${_FG}_FLAGS_FILES} ${_ALL_DEPENDS}
118         -rm -f ${.TARGET}
119         -> ${.TARGET}
120 .   if ${${_FG}_FLAGS_FILES:M*.[sS]} != ""
121         ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
122             ${${_FG}_FLAGS} \
123             ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
124             ${CFLAGS:M-std=*} \
125             ${.ALLSRC:M*.[sS]}
126 .   endif
127 .   if ${${_FG}_FLAGS_FILES:M*.cc} != "" || \
128     ${${_FG}_FLAGS_FILES:M*.C} != "" || \
129     ${${_FG}_FLAGS_FILES:M*.c} != "" || \
130     ${${_FG}_FLAGS_FILES:M*.cpp} != "" || \
131     ${${_FG}_FLAGS_FILES:M*.cxx} != ""
132         ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
133             ${${_FG}_FLAGS} \
134             ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
135             ${.ALLSRC:M*.c} \
136             ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
137 .   endif
138 .   if ${${_FG}_FLAGS_FILES:M*.m} != ""
139         ${MKDEPCMD} -f ${.TARGET} -a ${MKDEP} \
140             ${${_FG}_FLAGS} \
141             ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
142             ${OBJCFLAGS:M-Wno-import*} \
143             ${.ALLSRC:M*.m}
144 .   endif
145 .   if !empty(${_FG:M_}) && !empty(_DEPENDFILES)
146         cat ${_DEPENDFILES} >> ${.TARGET}
147 .   endif
148 .  endfor
149
150 .  if target(_EXTRADEPEND)
151 _EXTRADEPEND: .USE
152 ${DEPENDFILE}: _EXTRADEPEND
153 .  endif
154
155 . else
156 depend: beforedepend _dependincs afterdepend
157 . endif
158 . if !target(beforedepend)
159 beforedepend:
160 . endif
161 . if !target(afterdepend)
162 afterdepend:
163 . endif
164 .endif
165
166 .if !target(cleandepend)
167 cleandepend:
168 . if defined(SRCS)
169 .  if ${CTAGS:T} == "ctags"
170         rm -f ${DEPENDFILE} ${_DEPENDFILES} tags
171 .  elif ${CTAGS:T} == "gtags"
172         rm -f ${DEPENDFILE} ${_DEPENDFILES} GPATH GRTAGS GSYMS GTAGS
173 .   if defined(HTML)
174         rm -rf HTML
175 .   endif
176 .  endif
177 . endif
178 .endif
179
180 .if !target(checkdpadd) && (defined(DPADD) || defined(LDADD))
181 checkdpadd:
182         @ldadd=`echo \`for lib in ${DPADD} ; do \
183                 echo $$lib | sed 's;^/usr/lib/lib\(.*\)\.a;-l\1;' ; \
184         done \`` ; \
185         ldadd1=`echo ${LDADD}` ; \
186         if [ "$$ldadd" != "$$ldadd1" ] ; then \
187                 echo ${.CURDIR} ; \
188                 echo "DPADD -> $$ldadd" ; \
189                 echo "LDADD -> $$ldadd1" ; \
190         fi
191 .endif
192
193 .if defined(INCS) && make(depend)
194 _dependincs: buildincludes .WAIT installincludes
195 .else
196 _dependincs:
197 .endif
198
199 .ORDER: beforedepend _dependincs ${DEPENDFILE} afterdepend
200
201 ##
202 #  TAIL: embedded equivalent bsd.dep.mk
203 ##
204
205 .if !exists(${.OBJDIR}/${DEPENDFILE})
206 . if defined(LIB) && !empty(LIB)
207 ${OBJS} ${STATICOBJS}: ${SRCS:M*.h}
208 . endif
209 .endif
210
211 .if !target(clean)
212 clean:
213 . if defined(CLEANFILES) && !empty(CLEANFILES)
214         rm -f ${CLEANFILES}
215 . endif
216 . if defined(LIB) && !empty(LIB)
217         rm -f a.out ${OBJS} ${OBJS:S/$/.tmp/} ${STATICOBJS}
218 . endif
219 . if defined(_LIBS) && !empty(_LIBS)
220         rm -f ${_LIBS}
221 . endif
222 . if defined(CLEANDIRS) && !empty(CLEANDIRS)
223         rm -rf ${CLEANDIRS}
224 . endif
225 .endif
226
227 .include <bsd.obj.mk>
228 .include <bsd.sys.mk>