Bladeren bron

Import nacl from packages, add myself as maintainer, do some cleanup

Matthias Schiffer 10 jaren geleden
bovenliggende
commit
ec23ef3cdc
2 gewijzigde bestanden met toevoegingen van 251 en 0 verwijderingen
  1. 45
    0
      libs/nacl/Makefile
  2. 206
    0
      libs/nacl/do-openwrt

+ 45
- 0
libs/nacl/Makefile Bestand weergeven

@@ -0,0 +1,45 @@
1
+#
2
+# Copyright (C) 2011-2014 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=nacl
11
+PKG_VERSION:=20110221
12
+PKG_RELEASE:=1
13
+
14
+PKG_MAINTAINER:=Matthias Schiffer <mschiffer@universe-factory.net>
15
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
16
+PKG_SOURCE_URL:=http://hyperelliptic.org/nacl
17
+PKG_MD5SUM:=7efb5715561c3d10dafd3fa97b4f2d20
18
+
19
+include $(INCLUDE_DIR)/package.mk
20
+
21
+define Package/nacl
22
+  SECTION:=libs
23
+  CATEGORY:=Libraries
24
+  TITLE:=NaCl Networking and Cryptography library
25
+  URL:=http://nacl.cace-project.eu/
26
+endef
27
+
28
+define Build/Compile
29
+	(cd $(PKG_BUILD_DIR) && \
30
+			CC="$(TARGET_CC)" \
31
+			CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
32
+			AR="$(TARGET_CROSS)ar" \
33
+			RANLIB="$(TARGET_CROSS)ranlib" \
34
+		$(CURDIR)/do-openwrt \
35
+	)
36
+endef
37
+
38
+define Build/InstallDev
39
+	$(INSTALL_DIR) $(1)/usr/include/nacl
40
+	$(CP) $(PKG_BUILD_DIR)/build/include/*.h $(1)/usr/include/nacl/
41
+	$(INSTALL_DIR) $(1)/usr/lib
42
+	$(CP) $(PKG_BUILD_DIR)/build/lib/libnacl.a $(1)/usr/lib/
43
+endef
44
+
45
+$(eval $(call BuildPackage,nacl))

+ 206
- 0
libs/nacl/do-openwrt Bestand weergeven

@@ -0,0 +1,206 @@
1
+#!/bin/sh
2
+set -e
3
+
4
+# nacl/do
5
+# D. J. Bernstein
6
+# Public domain.
7
+
8
+version=`cat version`
9
+project=nacl
10
+
11
+top="`pwd`/build"
12
+bin="$top/bin"
13
+lib="$top/lib"
14
+include="$top/include"
15
+work="$top/work"
16
+
17
+
18
+# and work around bug in GNU sort
19
+LANG=C
20
+export LANG
21
+
22
+rm -rf "$top"
23
+mkdir -p "$top"
24
+mkdir -p "$bin"
25
+mkdir -p "$lib"
26
+mkdir -p "$include"
27
+
28
+exec >"$top/log"
29
+exec 2>&1
30
+exec 5>"$top/data"
31
+exec </dev/null
32
+
33
+echo "=== `date` === starting"
34
+
35
+echo "=== `date` === building inttypes"
36
+for target in int8 int16 int32 int64 uint8 uint16 uint32 uint64; do
37
+  (
38
+    echo "#ifndef crypto_${target}_h"
39
+    echo "#define crypto_${target}_h"
40
+    echo ""
41
+    echo "#include <stdint.h>"
42
+    echo ""
43
+    echo "typedef ${target}_t crypto_${target};"
44
+    echo ""
45
+    echo "#endif"
46
+  ) > "$include/crypto_$target.h"
47
+done
48
+
49
+echo "=== `date` === building randombytes"
50
+rm -rf "$work"
51
+mkdir -p "$work"
52
+cp -pr randombytes/* "$work"
53
+(
54
+  cd "$work"
55
+
56
+  cp devurandom.c randombytes-impl.c
57
+  cp devurandom.h randombytes-impl.h
58
+  $CC $CFLAGS -c randombytes-impl.c
59
+  mkdir -p lib
60
+  mv randombytes-impl.o lib/randombytes.o
61
+  mkdir -p include
62
+  mv randombytes-impl.h include/randombytes.h
63
+)
64
+cp -pr "$work"/lib/* "$lib"
65
+cp -pr "$work"/include/* "$include"
66
+
67
+rm -rf "$work"
68
+mkdir -p "$work"
69
+echo 'void crypto_'"$project"'_base(void) { ; }' > "$work/${project}_base.c"
70
+( cd "$work" && $CC $CFLAGS -c ${project}_base.c )
71
+$AR cr "$lib/lib${project}.a" "$work/${project}_base.o"
72
+( $RANLIB "$lib/lib${project}.a" || exit 0 )
73
+
74
+# loop over operations
75
+cat OPERATIONS \
76
+| while read o
77
+do
78
+  [ -d "$o" ] || continue
79
+
80
+  # for each operation, loop over primitives
81
+  ls "$o" \
82
+  | sort \
83
+  | while read p
84
+  do
85
+    [ -d "$o/$p" ] || continue
86
+    op="${o}_${p}"
87
+
88
+    startdate=`date +%Y%m%d`
89
+
90
+    echo "=== `date` === $o/$p"
91
+
92
+    rm -rf "$work"
93
+    mkdir -p "$work"
94
+
95
+    if [ -d "$o/$p/ref" ]; then
96
+      implementationdir="$o/$p/ref"
97
+    else
98
+      implementationdir="$o/$p/portable"
99
+    fi
100
+
101
+    opi=`echo "$implementationdir" | tr ./- ___`
102
+
103
+    echo "=== `date` === $implementationdir"
104
+
105
+    cfiles=`ls "$implementationdir" | grep '\.c$' || :`
106
+    sfiles=`ls "$implementationdir" | grep '\.[sS]$' || :`
107
+
108
+    cp -p "$o"/*.c "$work"
109
+
110
+    cp -pr "$implementationdir"/* "$work"
111
+
112
+    cp -p MACROS "$work/MACROS"
113
+    cp -p PROTOTYPES.c "$work/PROTOTYPES.c"
114
+
115
+    (
116
+      cd "$work"
117
+      (
118
+	echo "#ifndef ${o}_H"
119
+	echo "#define ${o}_H"
120
+	echo ""
121
+	echo "#include \"${op}.h\""
122
+	echo ""
123
+	egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \
124
+	  | sed "s/$o/$op/" | while read mop
125
+	do
126
+	  echo "#define ${mop} ${mop}" | sed "s/$op/$o/"
127
+	done
128
+	echo "#define ${o}_PRIMITIVE \"${p}\""
129
+	echo "#define ${o}_IMPLEMENTATION ${op}_IMPLEMENTATION"
130
+	echo "#define ${o}_VERSION ${op}_VERSION"
131
+	echo ""
132
+	echo "#endif"
133
+      ) > "$o.h"
134
+      (
135
+	echo "#ifndef ${op}_H"
136
+	echo "#define ${op}_H"
137
+	echo ""
138
+	sed 's/[ 	]CRYPTO_/ '"${opi}"'_/g' < api.h
139
+	echo '#ifdef __cplusplus'
140
+	  #echo '#include <string>'
141
+	  #egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.cpp \
142
+	  #    | sed "s/$o/$opi/"
143
+	echo 'extern "C" {'
144
+	echo '#endif'
145
+	egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < PROTOTYPES.c \
146
+	  | sed "s/$o/$opi/"
147
+	echo '#ifdef __cplusplus'
148
+	echo '}'
149
+	echo '#endif'
150
+	echo ""
151
+	egrep "${o}"'$|'"${o}"'\(|'"${o}"'_' < MACROS \
152
+	  | sed "s/$o/$opi/" | while read mopi
153
+	do
154
+	    echo "#define ${mopi} ${mopi}" | sed "s/$opi/$op/"
155
+	done
156
+	echo "#define ${op}_IMPLEMENTATION \"${implementationdir}\""
157
+	echo "#ifndef ${opi}_VERSION"
158
+	echo "#define ${opi}_VERSION \"-\""
159
+	echo "#endif"
160
+	echo "#define ${op}_VERSION ${opi}_VERSION"
161
+	echo ""
162
+	echo "#endif"
163
+      ) > "$op.h"
164
+
165
+      echo "=== `date` === $implementationdir $CC $CFLAGS"
166
+      for f in $cfiles $sfiles
167
+      do
168
+	ok=1
169
+	$CC $CFLAGS \
170
+	    -I. -I"$include" \
171
+	    -c "$f" >errors 2>&1 || ok=0
172
+	( if [ `wc -l < errors` -lt 25 ]
173
+	  then
174
+	    cat errors
175
+	  else
176
+	    head errors
177
+	    echo ...
178
+	    tail errors
179
+	  fi
180
+	) \
181
+	| while read err
182
+	do
183
+	  echo "$version $startdate $o $p fromcompiler $implementationdir $f $err" >&5
184
+	done
185
+
186
+	[ "$ok" = 1 ]
187
+      done
188
+
189
+      for f in *.o
190
+      do
191
+	mv "$f" "${opi}-$f"
192
+      done
193
+    )
194
+
195
+    echo "=== `date` === $implementationdir $CC $CFLAGS finishing"
196
+
197
+    $AR cr "$lib/lib${project}.a" "$work"/*.o \
198
+    && ( $RANLIB "$lib/lib${project}.a" || exit 0 ) \
199
+    && cp -p "$work/$op.h" "$include/$op.h" \
200
+    && [ -f "$o/$p/selected" ] \
201
+    && cp -p "$work/$o.h" "$include/$o.h" \
202
+    || :
203
+  done
204
+done
205
+
206
+echo "=== `date` === finishing"