RedHawk Build Failure on Ubuntu 16.04 - ubuntu-16.04

I'm trying to build the RedHawkSdr CF on Ubuntu 16.04. Seems like this should be a relatively easy operation, but I'm not sure where to even start to look at this problem. I believe that I followed all of the Ubuntu-specific instructions for dependencies and environment variables.
I'm getting this error:
make[2]: Entering directory '/home/brasssm1/workspace/draco/redhawk-src-2.0.3/redhawk/src/control/parser'
xsdcxx cxx-parser --root-element deviceconfiguration --type-map internal/dcd.map --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/dcd.xsd; sed -i 's/ns == "urn:mil:jpeojtrs:sca:dcd"/ns.empty()/g' internal/dcd-pskel.cpp; sed -i 's/"urn:mil:jpeojtrs:sca:dcd"/""/g' internal/dcd-pskel.cpp
xsdcxx cxx-parser --root-element domainmanagerconfiguration --type-map internal/dmd.map --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/dmd.xsd; sed -i 's/ns == "urn:mil:jpeojtrs:sca:dmd"/ns.empty()/g' internal/dmd-pskel.cpp; sed -i 's/"urn:mil:jpeojtrs:sca:dmd"/""/g' internal/dmd-pskel.cpp
xsdcxx cxx-parser --root-element devicepkg --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/dpd.xsd
xsdcxx cxx-parser --root-element properties --type-map internal/prf.map --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/prf.xsd; sed -i 's/ns == "urn:mil:jpeojtrs:sca:prf"/ns.empty()/g' internal/prf-pskel.cpp; sed -i 's/"urn:mil:jpeojtrs:sca:prf"/""/g' internal/prf-pskel.cpp
xsdcxx cxx-parser --root-element profile --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/profile.xsd
xsdcxx cxx-parser --root-element softwareassembly --type-map internal/sad.map --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/sad.xsd; sed -i 's/ns == "urn:mil:jpeojtrs:sca:sad"/ns.empty()/g' internal/sad-pskel.cpp; sed -i 's/"urn:mil:jpeojtrs:sca:sad"/""/g' internal/sad-pskel.cpp
xsdcxx cxx-parser --root-element softwarecomponent --type-map internal/scd.map --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/scd.xsd; sed -i 's/ns == "urn:mil:jpeojtrs:sca:scd"/ns.empty()/g' internal/scd-pskel.cpp; sed -i 's/"urn:mil:jpeojtrs:sca:scd"/""/g' internal/scd-pskel.cpp
xsdcxx cxx-parser --root-element softpkg --type-map internal/spd.map --hxx-suffix .h --cxx-suffix .cpp --xml-parser expat --output-dir internal --generate-validation ../../xml/xsd/spd.xsd; sed -i 's/ns == "urn:mil:jpeojtrs:sca:spd"/ns.empty()/g' internal/spd-pskel.cpp; sed -i 's/"urn:mil:jpeojtrs:sca:spd"/""/g' internal/spd-pskel.cpp
make all-am
make[3]: Entering directory '/home/brasssm1/workspace/draco/redhawk-src-2.0.3/redhawk/src/control/parser'
CXX libossieparser_la-Properties.lo
CXX libossieparser_la-debug.lo
CXX libossieparser_la-SoftPkg.lo
CXX libossieparser_la-DomainManagerConfiguration.lo
CXX libossieparser_la-ComponentDescriptor.lo
CXX libossieparser_la-SoftwareAssembly.lo
CXX libossieparser_la-componentProfile.lo
CXX libossieparser_la-DeviceManagerConfiguration.lo
CXX internal/libossieparser_la-prf-pskel.lo
In file included from /usr/include/xsd/cxx/parser/expat/elements.hxx:362:0,
from internal/sad-pskel.h:114,
from internal/sad-pimpl.h:30,
from internal/sad-parser.h:27,
from SoftwareAssembly.cpp:22:
/usr/include/xsd/cxx/parser/expat/elements.txx: In member function ‘bool xsd::cxx::parser::expat::document<C>::parse(std::istream&, const std::__cxx11::basic_string<_CharT>*, const std::__cxx11::basic_string<_CharT>*, xsd::cxx::xml::error_handler<C>&)’:
/usr/include/xsd/cxx/parser/expat/elements.txx:282:22: error: no match for ‘operator==’ (operand types are ‘xsd::cxx::parser::expat::parser_auto_ptr’ and ‘int’)
if (parser == 0)
^
In file included from /usr/include/xsd/cxx/parser/xml-schema.hxx:569:0,
from internal/sad-pskel.h:109,
from internal/sad-pimpl.h:30,
from internal/sad-parser.h:27,
from SoftwareAssembly.cpp:22:
/usr/include/xsd/cxx/parser/xml-schema.txx:15:7: note: candidate: template<class C> bool xsd::cxx::parser::operator==(const xsd::cxx::parser::string_sequence<C>&, const xsd::cxx::parser::string_sequence<C>&)
operator== (const string_sequence<C>& a, const string_sequence<C>& b)
^
/usr/include/xsd/cxx/parser/xml-schema.txx:15:7: note: template argument deduction/substitution failed:
In file included from /usr/include/xsd/cxx/parser/expat/elements.hxx:362:0,
from internal/sad-pskel.h:114,
from internal/sad-pimpl.h:30,
from internal/sad-parser.h:27,
from SoftwareAssembly.cpp:22:
/usr/include/xsd/cxx/parser/expat/elements.txx:282:25: note: ‘xsd::cxx::parser::expat::parser_auto_ptr’ is not derived from ‘const xsd::cxx::parser::string_sequence<C>’
if (parser == 0)
I downloaded the dependencies per the instruction, though I noticed one error when updating the repos:
E: Failed to fetch
http://ppa.launchpad.net/redhawksdr/redhawk/ubuntu/dists/xenial/main/binary-amd64/Packages
404 Not Found
E: Some index files failed to download. They have been ignored, or old
ones used instead.
I'm not sure if this is causing any problems or not.

