Pullup ticket #2800.
[pkgsrc.git] / mk / oss.builtin.mk
1 # $NetBSD: oss.builtin.mk,v 1.2 2006/04/06 06:23:06 reed Exp $
2
3 BUILTIN_PKG:=   oss
4
5 BUILTIN_FIND_LIBS:=             ossaudio
6 BUILTIN_FIND_FILES_VAR:=        H_SOUNDCARD
7 BUILTIN_FIND_FILES.H_SOUNDCARD= /usr/include/soundcard.h                \
8                                 /usr/include/sys/soundcard.h
9
10 .include "../../mk/buildlink3/bsd.builtin.mk"
11
12 ###
13 ### Determine if there is a built-in implementation of the package and
14 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
15 ###
16 .if !defined(IS_BUILTIN.oss)
17 IS_BUILTIN.oss= no
18 .  if empty(H_SOUNDCARD:M${LOCALBASE}/*) && empty(H_SOUNDCARD:M__nonexistent__)
19 IS_BUILTIN.oss= yes
20 .  endif
21 .endif
22 MAKEVARS+=      IS_BUILTIN.oss
23
24 ###
25 ### Determine whether we should use the built-in implementation if it
26 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
27 ###
28 .if !defined(USE_BUILTIN.oss)
29 # XXX
30 # XXX OSS support must always be native as it's provided by the OS.
31 # XXX
32 PREFER.oss=             native
33 .  if ${PREFER.oss} == "pkgsrc"
34 USE_BUILTIN.oss=        no
35 .  else
36 USE_BUILTIN.oss=        ${IS_BUILTIN.oss}
37 .    if defined(BUILTIN_PKG.oss) && \
38         !empty(IS_BUILTIN.oss:M[yY][eE][sS])
39 USE_BUILTIN.oss=        yes
40 .      for _dep_ in ${BUILDLINK_API_DEPENDS.oss}
41 .        if !empty(USE_BUILTIN.oss:M[yY][eE][sS])
42 USE_BUILTIN.oss!=                                                       \
43         if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.oss:Q}; then    \
44                 ${ECHO} yes;                                            \
45         else                                                            \
46                 ${ECHO} no;                                             \
47         fi
48 .        endif
49 .      endfor
50 .    endif
51 .  endif  # PREFER.oss
52 .endif
53 MAKEVARS+=      USE_BUILTIN.oss
54
55 ###
56 ### The section below only applies if we are not including this file
57 ### solely to determine whether a built-in implementation exists.
58 ###
59 CHECK_BUILTIN.oss?=     no
60 .if !empty(CHECK_BUILTIN.oss:M[nN][oO])
61
62 .  if !empty(USE_BUILTIN.oss:M[yY][eE][sS])
63 BUILDLINK_PREFIX.oss=   /usr
64 .    if !empty(BUILTIN_LIB_FOUND.ossaudio:M[yY][eE][sS])
65 BUILDLINK_LDADD.oss=    -lossaudio
66 .    else
67 BUILDLINK_LDADD.oss=    # empty
68 BUILDLINK_TRANSFORM+=   rm:-lossaudio
69 .    endif
70 .  endif
71
72 # Many OSS-aware programs expect <soundcard.h> to be found as either
73 # <sys/soundcard.h> or <machine/soundcard.h>, so create a dummy version.
74 # Also include <sys/ioctl.h> prior to including <soundcard.h> since we
75 # need definitions for _IOWR and friends.
76 #
77 BUILDLINK_TARGETS+=     buildlink-oss-soundcard-h
78 .PHONY: buildlink-oss-soundcard-h
79 buildlink-oss-soundcard-h:
80         ${RUN}                                                          \
81         sys_soundcard_h=${BUILDLINK_DIR}/include/sys/soundcard.h;       \
82         soundcard_h=${BUILDLINK_PREFIX.oss}/include/soundcard.h;        \
83         if ${TEST} ! -f $${sys_soundcard_h} -a -f $${soundcard_h}; then \
84                 ${ECHO_BUILDLINK_MSG} "Creating $${sys_soundcard_h}.";  \
85                 ${MKDIR} `${DIRNAME} $${sys_soundcard_h}`;              \
86                 ( ${ECHO} "#ifndef BUILDLINK_SYS_SOUNDCARD_H";          \
87                   ${ECHO} "#define BUILDLINK_SYS_SOUNDCARD_H";          \
88                   ${ECHO} "#include <sys/ioctl.h>";                     \
89                   ${ECHO} "#include <soundcard.h>";                     \
90                   ${ECHO} "#endif";                                     \
91                 ) > $${sys_soundcard_h};                                \
92         fi;                                                             \
93         mach_soundcard_h=${BUILDLINK_DIR}/include/machine/soundcard.h;  \
94         if ${TEST} ! -f $${mach_soundcard_h} -a -f $${sys_soundcard_h}; then \
95                 ${ECHO_BUILDLINK_MSG} "Creating $${mach_soundcard_h}."; \
96                 ${MKDIR} `${DIRNAME} $${mach_soundcard_h}`;             \
97                 ${LN} -s $${sys_soundcard_h} $${mach_soundcard_h};      \
98         fi
99
100 .endif  # CHECK_BUILTIN.oss