comparison nuc-fw/cfgmagic/processconf.sh @ 88:ccde45a06737

nuc-fw: beginning of the configuration mechanism
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 23 Aug 2013 02:02:59 +0000
parents
children 28f967578233
comparison
equal deleted inserted replaced
87:321f6a9ae989 88:ccde45a06737
1 #!/bin/sh
2 # The top level Makefile invokes this Bourne shell script after ensuring
3 # that the build.conf file is present. The job of this script is to grok
4 # that configuration file and to produce include/config.{h,mk,m4} files
5 # corresponding to the selected configuration.
6 #
7 # The current directory is expected to be the top level of nuc-fw, i.e.,
8 # all fragments are sourced as cfgmagic/blah.
9 # Don't run this script directly - let the Makefile do it for you.
10
11 set -e
12 . cfgmagic/functions
13 TARGET=
14 c_export_list=
15 mk_export_list=
16 m4_export_list=
17
18 . ./build.conf
19
20 if [ -z "$TARGET" ]
21 then
22 echo "Error: target not set in build.conf" 1>&2
23 exit 1
24 fi
25
26 # Once we get some actual functionality, the following definitions
27 # will likely depend on the target and feature configuration,
28 # but for now all we have is a FreeNucleus RTOS demo.
29
30 BUILD_COMPONENTS="nucdemo nucleus sprintf sysglue"
31 export_to_mk BUILD_COMPONENTS
32
33 BUILD_DEFAULT_IMAGE=ramImage
34 export_to_mk BUILD_DEFAULT_IMAGE
35
36 # Now generate the output files!
37
38 parse_export_list() {
39 for var in $1
40 do
41 eval "value=\"\$$var\""
42 emit_def "$var" "$value"
43 done
44 }
45
46 # make config.h
47 emit_def() {
48 echo "#define $1 $2" >> include/config.h
49 }
50 : > include/config.h
51 parse_export_list "$c_export_list"
52
53 # make config.mk
54 emit_def() {
55 echo "$1= $2" >> include/config.mk
56 }
57 : > include/config.mk
58 parse_export_list "$mk_export_list"
59
60 # make config.m4
61 emit_def() {
62 echo 'define(`'"$1'"',`'"$2')dnl" >> include/config.m4
63 }
64 : > include/config.m4
65 parse_export_list "$m4_export_list"