Looks like this is a bug in expat, here is a link that provides some diffs for a similar bug.
You'll need to apply the same sort of fix, in elements.txx line 282 change parser == 0 to parser.get() == 0
This is what the current HEAD of expat's git repo looks like and they have the same fix
After making that fix the framework should compile.
Regarding the 404 error, there are only packages in that ppa for Trusty (14.04). You can see that here. The omniEvents package available in 16.04's default repositories should work fine in most cases.

Related

Error in Makefile calling sed with comment character

I'm trying to build lstrip, a Lua utility for compressing Lua source code. I'm trying to build for Lua 5.1.3 on OS X v10.10.3.
I have downloaded and extracted the Lua 5.1.3 source code and modified the Makefile for lstrip to point to this directory. However, when I run make, I get this output:
cc -I/usr/local/src/lua-5.1.3/src -I/usr/local/src/lua-5.1.3/src -O2 -Wall -Wextra -O2 -c -o lstrip.o lstrip.c
lstrip.c:33:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char* argv[])
^
1 warning generated.
sed '/void luaX_next/i#include "proxy.c"' /usr/local/src/lua-5.1.3/src/llex.c > llex.c
sed: 1: "/void luaX_next/i#inclu ...": command i expects \ followed by text
make: *** [llex.c] Error 1
This is what the relevant Makefile command looks like:
llex.c:
sed '/void luaX_next/i#include "proxy.c"' $(LUASRC)/$# > $#
I think that this is because the # in the sed command is being treated like an actual comment, but I'm not sure.
How can I fix the Makefile, or manually run the steps, to get lstrip built?
Full copy of the Makefile follows, in case it matters:
# makefile for lstrip
# change these to reflect your Lua installation (Lua 5.1!)
LUA= /usr/local/src/lua-5.1.3
LUAINC= $(LUA)/src
LUALIB= $(LUA)/src
LUASRC= $(LUA)/src
# no need to change anything below here
CFLAGS= $(INCS) $(WARN) -O2 $G
WARN= -O2 -Wall -Wextra
INCS= -I$(LUAINC) -I$(LUASRC)
LIBS= -L$(LUALIB) -llua -lm
MYNAME= lstrip
MYLIB= $(MYNAME)
T= $(MYNAME)
OBJS= $(MYNAME).o llex.o
TEST= test.lua
all: test
test: $T
$T $(TEST)
$T: $(OBJS)
$(CC) -o $# $(OBJS) $(LIBS)
llex.c:
sed '/void luaX_next/i#include "proxy.c"' $(LUASRC)/$# > $#
llex.o: proxy.c
clean:
-rm -f $(OBJS) core core.* a.out $(MYNAME)
# eof
Hand-build solution:
cp /usr/local/src/lua-5.1.3/src/llex.c .
Hand-edit llex.c to add the line #include "proxy.c" before the line starting with void luaX_next (line 446 for me).
Now run make, which will succeed.
You can find the answer in the sed manual, and it is in the Makefile lines
llex.c:
sed '/void luaX_next/i#include "proxy.c"' $(LUASRC)/$# > $#
Some variable expansion takes place here:
$(LUASRC) is expanded to the variable set above -> $(LUA)/src. Recurse as needed.
$# is replaced with the current target (llex.c)
So this recipe says:
In order to obtain the target llex.c (which will be processed later through other recipes), apply a stream editing command to the file $LUASRC/llex.c and write it to llex.c.
The stream editing command is: look for text "void luaX_next", before printing it, insert line "#include "proxy.c"".
Problem is, the command to do this is not "i" but "i\(newline)", which conflicts with a requirement of Makefiles that recipes must be on a single line.
I suspect that in order to fix your Makefile you need to use a different command than sed; awk can fit the bill although it's a bit more complex.
This line works in Mac OS X and in Linux:
sed '/void luaX_next/{h;s/.*/#include "proxy.c"/;p;g;}' $(LUASRC)/$# > $#

