-
Notifications
You must be signed in to change notification settings - Fork 0
/
amalgamate.sh
executable file
·44 lines (35 loc) · 1.58 KB
/
amalgamate.sh
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
# delete existing file and create a new one
rm -f moreward.h
touch moreward.h
# add include guard
printf "#ifndef _MOREWARD_H_\n" >> moreward.h
printf "#define _MOREWARD_H_\n" >> moreward.h
# add comment/guide at the top
printf "\n/*\n" >> moreward.h
printf "\nLicense (MIT) is at the EOF .\n\n" >> moreward.h
cat readme.md >> moreward.h
printf "\n*/\n\n" >> moreward.h
# add header file (remove top 3 and last 1 line from each)
sed '1,3d;$d' src/m.h >> moreward.h
# add implementation include guard
printf "\n\n/* IMPLEMENTATION */\n\n" >> moreward.h
printf "\n#ifdef MOREWARD_IMPL\n\n" >> moreward.h
# add impl. header file (remove top 3 and last 1 line from each)
sed '1,3d;$d' src/i.h >> moreward.h
# add implementation files (remove top 1 line from each
# which includes m.h)
sed '1,2d' src/alloc.c >> moreward.h
sed '1,2d' src/buffer.c >> moreward.h
# sed '2d' src/mg_create_destroy.c >> moreward.h
sed '1,2d' src/list.c >> moreward.h
sed '1,2d' src/dict.c >> moreward.h
sed '1,2d' src/strbuffer.c >> moreward.h
sed '1,2d' src/log.c >> moreward.h
# add end implementation include guard
printf "\n\n#endif /* MOREWARD_IMPL */\n\n" >> moreward.h
# add license text at the bottom
printf "/*\n\n" >> moreward.h
cat license.txt >> moreward.h
printf "\n*/\n\n" >> moreward.h
# add end include guard
printf "#endif /* _MOREWARD_H_ */\n" >> moreward.h