• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -e
4
5mkdir -p amalgamation
6OUTPUT_PREFIX=amalgamation/miniz
7
8cat miniz.h > $OUTPUT_PREFIX.h
9cat miniz.c > $OUTPUT_PREFIX.c
10cat miniz_common.h >> $OUTPUT_PREFIX.h
11cat miniz_tdef.c >> $OUTPUT_PREFIX.c
12cat miniz_tdef.h >> $OUTPUT_PREFIX.h
13cat miniz_tinfl.c >> $OUTPUT_PREFIX.c
14cat miniz_tinfl.h >> $OUTPUT_PREFIX.h
15cat miniz_zip.c >> $OUTPUT_PREFIX.c
16cat miniz_zip.h >> $OUTPUT_PREFIX.h
17
18
19sed -i '0,/#include "miniz.h"/{s/#include "miniz.h"/#include  "miniz.h"/}' $OUTPUT_PREFIX.c
20for i in miniz miniz_common miniz_tdef miniz_tinfl miniz_zip
21do
22	sed -i "s/#include \"$i.h\"//g" $OUTPUT_PREFIX.h
23	sed -i "s/#include \"$i.h\"//g" $OUTPUT_PREFIX.c
24done
25
26echo "int main() { return 0; }" > main.c
27echo "Test compile with GCC..."
28gcc -pedantic -Wall main.c $OUTPUT_PREFIX.c -o test.out
29echo "Test compile with GCC ANSI..."
30gcc -ansi -pedantic -Wall main.c $OUTPUT_PREFIX.c -o test.out
31if command -v clang
32then
33		echo "Test compile with clang..."
34        clang -Wall -Wpedantic -fsanitize=unsigned-integer-overflow main.c $OUTPUT_PREFIX.c -o test.out
35fi
36for def in MINIZ_NO_STDIO MINIZ_NO_TIME MINIZ_NO_ARCHIVE_APIS MINIZ_NO_ARCHIVE_WRITING_APIS MINIZ_NO_ZLIB_APIS MINIZ_NO_ZLIB_COMPATIBLE_NAMES MINIZ_NO_MALLOC
37do
38	echo "Test compile with GCC and define $def..."
39	gcc -ansi -pedantic -Wall main.c $OUTPUT_PREFIX.c -o test.out -D${def}
40done
41rm test.out
42rm main.c
43
44cp ChangeLog.md amalgamation/
45cp LICENSE amalgamation/
46cp readme.md amalgamation/
47mkdir -p amalgamation/examples
48cp examples/* amalgamation/examples/
49
50cd amalgamation
51! test -e miniz.zip || rm miniz.zip
52cat << EOF | zip -@ miniz
53miniz.c
54miniz.h
55ChangeLog.md
56LICENSE
57readme.md
58examples/example1.c
59examples/example2.c
60examples/example3.c
61examples/example4.c
62examples/example5.c
63examples/example6.c
64EOF
65cd ..
66
67echo "Amalgamation created."
68
69
70