Perl. Install PAR::Packer under Windows (w/ Strawberry Perl)

I am trying to install PAR::Packer on a Windows system. I tried "cpanm -n PAR::Packer --force" but got the following dump. I don't even understand what it is trying to do in my GnuPgp directory, but apparently there is a problem with blank spaces in its path?
Thanks!
Configuring PAR-Packer-1.019
Running Makefile.PL
Checking if your kit is complete...
Looks good
Prototype mismatch: sub main::prompt: none vs ($;$) at C:/Dwimperl/perl/lib/ExtUtils/MakeMaker.pm line 219
Writing Makefile for par.exe
Writing MYMETA.yml and MYMETA.json
Writing Makefile for PAR::Packer
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have Compress::Zlib 1.16 ... Yes (2.042)
Checking if you have Archive::Zip 1 ... Yes (1.30)
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (6.62)
Checking if you have Getopt::ArgvFile 1.07 ... Yes (1.11)
Checking if you have IO::Compress::Gzip 0 ... Yes (2.042)
Checking if you have PAR 1.005 ... Yes (1.007)
Checking if you have PAR::Dist 0.22 ... Yes (0.48)
Checking if you have ExtUtils::Embed 0 ... Yes (1.30)
Checking if you have File::Temp 0.05 ... Yes (0.22)
Checking if you have Win32::Process 0 ... Yes (0.14)
Checking if you have Parse::Binary 0.04 ... Yes (0.11)
Checking if you have Module::ScanDeps 1.09 ... Yes (1.13)
Checking if you have Win32::Exe 0.17 ... Yes (0.17)
Building PAR-Packer-1.019
cp lib/App/Packer/PAR.pm blib\lib\App\Packer\PAR.pm
cp lib/PAR/Packer.pm blib\lib\PAR\Packer.pm
cp lib/PAR/Filter/Obfuscate.pm blib\lib\PAR\Filter\Obfuscate.pm
cp lib/PAR/Filter/PodStrip.pm blib\lib\PAR\Filter\PodStrip.pm
cp lib/PAR/StrippedPARL/Base.pm blib\lib\PAR\StrippedPARL\Base.pm
cp lib/PAR/Filter.pm blib\lib\PAR\Filter.pm
cp lib/PAR/Filter/PatchContent.pm blib\lib\PAR\Filter\PatchContent.pm
cp lib/PAR/Filter/Bytecode.pm blib\lib\PAR\Filter\Bytecode.pm
cp lib/pp.pm blib\lib\pp.pm
cp lib/PAR/Filter/Bleach.pm blib\lib\PAR\Filter\Bleach.pm
C:\Dwimperl\perl\bin\perl.exe par_pl2c.pl my_par_pl < ..\script\par.pl > my_par_pl.c
C:\Dwimperl\perl\bin\perl.exe sha1.c.PL
gcc -c -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields -I"C:\Dwimperl\perl\lib\CORE" -DPARL_EXE=\"parl.exe\" -s -O2 main.c
main.c: In function 'main':
main.c:121: warning: assignment discards qualifiers from pointer target type
windres -i winres/pp.rc -o ppresource.coff --input-format=rc --output-format=coff --target=pe-i386
g++ main.o ppresource.coff -s -s -L"C:\Dwimperl\perl\lib\CORE" -L"C:\Dwimperl\c\lib" C:\Dwimperl\perl\lib\CORE\libperl514.a C:\Dwimperl\c\i686-w64-mingw32\lib\libmoldname.a C:\Dwimperl\c\i686-w64-mingw32\lib\libkernel32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libuser32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libgdi32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libwinspool.a C:\Dwimperl\c\i686-w64-mingw32\lib\libcomdlg32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libadvapi32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libshell32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libole32.a C:\Dwimperl\c\i686-w64-mingw32\lib\liboleaut32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libnetapi32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libuuid.a C:\Dwimperl\c\i686-w64-mingw32\lib\libws2_32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libmpr.a C:\Dwimperl\c\i686-w64-mingw32\lib\libwinmm.a C:\Dwimperl\c\i686-w64-mingw32\lib\libversion.a C:\Dwimperl\c\i686-w64-mingw32\lib\libodbc32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libodbccp32.a C:\Dwimperl\c\i686-w64-mingw32\lib\libcomctl32.a -o par.exe
rem
C:\Dwimperl\perl\bin\perl.exe encode_append.pl Dynamic.in par.exe Dynamic.pm
C:\Dwimperl\perl\bin\perl.exe file2c.pl -c 30000 par.exe C:\Dwimperl\perl\bin\perl514.dll C:\Dwimperl\perl\bin\libgcc_s_sjlj-1.dll C:\Program Files (x86)\GNU\GnuPG\pub\libstdc++-6.dll > boot_embedded_files.c
open input file 'C:\Program': No such file or directory at file2c.pl line 43.
dmake: Error code 130, while making 'boot_embedded_files.c'
dmake: 'boot_embedded_files.c' removed.
dmake.exe: Error code 255, while making 'subdirs'
-> FAIL Installing PAR::Packer failed. See C:\Users\user\.cpanm\work\1406015074.8672\build.log for details. Retry with --force to force install it.
From your output, you can see the commands which the Makefile is executing. This one:
C:\Dwimperl\perl\bin\perl.exe file2c.pl -c 30000 par.exe C:\Dwimperl\perl\bin\perl514.dll C:\Dwimperl\perl\bin\libgcc_s_sjlj-1.dll C:\Program Files (x86)\GNU\GnuPG\pub\libstdc++-6.dll > boot_embedded_files.c
appears to attempt to pass this filename:
C:\Program Files (x86)\GNU\GnuPG\pub\libstdc++-6.dll
as a command-line argument, but does not quote it. The called program therefore attempts to open file C:\Program and fails. The fault probably lies somewhere within the build process, where a value should have been quoted, but wasn't. You might be able to work round it by executing the command correctly quoted:
C:\Dwimperl\perl\bin\perl.exe file2c.pl -c 30000 par.exe C:\Dwimperl\perl\bin\perl514.dll C:\Dwimperl\perl\bin\libgcc_s_sjlj-1.dll "C:\Program Files (x86)\GNU\GnuPG\pub\libstdc++-6.dll" > boot_embedded_files.c
and then rerunning make to allow it to build the rest. But this approach is not guaranteed to work.
However, the package seems to be being maintained, with the changelog for the most recent version here:
http://cpansearch.perl.org/src/RSCHUPP/PAR-Packer-1.020/ChangeLog
and evidence from the bug tracker that some issues are being resolved:
https://rt.cpan.org/Public/Dist/Display.html?Status=Resolved;Name=PAR-Packer
I suggest you report this bug there, and see whether the maintainers are able to provide a fix.

