allow both "jammod" and "jammodule"
[k8jam.git] / defaults / configure / Jambase.configure.compile
blobd8826107879ca00608a73005378ace8cd938e91c
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
14 # $(1) -- program, string list
15 # $(2) -- additional compiler flags (optional)
16 # $(3) -- additional linker flags (optional)
17 rule -configure-try-compile-cc- {
18   local res = ;
19   if $(CC) && $(LINK) {
20     local tfn = [ RandName ] ;
21     tfn = $(tfn:S=.c) ;
22     if [ ListWrite $(tfn) : $(1) ] {
23       res = [ Command $(CC) -c $(tfn:Q) -o $(tfn:S=.o:Q) $(2) '2>/dev/null' : exit-code no-output ] ;
24       if $(res) = '0' {
25         res = [ Command $(LINK) $(tfn:S=.o:Q) -o $(tfn:S=.elf:Q) $(3) '2>/dev/null' : exit-code no-output ] ;
26       }
27       Command rm $(tfn:Q) $(tfn:S=.o:Q) $(tfn:S=.elf:Q) '2>/dev/null' ;
28       if $(res) = '0' { res = 1 ; } else { res = ; }
29     }
30   }
31   return $(res) ;
35 # $(1) -- test name
36 # $(2) -- program, string list
37 # $(3) -- additional compiler flags (optional)
38 # $(4) -- additional linker flags (optional)
39 rule -configure-test-compile-cc- {
40   local r ;
41   Echo 'checking for' $(1) '... ' : -n ;
42   r = [ -configure-try-compile-cc- $(2) : $(3) : $(4) ] ;
43   if $(r) { Echo 'found' ; } else { Echo 'not found' ; }
44   return $(r);