Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / mk / plist / print-plist.mk
blob3bf5d89e356ab52ea979ca096a3c344d0a6fcfc2
1 # $NetBSD: print-plist.mk,v 1.22 2013/02/20 08:45:05 wiz Exp $
3 ###
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
9 ###
10 ### Usage:
11 ### - make install
12 ### - make print-PLIST | brain >PLIST
13 ###
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}");
24 .endif
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)?$$/)
40 .endif
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/)
44 .endif
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/)
48 .endif
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/)
53 .endif
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
60 .if make(print-PLIST)
61 _PRINT_PLIST_COMMON_DIRS!= ${AWK} 'BEGIN { \
62 i=0; \
63 stack[i]="${PREFIX}" ; \
64 cwd=""; \
65 } \
66 ! ( /^\// || /^\#/ || /^$$/ ) { \
67 if ( $$1 == ".." ){ \
68 i=i-1; \
69 cwd = stack[i]; \
70 } else if ( $$1 == "." ){ \
71 } else { \
72 stack[i] = cwd ; \
73 if ( i == 0 ){ \
74 cwd = $$1 ; \
75 } else { \
76 cwd = cwd "\\/" $$1 ; \
77 } \
78 print "/^" cwd "$$$$/ { next; }"; \
79 i=i+1 ; \
80 } \
81 } \
82 END { print "{ print $$$$0; }"; } \
83 ' <${_COMMON_MTREE_FILE}
84 .endif
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
96 .else
97 _PRINT_PLIST_FILES_CMD= \
98 ${FIND} ${DESTDIR}${PREFIX}/. \! -type d -print
99 _PRINT_PLIST_DIRS_CMD= \
100 ${FIND} ${DESTDIR}${PREFIX}/. -type d -print
101 .endif
103 .if !empty(LIBTOOLIZE_PLIST:M[yY][eE][sS])
104 _PRINT_PLIST_LIBTOOLIZE_FILTER?= \
106 if ${TEST} -d ${WRKDIR}; then \
107 tmpdir="${WRKDIR}"; \
108 else \
109 tmpdir="$${TMPDIR-/tmp}"; \
110 fi; \
111 fileslist="$$tmpdir/print.plist.files.$$$$"; \
112 libslist="$$tmpdir/print.plist.libs.$$$$"; \
113 while read file; do \
114 case $$file in \
115 *.la) \
116 ${_LIBTOOL_EXPAND} $$file >> $$libslist; \
117 ;; \
118 esac; \
119 ${ECHO} "$$file"; \
120 done > $$fileslist; \
121 if ${TEST} -f "$$libslist"; then \
122 ${GREP} -hvxF "`${SORT} -u $$libslist`" "$$fileslist"; \
123 else \
124 ${CAT} "$$fileslist"; \
125 fi; \
126 ${RM} -f "$$fileslist" "$$libslist"; \
128 .else
129 _PRINT_PLIST_LIBTOOLIZE_FILTER?= ${CAT}
130 .endif
132 .PHONY: print-PLIST
133 .if !target(print-PLIST)
134 print-PLIST:
135 ${RUN} ${ECHO} '@comment $$'NetBSD'$$'
136 ${RUN}\
137 shlib_type=${SHLIB_TYPE:Q}; \
138 case $$shlib_type in \
139 "a.out") genlinks=1 ;; \
140 *) genlinks=0 ;; \
141 esac; \
142 ${_PRINT_PLIST_FILES_CMD} \
143 | ${_PRINT_PLIST_LIBTOOLIZE_FILTER} \
144 | ${SORT} \
145 | ${AWK} ' \
146 { sub("${DESTDIR:S|+|\\\\+|g}${PREFIX}/\\./", ""); } \
147 ${_PRINT_PLIST_AWK_IGNORE} { next; } \
148 ${PRINT_PLIST_AWK} \
149 ${_PRINT_PLIST_AWK_SUBST} \
150 /^@/ { print $$0; next } \
151 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \
152 print $$0; \
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; \
159 next; \
161 /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \
162 print $$0; \
163 sub("\\.[0-9]+$$", ""); \
164 if ('$$genlinks') print $$0; \
165 sub("\\.[0-9]+$$", ""); \
166 if ('$$genlinks') print $$0; \
167 next; \
169 { print $$0; }'
170 ${RUN}\
171 for i in `${_PRINT_PLIST_DIRS_CMD} \
172 | ${SORT} -r \
173 | ${AWK} ' \
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}'` ; \
184 do \
185 if [ `${LS} -la ${DESTDIR}${PREFIX}/$$i | ${WC} -l` = 3 ]; then \
186 ${ECHO} @pkgdir $$i | ${AWK} ' \
187 ${PRINT_PLIST_AWK} \
188 { print $$0; }' ; \
189 fi ; \
190 done \
191 | ${AWK} '${_PRINT_PLIST_AWK_SUBST} { print $$0; }'
192 .endif # target(print-PLIST)