summaryrefslogtreecommitdiffhomepage
path: root/auto/modules/skel
blob: 386b61fadcc1337387fcc8fb03081d3e3792ad56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright (C) NGINX, Inc.


shift

if [ ! -f $NXT_AUTOCONF_DATA ]; then
    echo
    echo Please run common $0 before configuring module \"$nxt_module\".
    echo
    exit 1
fi

. $NXT_AUTOCONF_DATA

$echo "configuring SKEL module"
$echo "configuring SKEL module ..." >> $NXT_AUTOCONF_ERR

NXT_SKEL=skel
NXT_SKEL_MODULE=${NXT_SKEL_MODULE=${NXT_SKEL##*/}}

NXT_SKEL_LDFLAGS=
NXT_SKEL_ADDITIONAL_FLAGS=

if grep ^$NXT_SKEL_MODULE: $NXT_MAKEFILE 2>&1 > /dev/null; then
    $echo
    $echo $0: error: duplicate \"$NXT_SKEL_MODULE\" module configured.
    $echo
    exit 1;
fi

$echo " + SKEL module: ${NXT_SKEL_MODULE}.unit.so"

. auto/cc/deps

$echo >> $NXT_MAKEFILE

NXT_SKEL_MODULE_SRCS=" \
    src/skel/nxt_skel.c \
"

# The skel module object files.

nxt_objs=$NXT_BUILD_DIR/src/nxt_unit.o

for nxt_src in $NXT_SKEL_MODULE_SRCS; do

    nxt_obj=${nxt_src%.c}-$NXT_SKEL_MODULE.o
    nxt_dep=${nxt_src%.c}-$NXT_SKEL_MODULE.dep
    nxt_dep_flags=`nxt_gen_dep_flags`
    nxt_dep_post=`nxt_gen_dep_post`
    nxt_objs="$nxt_objs $NXT_BUILD_DIR/$nxt_obj"

    cat << END >> $NXT_MAKEFILE

$NXT_BUILD_DIR/$nxt_obj:	$nxt_src $NXT_VERSION_H
	\$(v)mkdir -p $NXT_BUILD_DIR/src/skel
	\$(PP_CC) \$@
	\$(v)\$(CC) -c \$(CFLAGS) $NXT_SKEL_ADDITIONAL_FLAGS \$(NXT_INCS) \\
	    $nxt_dep_flags \\
	    -o $NXT_BUILD_DIR/$nxt_obj $nxt_src
	$nxt_dep_post

-include $NXT_BUILD_DIR/$nxt_dep

END

done


cat << END >> $NXT_MAKEFILE

.PHONY: ${NXT_SKEL_MODULE}
.PHONY: ${NXT_SKEL_MODULE}-install
.PHONY: ${NXT_SKEL_MODULE}-uninstall

all: ${NXT_SKEL_MODULE}

${NXT_SKEL_MODULE}:	$NXT_BUILD_DIR/lib/unit/modules/${NXT_SKEL_MODULE}.unit.so

$NXT_BUILD_DIR/lib/unit/modules/${NXT_SKEL_MODULE}.unit.so:	$nxt_objs
	\$(PP_LD) \$@
	\$(v)\$(NXT_MODULE_LINK) -o \$@ \\
	    $nxt_objs ${NXT_SKEL_LDFLAGS} $NXT_LD_OPT


install: ${NXT_SKEL_MODULE}-install

${NXT_SKEL_MODULE}-install: ${NXT_SKEL_MODULE} install-check
	install -d \$(DESTDIR)$NXT_MODULESDIR
	install -p $NXT_BUILD_DIR/lib/unit/modules/${NXT_SKEL_MODULE}.unit.so \\
		\$(DESTDIR)$NXT_MODULESDIR/


uninstall: ${NXT_SKEL_MODULE}-uninstall

${NXT_SKEL_MODULE}-uninstall:
	rm -f \$(DESTDIR)$NXT_MODULESDIR/${NXT_SKEL_MODULE}.unit.so
	@rmdir -p \$(DESTDIR)$NXT_MODULESDIR 2>/dev/null || true

END