make: *** No rule to make target `main.o'

here is the output from the console in Eclipse:
**** Build of configuration Debug for project FatFstest ****
make all
make: *** No rule to make target `main.o', needed by `FatFstest.elf'. Stop.
I am trying to build a project using the AVR plugin for Eclipse to test the FatFs library. I first imported the FatFs code then created main.c file to implement it. After I tried building it the first time, I added the src folder of my project to my the directories list in Properties > AVR Compiler > Directories, and I still get the build error. Any help?
Here is my makefile:
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include src/subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(ASM_DEPS)),)
-include $(ASM_DEPS)
endif
ifneq ($(strip $(S_DEPS)),)
-include $(S_DEPS)
endif
ifneq ($(strip $(S_UPPER_DEPS)),)
-include $(S_UPPER_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
LSS += \
FatFstest.lss \
SIZEDUMMY += \
sizedummy \
AVRDUDEDUMMY += \
avrdudedummy \
# All Target
all: FatFstest.elf secondary-outputs
# Tool invocations
FatFstest.elf: $(OBJS) $(USER_OBJS)
#echo 'Building target: $#'
#echo 'Invoking: AVR C Linker'
avr-gcc -Wl,-Map,FatFstest.map -mmcu=atmega328p -o"FatFstest.elf" $(OBJS) $(USER_OBJS) $(LIBS)
#echo 'Finished building target: $#'
#echo ' '
FatFstest.lss: FatFstest.elf
#echo 'Invoking: AVR Create Extended Listing'
-avr-objdump -h -S FatFstest.elf >"FatFstest.lss"
#echo 'Finished building: $#'
#echo ' '
sizedummy: FatFstest.elf
#echo 'Invoking: Print Size'
-avr-size --format=avr --mcu=atmega328p FatFstest.elf
#echo 'Finished building: $#'
#echo ' '
avrdudedummy: FatFstest.elf
#echo 'Invoking: AVRDude'
/usr/local/CrossPack-AVR-20100115/bin/avrdude -pm328p -Uflash:w:FatFstest.hex:a
#echo 'Finished building: $#'
#echo ' '
# Other Targets
clean:
-$(RM) $(OBJS)$(C_DEPS)$(ASM_DEPS)$(ELFS)$(LSS)$(AVRDUDEDUMMY)$(S_DEPS)$(SIZEDUMMY)$(S_UPPER_DEPS) FatFstest.elf
-#echo ' '
secondary-outputs: $(LSS) $(SIZEDUMMY) $(AVRDUDEDUMMY)
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
main.c
#include <diskio.h>
#include <ff.h>
#include <stdio.h>
int main(void)
{
printf("hello world\n");
return 0;
}
subdir.mk
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../src/diskio.c \
../src/ff.c \
../src/main.c
OBJS += \
./src/diskio.o \
./src/ff.o \
./src/main.o
C_DEPS += \
./src/diskio.d \
./src/ff.d \
./src/main.d
# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.c
#echo 'Building file: $<'
#echo 'Invoking: AVR Compiler'
avr-gcc -I"/Users/nathannewcomb/Documents/Puzzles/FatFstest/src" -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=1000000UL -MMD -MP -MF"$(#:%.o=%.d)" -MT"$(#:%.o=%.d)" -c -o"$#" "$<"
#echo 'Finished building: $<'
#echo ' '
objects.mk
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
USER_OBJS :=
LIBS :=
sources.mk
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
O_SRCS :=
C_SRCS :=
S_UPPER_SRCS :=
S_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
OBJS :=
C_DEPS :=
ASM_DEPS :=
ELFS :=
LSS :=
AVRDUDEDUMMY :=
S_DEPS :=
SIZEDUMMY :=
S_UPPER_DEPS :=
# Every subdirectory with source files must be described here
SUBDIRS := \
src \
It happened to me too, simply moving main.cpp in an another folder.
I try to clean out the project, but the problem persist, so I have deleted Debug folder, re-compile and it works!
Don't put the main.c in a directory, put it at the top of its project
I added the src folder of my project to my the directories list in
Properties > AVR Compiler > Directories
Remove this /Users/nathannewcomb/Documents/Puzzles/FatFstest/src folder and try to compile again.
In the subdir.mk file, the line :
avr-gcc -I"/Users/nathannewcomb/Documents/Puzzles/FatFstest/src" -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=1000000UL -MMD -MP -MF"$(#:%.o=%.d)" -MT"$(#:%.o=%.d)" -c -o"$#" "$<"
should be become :
avr-gcc -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega328p -DF_CPU=1000000UL -MMD -MP -MF"$(#:%.o=%.d)" -MT"$(#:%.o=%.d)" -c -o"$#" "$<"
This src folder is already added in source.mk file :
# Every subdirectory with source files must be described here
SUBDIRS := \
src \
quoting eclipse - http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fconcepts%2Fcdt_c_makefile.htm
Q2. My Console view says No rule to make target 'X'.
make -k clean all
make: * No rule to make target 'clean'.
make: * No rule to make target 'all'.
By default, the make program looks for a file most commonly called "Makefile" or "makefile". If it cannot find such a file in the working directory, or if that file is empty or the file does not contain rules for the command line goals ("clean" and "all" in this case), it will normally fail with an error message similar to those shown.
If you already have a valid Makefile, you may need to change the working directory of your build. The default working directory for the build command is the project's root directory. You can change this by specifying an alternate Build Directory in the Make Project properties. Or, if your Makefile is named something else (eg. buildFile.mk), you can specify the name by setting the default Build command to make -f buildFile.mk.
If you do not have a valid Makefile, create a new file named Makefile in the root directory. You can then add the contents of the sample Makefile (above), and modify it as appropriate.

SCons: GCC Ignoring -c

I'm using a MinGW-based GCC cross-compiler to compile a project which uses SCons as its build system.
The Python is a native 2.6.2 version, not specifically compiled for MinGW (or Cygwin).
However, I am running into a problem with the build:
F:/pedigree/compilers/bin/i686-elf-gcc -o build\src\user\applications\apptest\ma
in.obj -c -std=gnu99 -march=i486 -fno-builtin -m32 -g0 -O3 -Wno-long-long -Wnest
ed-externs -Wall -Wextra -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-long-
long -Wno-variadic-macros -Wno-unused -Wno-unused-variable -Wno-conversion -Wno-
format -Wno-empty-body -fno-stack-protector -DTHREADS -DDEBUGGER -DDEBUGGER_QWER
TY -DSERIAL_IS_FILE -DECHO_CONSOLE_TO_SERIAL -DKERNEL_NEEDS_ADDRESS_SPACE_SWITCH
-DADDITIONAL_CHECKS -DBITS_32 -DKERNEL_STANDALONE -DVERBOSE_LINKER -DX86 -DX86_
COMMON -DLITTLE_ENDIAN -D__UD_STANDALONE__ -DINSTALLER -Isrc\subsys\posix\includ
e -Ibuild\src\user\applications\apptest -Isrc\user\applications\apptest src\user
\applications\apptest\main.c
f:/pedigree/compilers/bin/../lib/gcc/i686-elf/4.4.1/../../../../i686-elf/bin/ld.
exe: crt0.o: No such file: No such file or directory
If I add -c to the CFLAGS, I get a compiled object called "main.obj -c" (there's a space between obj and -c there).
Does anyone have any idea what's happening? Is there anything I can do to solve this?
The project uses the POSIX platform to enforce progarm and object file extensions, however the POSIX platform in SCons defines a function "escape":
def escape(arg):
"escape shell special characters"
slash = '\\'
special = '"$()'
arg = string.replace(arg, slash, slash+slash)
for c in special:
arg = string.replace(arg, c, slash+c)
return '"' + arg + '"'
When it escapes the backslashes, it wreaks havoc in the Windows environment. Changing to a neutral platform, and specifying the extensions explicitly, fixes the problem.

How to write a Makefile rule to download a file only if it is missing?

I'm trying to write a Makefile which should download some sources if and only if they are missing.
Something like:
hello: hello.c
gcc -o hello hello.c
hello.c:
wget -O hello.c http://example.org/hello.c
But of course this causes hello.c to be downloaded every time make command is run. I would like hello.c to be downloaded by this Makefile only if it is missing. Is this possible with GNU make and how to do this if it is?
My guess is that wget doesn't update the timestamp on hello.c, but retains the remote timestamp. This causes make to believe that hello.c is old and attempts to download it again. Try
hello.c:
wget ...
touch $#
EDIT: The -N option to wget will prevent wget from downloading anything unless the remote file is newer (but it'll still check the timestamp of the remote file, of course.)
Since the Makefile should be working as you want, you need to check a few unlikely cases:
1) Check that you don't have any .PHONY rules mentioning the source file.
2) Check that the source target name matches the file path you are downloading.
You could also try running make -d to see why make thinks it needs to 're-build' the source file.
The Makefile you wrote downloads hello.c only if it's missing. Perhaps you are doing something else wrong? See for example:
hello: hello.c
gcc -o hello hello.c
hello.c:
echo 'int main() {}' > hello.c
And:
% make
echo 'int main() {}' > hello.c
gcc -o hello hello.c
% rm hello
% make
gcc -o hello hello.c
% rm hello*
% make
echo 'int main() {}' > hello.c
gcc -o hello hello.c
(the echo command was not executed the second time)
If the prerequisite for hello.c has changed or is empty and Make continues to download the file when it exists, then one option to prevent Make from re-downloading the file is to use a flag in the body of the target to detect if the file exists:
hello.c:
test -f $# || wget -O hello.c http://example.org/hello.c
The test command will return true if the hello.c file exists, otherwise it will return false and the wget command will run.