Skip to content

Commit 04e8f21

Browse files
committed
App: provide the path to the plug-ins
1 parent a984ce1 commit 04e8f21

File tree

5 files changed

+233
-6
lines changed

5 files changed

+233
-6
lines changed

include/App/app.h renamed to include/App/app.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ typedef struct _App App;
2525

2626
typedef struct _AppMessage AppMessage;
2727

28+
29+
/* constants */
30+
# define APP_PATH "@LIBDIR@/App"
31+
2832
#endif /* !LIBAPP_APP_APP_H */

include/App/apptransport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,8 @@ struct _AppTransportPluginDefinition
8484
AppTransportClient * client, AppMessage * message);
8585
};
8686

87+
88+
/* constants */
89+
# define APP_TRANSPORT_PATH APP_PATH "/transport"
90+
8791
#endif /* !LIBAPP_APP_APPTRANSPORT_H */

include/App/project.conf

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
includes=app.h,appclient.h,appmessage.h,appserver.h,appstatus.h,apptransport.h
2-
dist=Makefile
3-
4-
[app.h]
5-
install=$(INCLUDEDIR)/System/App
1+
includes=appclient.h,appmessage.h,appserver.h,appstatus.h,apptransport.h
2+
targets=app.h
3+
dist=Makefile,app.h.in
64

5+
#includes
76
[appclient.h]
87
install=$(INCLUDEDIR)/System/App
98

@@ -18,3 +17,10 @@ install=$(INCLUDEDIR)/System/App
1817

1918
[apptransport.h]
2019
install=$(INCLUDEDIR)/System/App
20+
21+
#targets
22+
[app.h]
23+
type=script
24+
script=../../tools/subst.sh
25+
install=$(INCLUDEDIR)/System/App
26+
depends=app.h.in,../../config.sh

tools/project.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cflags_force=`pkg-config --cflags libSystem libMarshall`
55
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
66
ldflags_force=-L$(OBJDIR)../src `pkg-config --libs libSystem libMarshall` -lApp
77
ldflags=-pie -Wl,-z,relro -Wl,-z,now
8-
dist=Makefile
8+
dist=Makefile,tools.sh
99

1010
#targets
1111
[AppBroker]

