##// END OF EJS Templates
libucmake: Subdir feature added, no need to provide project file
jeandet -
r2:9fb2544f9ae2 default
parent child
Show More
@@ -1,121 +1,157
1 #!/bin/bash
1 #!/bin/bash
2 #/*------------------------------------------------------------------------------
2 #/*------------------------------------------------------------------------------
3 #-- This file is a part of the libuc, microcontroler library
3 #-- This file is a part of the libuc, microcontroler library
4 #-- Copyright (C) 2011, Alexis Jeandet
4 #-- Copyright (C) 2011, Alexis Jeandet
5 #--
5 #--
6 #-- This program is free software; you can redistribute it and/or modify
6 #-- This program is free software; you can redistribute it and/or modify
7 #-- it under the terms of the GNU General Public License as published by
7 #-- it under the terms of the GNU General Public License as published by
8 #-- the Free Software Foundation; either version 3 of the License, or
8 #-- the Free Software Foundation; either version 3 of the License, or
9 #-- (at your option) any later version.
9 #-- (at your option) any later version.
10 #--
10 #--
11 #-- This program is distributed in the hope that it will be useful,
11 #-- This program is distributed in the hope that it will be useful,
12 #-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #-- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 #-- GNU General Public License for more details.
14 #-- GNU General Public License for more details.
15 #--
15 #--
16 #-- You should have received a copy of the GNU General Public License
16 #-- You should have received a copy of the GNU General Public License
17 #-- along with this program; if not, write to the Free Software
17 #-- along with this program; if not, write to the Free Software
18 #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #-------------------------------------------------------------------------------
19 #-------------------------------------------------------------------------------
20 #-- Author : Alexis Jeandet
20 #-- Author : Alexis Jeandet
21 #-- Mail : alexis.jeandet@gmail.com
21 #-- Mail : alexis.jeandet@gmail.com
22 #-------------------------------------------------------------------------------*/
22 #-------------------------------------------------------------------------------*/
23 TEMPLATE=""
23 TEMPLATE=""
24 ARCH=""
24 ARCH=""
25 TARGET=""
25 TARGET=""
26 SRCFILES=""
26 SRCFILES=""
27 INCLUDES=""
27 INCLUDES=""
28 LIBRARIES=""
28 LIBRARIES=""
29 HEADERSINSTALLPATH=""
29 HEADERSINSTALLPATH=""
30 TARGETINSTALLPATH=""
30 TARGETINSTALLPATH=""
31
31
32 function getFilesList {
32 function getFilesList {
33 sed ':a;N;$!ba;s/\\\n/ /g' $1 | sed ':a;N;$!ba;s/\\ \n/ /g' | grep -i $2 | sed 's/\t//g'
33 sed ':a;N;$!ba;s/\\\n/ /g' $1 | sed ':a;N;$!ba;s/\\ \n/ /g' | grep -i $2 | sed 's/\t//g'
34 }
34 }
35
35
36
36 function Template {
37 function Template {
37 TEMPLATE=`more $1 | grep -i "TEMPLATE " | sed s/TEMPLATE// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
38 TEMPLATE=`more $1 | grep -i "TEMPLATE " | sed s/TEMPLATE// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
38 }
39 }
39
40
40 function Arch {
41 function Arch {
41 ARCH=`more $1 | grep -i "ARCH " | sed s/ARCH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
42 ARCH=`more $1 | grep -i "ARCH " | sed s/ARCH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
42 }
43 }
43
44
44 function Target {
45 function Target {
45 TARGET=`more $1 | grep -i "TARGET " | sed s/TARGET// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
46 TARGET=`more $1 | grep -i "TARGET " | sed s/TARGET// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
46 }
47 }
47
48
48 function Libs_Inc {
49 function Libs_Inc {
49 INCLUDEStmp=`more $1 | grep -i "LIBS " | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
50 INCLUDEStmp=`more $1 | grep -i "LIBS " | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
50 for FILES in $INCLUDEStmp
51 for FILES in $INCLUDEStmp
51 do
52 do
52 INCLUDES+='$('"LIBUC_INC_DIR_$FILES) "
53 INCLUDES+='$('"LIBUC_INC_DIR_$FILES) "
53 done
54 done
54 }
55 }
55 function Libs_Link {
56 function Libs_Link {
56 LIBRARIEStmp=`more $1 | grep -i "LIBS " | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
57 LIBRARIEStmp=`more $1 | grep -i "LIBS " | sed s/LIBS// |sed s/+//|sed s/=//| sed 's/^[ \t]*//;s/[ \t]*$//'`
57 for FILES in $LIBRARIEStmp
58 for FILES in $LIBRARIEStmp
58 do
59 do
59 LIBRARIES+='$('"LIBUC_LIBS_DIR_$FILES) "'$('"LIBUC_LIBS_$FILES) "
60 LIBRARIES+='$('"LIBUC_LIBS_DIR_$FILES) "'$('"LIBUC_LIBS_$FILES) "
60 done
61 done
61 }
62 }
62
63
63 function HeadersInstallPath {
64 function HeadersInstallPath {
64 HEADERSINSTALLPATH=`more $1 | grep -i "HEADERSINSTALLPATH" | sed s/HEADERSINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
65 HEADERSINSTALLPATH=`more $1 | grep -i "HEADERSINSTALLPATH" | sed s/HEADERSINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
65 }
66 }
66
67
67 function TargetInstallPath {
68 function TargetInstallPath {
68 TARGETINSTALLPATH=`more $1 | grep -i "TARGETINSTALLPATH" | sed s/TARGETINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
69 TARGETINSTALLPATH=`more $1 | grep -i "TARGETINSTALLPATH" | sed s/TARGETINSTALLPATH// | sed s/=// | sed 's/^[ \t]*//;s/[ \t]*$//'`
69 }
70 }
70
71
71
72 if [ -z "$1" ] ; then
73 echo "try to find a project file ..."
74 TMP=`ls *.pro`
75 i=1
76 for Files in $TMP
77 do
78 echo "found $Files"
79 PROJECTFILES[i]=$Files
80 i=$((i + 1))
81 done
82 if [ -z "${PROJECTFILES[1]}" ]; then
83 exit
84 else
85 PROJECTFILE=${PROJECTFILES[1]}
86 fi
87
88 else
89 PROJECTFILE=$1
90 fi
72
91
73 Template $1
92 CURRENTDIR=`pwd`
74 Target $1
93 Template $PROJECTFILE
75 Arch $1
94 echo '' > Makefile
76 Libs_Inc $1
77 Libs_Link $1
78 HeadersInstallPath $1
79 TargetInstallPath $1
80 echo $SRCFILES > Makefile
81 getFilesList $1 HEADERS >> Makefile
82 getFilesList $1 SOURCES >> Makefile
83 echo 'PROJECTDIR = `pwd`'>> Makefile
95 echo 'PROJECTDIR = `pwd`'>> Makefile
84 echo 'OBJECTFILES = $(SOURCES:.c=.o)'>> Makefile
85 echo "LIBUC = $libuc2" >> Makefile
96 echo "LIBUC = $libuc2" >> Makefile
86 echo "ARCH = "'$(LIBUC)'"/rules/$ARCH" >> Makefile
87 echo "TARGET=$TARGET">> Makefile
88 echo "LIBUC_INCLUDES=$INCLUDES">> Makefile
89 echo "LIBUC_LIBRARIES=$LIBRARIES">> Makefile
90 echo "TARGETINSTALLPATH=$TARGETINSTALLPATH">> Makefile
91 echo "HEADERSINSTALLPATH=$HEADERSINSTALLPATH">> Makefile
92 echo 'include $(ARCH)/rules.mk' >> Makefile
93
94
95
97
96 if(echo $TEMPLATE|grep -i app); then
98 if(echo $TEMPLATE|grep -i 'dir'); then
97 echo '' >> Makefile
99
98 echo 'all:bin' >> Makefile
100 echo 'include $(LIBUC)/rules/common/rules.mk' >> Makefile
101 SUBDIRS=`getFilesList $PROJECTFILE SUBDIRS | sed 's/SUBDIRS//' | sed 's/=//' | sed 's/+//' `
102 CURRENTDIR=`pwd`
103 echo $CURRENTDIR
104 echo "" >> Makefile
105 echo 'all:subdir' >> Makefile
106 for DIRS in $SUBDIRS
107 do
108 cd $DIRS
109 $0
110 cd $CURRENTDIR
111 if [ -e "$DIRS/Makefile" ]; then
112 echo " make -C $DIRS">> Makefile
113 fi
114 done
99 echo " @echo Code compiled" >> Makefile
115 echo " @echo Code compiled" >> Makefile
100 else
116 echo "" >> Makefile
101 if(echo $TEMPLATE|grep -i lib); then
117 else
118 Target $PROJECTFILE
119 Arch $PROJECTFILE
120 Libs_Inc $PROJECTFILE
121 Libs_Link $PROJECTFILE
122 HeadersInstallPath $PROJECTFILE
123 TargetInstallPath $PROJECTFILE
124 echo $SRCFILES >> Makefile
125 getFilesList $PROJECTFILE HEADERS >> Makefile
126 getFilesList $PROJECTFILE SOURCES >> Makefile
127 echo 'OBJECTFILES = $(SOURCES:.c=.o)'>> Makefile
128 echo "ARCH = "'$(LIBUC)'"/rules/$ARCH" >> Makefile
129 echo "TARGET=$TARGET">> Makefile
130 echo "LIBUC_INCLUDES=$INCLUDES">> Makefile
131 echo "LIBUC_LIBRARIES=$LIBRARIES">> Makefile
132 echo "TARGETINSTALLPATH=$TARGETINSTALLPATH">> Makefile
133 echo "HEADERSINSTALLPATH=$HEADERSINSTALLPATH">> Makefile
134 echo 'include $(ARCH)/rules.mk' >> Makefile
135
136 if(echo $TEMPLATE|grep -i app); then
102 echo '' >> Makefile
137 echo '' >> Makefile
103 echo 'all:lib' >> Makefile
138 echo 'all:bin' >> Makefile
104 echo " @echo Code compiled" >> Makefile
139 echo " @echo Code compiled" >> Makefile
105 else
140 else
106 if(echo $TEMPLATE|grep -i dir); then
141 if(echo $TEMPLATE|grep -i lib); then
107 echo '' >> Makefile
142 echo '' >> Makefile
108 echo 'all:subdir' >> Makefile
143 echo 'all:lib' >> Makefile
109 echo " @echo Code compiled" >> Makefile
144 echo " @echo Code compiled" >> Makefile
110 fi
145 fi
111 fi
146 fi
112 fi
147 fi
148
113 echo $TEMPLATE
149 echo $TEMPLATE
114 echo $TARGET
150 echo $TARGET
115 echo $ARCH
151 echo $ARCH
116
152
117
153
118
154
119
155
120
156
121
157
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,17 +1,18
1
2 PROJECTDIR = `pwd`
3 LIBUC = /opt/libuc2
1
4
2 HEADERSINSTALLPATH = $(LIBUC_INC_DIR)/UART
5 HEADERSINSTALLPATH = $(LIBUC_INC_DIR)/UART
3 HEADERS += uart.h
6 HEADERS += uart.h
4 SOURCES += uart.c
7 SOURCES += uart.c
5 PROJECTDIR = `pwd`
6 OBJECTFILES = $(SOURCES:.c=.o)
8 OBJECTFILES = $(SOURCES:.c=.o)
7 LIBUC = /opt/libuc2
8 ARCH = $(LIBUC)/rules/lpc17XX-arm-noabi-gcc
9 ARCH = $(LIBUC)/rules/lpc17XX-arm-noabi-gcc
9 TARGET=libuart
10 TARGET=libuart
10 LIBUC_INCLUDES=
11 LIBUC_INCLUDES=
11 LIBUC_LIBRARIES=
12 LIBUC_LIBRARIES=
12 TARGETINSTALLPATH=$(LIBUC_LIBS_DIR)/UART
13 TARGETINSTALLPATH=$(LIBUC_LIBS_DIR)/UART
13 HEADERSINSTALLPATH=$(LIBUC_INC_DIR)/UART
14 HEADERSINSTALLPATH=$(LIBUC_INC_DIR)/UART
14 include $(ARCH)/rules.mk
15 include $(ARCH)/rules.mk
15
16
16 all:lib
17 all:lib
17 @echo Code compiled
18 @echo Code compiled
@@ -1,23 +1,29
1 #/*------------------------------------------------------------------------------
1 #/*------------------------------------------------------------------------------
2 #-- This file is a part of the libuc, microcontroler library
2 #-- This file is a part of the libuc, microcontroler library
3 #-- Copyright (C) 2011, Alexis Jeandet
3 #-- Copyright (C) 2011, Alexis Jeandet
4 #--
4 #--
5 #-- This program is free software; you can redistribute it and/or modify
5 #-- This program is free software; you can redistribute it and/or modify
6 #-- it under the terms of the GNU General Public License as published by
6 #-- it under the terms of the GNU General Public License as published by
7 #-- the Free Software Foundation; either version 3 of the License, or
7 #-- the Free Software Foundation; either version 3 of the License, or
8 #-- (at your option) any later version.
8 #-- (at your option) any later version.
9 #--
9 #--
10 #-- This program is distributed in the hope that it will be useful,
10 #-- This program is distributed in the hope that it will be useful,
11 #-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 #-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #-- GNU General Public License for more details.
13 #-- GNU General Public License for more details.
14 #--
14 #--
15 #-- You should have received a copy of the GNU General Public License
15 #-- You should have received a copy of the GNU General Public License
16 #-- along with this program; if not, write to the Free Software
16 #-- along with this program; if not, write to the Free Software
17 #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #-------------------------------------------------------------------------------
18 #-------------------------------------------------------------------------------
19 #-- Author : Alexis Jeandet
19 #-- Author : Alexis Jeandet
20 #-- Mail : alexis.jeandet@gmail.com
20 #-- Mail : alexis.jeandet@gmail.com
21 #-------------------------------------------------------------------------------*/
21 #-------------------------------------------------------------------------------*/
22
22
23
24
25 all:
26 @echo "Generic subdir rules"
27
23 subdir:
28 subdir:
29 @echo "Generic subdir rules"
General Comments 0
You need to be logged in to leave comments. Login now