1 # $NetBSD: print-plist.mk,v 1.22 2013/02/20 08:45:05 wiz Exp $
4 ### Automatic PLIST generation
5 ### - files & symlinks first
6 ### - empty directories are handled properly
7 ### - dirs from mtree files are excluded
8 ### - substitute for platform or package specifics substrings
12 ### - make print-PLIST | brain >PLIST
15 _PRINT_PLIST_AWK_SUBST
={
16 .if
!defined
(EMUL_PLATFORMS
)
17 _PRINT_PLIST_AWK_SUBST
+= \
18 gsub
(/${OS_VERSION
:S
/.
/\.
/g
}/, "$${OS_VERSION}"); \
19 gsub
(/${MACHINE_GNU_PLATFORM}/, "$${MACHINE_GNU_PLATFORM}"); \
20 gsub
(/${MACHINE_ARCH}/, "$${MACHINE_ARCH}"); \
21 gsub
(/${MACHINE_GNU_ARCH}/, "$${MACHINE_GNU_ARCH}");
22 _PRINT_PLIST_AWK_SUBST
+= \
23 gsub
(/${LOWER_OS_VERSION
:S
/.
/\.
/g
}/, "$${LOWER_OS_VERSION}");
25 _PRINT_PLIST_AWK_SUBST
+= \
26 gsub
(/${PKGNAME_NOREV}/, "$${PKGNAME}"); \
27 gsub
(/${PKGVERSION
:S
/.
/\.
/g
:C
/nb
[0-9]*$$//}/, "$${PKGVERSION}");\
28 gsub
(/^
${PKGLOCALEDIR}\
/locale
/, "share/locale"); \
29 gsub
("^${PKGGNUDIR}", "gnu/"); \
30 gsub
("^${PKGINFODIR}/", "info/"); \
31 gsub
("^${PKGMANDIR}/", "man/");
32 _PRINT_PLIST_AWK_SUBST
+=}
34 _PRINT_PLIST_AWK_IGNORE
= ($$0 ~
/^
${PKG_DBDIR
:S|^
${PREFIX}/||
:S|
/|
\\/|g
}\
//)
35 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/emul\
/linux\
/proc
/)
36 .if defined
(INFO_FILES
)
37 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/^
${PKGINFODIR
:S|
/|
\\/|g
}\
/dir$$/)
38 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/^
${PKGINFODIR
:S|
/|
\\/|g
}\
/[^\
/]+(-[0-9]+)(\.gz
)?
$$/)
39 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/^
([^\
/]*\
/)*(info\
/[^\
/]+|
[^\
/]+\.
info)(-[0-9]+)(\.gz
)?
$$/)
41 .if
(defined
(FONTS_DIRS.x11
) && !empty
(FONTS_DIRS.x11
:M
*))
42 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/^.
*\
/encodings\.
dir/)
43 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/^.
*\
/fonts\.
dir/)
45 .if
(defined
(FONTS_DIRS.ttf
) && !empty
(FONTS_DIRS.ttf
:M
*)) || \
46 (defined
(FONTS_DIRS.type1
) && !empty
(FONTS_DIRS.type1
:M
*))
47 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/^.
*\
/fonts\.scale
/)
49 .if
(defined
(FONTS_DIRS.ttf
) && !empty
(FONTS_DIRS.ttf
:M
*)) || \
50 (defined
(FONTS_DIRS.type1
) && !empty
(FONTS_DIRS.type1
:M
*)) || \
51 (defined
(FONTS_DIRS.x11
) && !empty
(FONTS_DIRS.x11
:M
*))
52 _PRINT_PLIST_AWK_IGNORE
+= ||
($$0 ~
/^.
*\
/fonts\.cache-1
/)
55 # Common (system) directories not to generate @dirrm statements for
56 # Reads _MTREE_FILE and generate awk statements that will
57 # sort out which directories NOT to include into the PLIST @dirrm list
58 _COMMON_MTREE_FILE
= ${PKGSRCDIR}/mk
/plist
/common-dirs.mtree
61 _PRINT_PLIST_COMMON_DIRS
!= ${AWK} 'BEGIN { \
63 stack[i]="${PREFIX}" ; \
66 ! ( /^\// || /^\#/ || /^$$/ ) { \
70 } else if ( $$1 == "." ){ \
76 cwd = cwd "\\/" $$1 ; \
78 print "/^" cwd "$$$$/ { next; }"; \
82 END { print "{ print $$$$0; }"; } \
83 ' <${_COMMON_MTREE_FILE}
86 # scan $PREFIX for any files/dirs modified since the package was extracted
87 # will emit "@exec mkdir"-statements for empty directories
88 # XXX will fail for data files that were copied using tar (e.g. emacs)!
89 # XXX should check $LOCALBASE and $X11BASE, and add @cwd statements
91 .if
${_USE_DESTDIR} == "no"
92 _PRINT_PLIST_FILES_CMD
= \
93 ${FIND} ${DESTDIR}${PREFIX}/.
-xdev
-newer
${_COOKIE.extract
} \
! -type d
-print
94 _PRINT_PLIST_DIRS_CMD
= \
95 ${FIND} ${DESTDIR}${PREFIX}/.
-xdev
-newer
${_COOKIE.extract
} -type d
-print
97 _PRINT_PLIST_FILES_CMD
= \
98 ${FIND} ${DESTDIR}${PREFIX}/. \
! -type d
-print
99 _PRINT_PLIST_DIRS_CMD
= \
100 ${FIND} ${DESTDIR}${PREFIX}/.
-type d
-print
103 .if
!empty
(LIBTOOLIZE_PLIST
:M
[yY
][eE
][sS
])
104 _PRINT_PLIST_LIBTOOLIZE_FILTER?
= \
106 if
${TEST} -d
${WRKDIR}; then \
107 tmpdir
="${WRKDIR}"; \
109 tmpdir
="$${TMPDIR-/tmp}"; \
111 fileslist
="$$tmpdir/print.plist.files.$$$$"; \
112 libslist
="$$tmpdir/print.plist.libs.$$$$"; \
113 while read file
; do \
116 ${_LIBTOOL_EXPAND} $$file >> $$libslist; \
120 done
> $$fileslist; \
121 if
${TEST} -f
"$$libslist"; then \
122 ${GREP} -hvxF
"`${SORT} -u $$libslist`" "$$fileslist"; \
124 ${CAT} "$$fileslist"; \
126 ${RM} -f
"$$fileslist" "$$libslist"; \
129 _PRINT_PLIST_LIBTOOLIZE_FILTER?
= ${CAT}
133 .if
!target
(print-PLIST
)
135 ${RUN} ${ECHO} '@comment $$'NetBSD
'$$'
137 shlib_type
=${SHLIB_TYPE
:Q
}; \
138 case
$$shlib_type in \
139 "a.out") genlinks
=1 ;; \
142 ${_PRINT_PLIST_FILES_CMD} \
143 |
${_PRINT_PLIST_LIBTOOLIZE_FILTER} \
146 { sub("${DESTDIR:S|+|\\\\+|g}${PREFIX}/\\./", ""); } \
147 ${_PRINT_PLIST_AWK_IGNORE} { next; } \
149 ${_PRINT_PLIST_AWK_SUBST} \
150 /^@/ { print $$0; next } \
151 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \
153 sub("\\.[0-9]+$$", ""); \
154 if ('$$genlinks') print $$0; \
155 sub("\\.[0-9]+$$", ""); \
156 if ('$$genlinks') print $$0; \
157 sub("\\.[0-9]+$$", ""); \
158 if ('$$genlinks') print $$0; \
161 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \
163 sub("\\.[0-9]+$$", ""); \
164 if ('$$genlinks') print $$0; \
165 sub("\\.[0-9]+$$", ""); \
166 if ('$$genlinks') print $$0; \
171 for i in
`${_PRINT_PLIST_DIRS_CMD} \
174 /emul\/linux\/proc/ { next; } \
175 /${DESTDIR:S|/|\\/|g:S/+/\\\\+/g}${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \
176 /${PKG_DBDIR:S|/|\\/|g}\// { next; } \
177 { sub("${DESTDIR:S/+/\\\\\\+/g}${PREFIX}/\\\\./", ""); } \
178 { sub("^${PKGGNUDIR}", "gnu/"); } \
179 { sub("^${PKGINFODIR}/", "info/"); } \
180 { sub("^${PKGMANDIR}/", "man/"); } \
181 /^${PKG_DBDIR:S|^${PREFIX}/||:S|/|\\/|g}(\/|$$)/ { next; } \
182 /^${PKGINFODIR:S|/|\\/|g}$$/ { next; } \
183 ${_PRINT_PLIST_COMMON_DIRS}'` ; \
185 if
[ `${LS} -la ${DESTDIR}${PREFIX}/$$i | ${WC} -l` = 3 ]; then \
186 ${ECHO} @pkgdir
$$i |
${AWK} ' \
191 |
${AWK} '${_PRINT_PLIST_AWK_SUBST} { print $$0; }'
192 .
endif # target(print-PLIST)