tools/subst.sh

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
#!/bin/sh
2+
#$Id$
3+
#Copyright (c) 2012-2022 Pierre Pronchery <[email protected]>
4+
#
5+
#Redistribution and use in source and binary forms, with or without
6+
#modification, are permitted provided that the following conditions are met:
7+
#
8+
# * Redistributions of source code must retain the above copyright notice, this
9+
# list of conditions and the following disclaimer.
10+
# * Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18+
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20+
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21+
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22+
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
25+
26+
27+
#variables
28+
CONFIGSH="${0%/subst.sh}/../config.sh"
29+
PREFIX="/usr/local"
30+
BINDIR=
31+
DATADIR=
32+
DEVNULL="/dev/null"
33+
INCLUDEDIR=
34+
LDSO=
35+
LIBDIR=
36+
LIBEXECDIR=
37+
MANDIR=
38+
PROGNAME="subst.sh"
39+
SBINDIR=
40+
SYSCONFDIR=
41+
#executables
42+
CHMOD="chmod"
43+
DATE="date"
44+
DEBUG="_debug"
45+
INSTALL="install"
46+
MKDIR="mkdir -m 0755 -p"
47+
RM="rm -f"
48+
SED="sed"
49+
50+
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
51+
52+
53+
#functions
54+
#subst
55+
_subst()
56+
{
57+
#check the variables
58+
if [ -z "$PACKAGE" ]; then
59+
_error "The PACKAGE variable needs to be set"
60+
return $?
61+
fi
62+
if [ -z "$VERSION" ]; then
63+
_error "The VERSION variable needs to be set"
64+
return $?
65+
fi
66+
[ -z "$BINDIR" ] && BINDIR="$PREFIX/bin"
67+
[ -z "$DATADIR" ] && DATADIR="$PREFIX/share"
68+
[ -z "$INCLUDEDIR" ] && INCLUDEDIR="$PREFIX/include"
69+
if [ -z "$LDSO" ]; then
70+
case "$(uname -s)" in
71+
FreeBSD)
72+
LDSO="/libexec/ld-elf.so.1"
73+
;;
74+
Linux)
75+
LDSO="/lib/ld-linux-$(uname -m | tr _ -).so.2"
76+
;;
77+
*)
78+
LDSO="/libexec/ld.elf_so"
79+
;;
80+
esac
81+
fi
82+
[ -z "$LIBDIR" ] && LIBDIR="$PREFIX/lib"
83+
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="$PREFIX/libexec"
84+
[ -z "$MANDIR" ] && MANDIR="$DATADIR/man"
85+
if [ -z "$SYSCONFDIR" ]; then
86+
SYSCONFDIR="$PREFIX/etc"
87+
[ "$PREFIX" = "/usr" ] && SYSCONFDIR="/etc"
88+
fi
89+
[ -z "$SBINDIR" ] && SBINDIR="$PREFIX/sbin"
90+
91+
while [ $# -gt 0 ]; do
92+
target="$1"
93+
shift
94+
95+
#clean
96+
[ "$clean" -ne 0 ] && continue
97+
98+
#uninstall
99+
if [ "$uninstall" -eq 1 ]; then
100+
$DEBUG $RM -- "$PREFIX/$target" || return 2
101+
continue
102+
fi
103+
104+
#install
105+
if [ "$install" -eq 1 ]; then
106+
source="${target#$OBJDIR}"
107+
$DEBUG $MKDIR -- "$PREFIX" || return 2
108+
mode="-m 0644"
109+
[ -x "${source}.in" ] && mode="-m 0755"
110+
$DEBUG $INSTALL $mode "$target" "$PREFIX/$source" \
111+
|| return 2
112+
continue
113+
fi
114+
115+
#create
116+
source="${target#$OBJDIR}"
117+
source="${source}.in"
118+
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") \
119+
|| return 2
120+
$DEBUG $SED -e "s;@VENDOR@;$VENDOR;g" \
121+
-e "s;@PACKAGE@;$PACKAGE;g" \
122+
-e "s;@VERSION@;$VERSION;g" \
123+
-e "s;@PREFIX@;$PREFIX;g" \
124+
-e "s;@BINDIR@;$BINDIR;g" \
125+
-e "s;@DATADIR@;$DATADIR;g" \
126+
-e "s;@DATE@;$DATE;g" \
127+
-e "s;@INCLUDEDIR@;$INCLUDEDIR;g" \
128+
-e "s;@LDSO@;$LDSO;g" \
129+
-e "s;@LIBDIR@;$LIBDIR;g" \
130+
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
131+
-e "s;@MANDIR@;$MANDIR;g" \
132+
-e "s;@PWD@;$PWD;g" \
133+
-e "s;@SBINDIR@;$SBINDIR;g" \
134+
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
135+
-- "$source" > "$target"
136+
if [ $? -ne 0 ]; then
137+
$RM -- "$target" 2> "$DEVNULL"
138+
return 2
139+
elif [ -x "$source" ]; then
140+
$DEBUG $CHMOD -- 0755 "$target"
141+
fi
142+
done
143+
return 0
144+
}
145+
146+
147+
#debug
148+
_debug()
149+
{
150+
echo "$@" 1>&3
151+
"$@"
152+
}
153+
154+
155+
#error
156+
_error()
157+
{
158+
echo "$PROGNAME: $@" 1>&2
159+
return 2
160+
}
161+
162+
163+
#usage
164+
_usage()
165+
{
166+
echo "Usage: $PROGNAME [-c|-i|-u][-P prefix] target..." 1>&2
167+
return 1
168+
}
169+
170+
171+
#main
172+
clean=0
173+
install=0
174+
uninstall=0
175+
while getopts "ciuO:P:" name; do
176+
case $name in
177+
c)
178+
clean=1
179+
;;
180+
i)
181+
uninstall=0
182+
install=1
183+
;;
184+
u)
185+
install=0
186+
uninstall=1
187+
;;
188+
O)
189+
export "${OPTARG%%=*}"="${OPTARG#*=}"
190+
;;
191+
P)
192+
PREFIX="$OPTARG"
193+
;;
194+
?)
195+
_usage
196+
exit $?
197+
;;
198+
esac
199+
done
200+
shift $(($OPTIND - 1))
201+
if [ $# -lt 1 ]; then
202+
_usage
203+
exit $?
204+
fi
205+
206+
if [ -n "$SOURCE_DATE_EPOCH" ]; then
207+
DATE="$($DATE -d "@$SOURCE_DATE_EPOCH" '+%B %d, %Y')"
208+
else
209+
DATE="$($DATE '+%B %d, %Y')"
210+
fi
211+
212+
exec 3>&1
213+
_subst "$@"

0 commit comments

Comments
 (0)