xref: /freebsd/contrib/flex/src/mkskel.sh (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1#! /bin/sh
2
3#  This file is part of flex.
4
5#  Redistribution and use in source and binary forms, with or without
6#  modification, are permitted provided that the following conditions
7#  are met:
8
9#  1. Redistributions of source code must retain the above copyright
10#     notice, this list of conditions and the following disclaimer.
11#  2. Redistributions in binary form must reproduce the above copyright
12#     notice, this list of conditions and the following disclaimer in the
13#     documentation and/or other materials provided with the distribution.
14
15#  Neither the name of the University nor the names of its contributors
16#  may be used to endorse or promote products derived from this software
17#  without specific prior written permission.
18
19#  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20#  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22#  PURPOSE.
23
24if test ! $# = 3; then
25   echo 'Usage: mkskel.sh srcdir m4 version' >&2
26   exit 1
27fi
28echo '/* File created from flex.skl via mkskel.sh */
29
30#include "flexdef.h"
31
32const char *skel[] = {'
33srcdir=$1
34m4=$2
35VERSION=$3
36case $VERSION in
37   *[!0-9.]*) echo 'Invalid version number' >&2; exit 1;;
38esac
39IFS=.
40set $VERSION
41sed 's/4_/a4_/g
42s/m4preproc_/m4_/g
43' "$srcdir/flex.skl" |
44"$m4" -P -I "$srcdir" "-DFLEX_MAJOR_VERSION=$1" \
45   "-DFLEX_MINOR_VERSION=$2" \
46   "-DFLEX_SUBMINOR_VERSION=$3" |
47sed '/^%#/d
48s/m4_/m4preproc_/g
49s/a4_/4_/g
50s/[\\"]/\\&/g
51s/.*/  "&",/'
52
53echo '  0
54};'
55