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