Programming :: Makefile Index Of List Element?
Apr 5, 2011
So I have been trying for 8 hours to try to get the index of an element from a list in a Makefile. The problem is that after I get the index using all the methods I have tried, the index cant be used in the "word" function:
for instance:
$(OUTPUT2) : INDEX = $(shell echo $(OUTPUT2) | sed -r -e "s/[ ]+/
/g" | grep -n $@ | sed 's/^([0-9]*):.*/1/')
will create a variable INDEX defined specifically for each member of OUTPUT2, so that each output knows its index. Unfortunately, when I pass this $(INDEX) into word, it doesn't work:
$(OUTPUT2) : $(word $(INDEX), $(INPUT1)) $(word $(INDEX), $(INPUT2))
echo $(INAME) $(TMPBASE) $@
and I get the error:
Makefile:16: *** non-numeric first argument to `word' function: 'num'. Stop.
I feel like if I could just convert a string to a Makefile acceptable number this would just work....
View 6 Replies
ADVERTISEMENT
Feb 9, 2011
I'm trying to make a very small script with greasemonkey to do some automatic things when a page loads. The first thing I need to do is to click on a link. I've done that. Then I need to select the 3rd element of a drop down list that appears a few moments (depending on the connection) after the link is pressed, without reloading the page (ajax or something like that). This I can't get to work, The select has no id or class, but I can get its xpath value. There is only one select on the page. I've tried both setTimeOut and the DOMNodeInserted event with no effect.
Code:
// ==UserScript==
// @name test
// @namespace "www.google.com"
// @include www.mywebpage.com
// ==/UserScript==
[Code]....
View 11 Replies
View Related
Feb 18, 2011
Having a bit of an issue with Python while trying to write a script to download every rar file on a webpage. The script successfully downloads any link that doesn't contain any spaces, etc. But when it hits a url like: [URL] (Classical Spelling).rar. It fails...I'm sure this is something simple, but I'm so new to python I'm not sure what to do!
Code:
import urllib2
import os
os.system("curl [URL] -i rar|cut -d '"' -f 2 > temp.out ")
infile =open('temp.out', 'r')
for url in infile:
print url
#url = "[URL]"
#url = target
file_name = url.split('/')[-1]
u = urllib2.urlopen(url)
f = open(file_name, 'w')
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
print "Downloading: %s Bytes: %s" % (file_name, file_size)
file_size_dl = 0
block_sz = 8192
while True:
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += block_sz
f.write(buffer)
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status = status + chr(8)*(len(status)+1)
print status,
f.close()
View 7 Replies
View Related
Mar 27, 2010
I wonder why arrays in the C programming language are pointers to the first element of the array, not the first element of the array itself?
View 14 Replies
View Related
May 10, 2010
Exist it a perl function to count how much each array element is into array?
View 14 Replies
View Related
Jul 19, 2011
I'm trying to create an array with variable including hyphenbut ksh refuses the first element
set -A allArgs
set +A allArgs ${allArgs[@]} -all
set +A allArgs ${allArgs[@]} -date
[code]...
View 5 Replies
View Related
Jun 23, 2010
I changed my post because I found that solution, and didn't want to bother for that. But, since I didnt find a way to delete the post, I thought of updating it: I am beginning to write the code for the philosophers problem. As you know, they can eat, think or wait for forks. When they have 2 forks, one by each side, they eat. Then they set the 2 forks as available, and think.
Each philosopher is a thread. My problem is that it gives segmentation fault, somehow, when I try to initialize. The thing I really don't understand, is why it sometimes gives segmentation fault on initialization #0!!! (But generally on initialization #1) I have set 5 initializations in total, defined by N, that is also the number of threads I'm working on.
PHP Code: #include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<pthread.h>
#include<errno.h>
#include <time.h>
#define N 5
[Code]....
View 1 Replies
View Related
Aug 21, 2010
it's been a while since I logged on here! I've been trying my hand at a little perl and have hit a brick wall.I'm using the Imagemagick module to manipulate some images. I can get the following to work without issue:
Code:
$teampath = "/var/www/team1";
$player=Image::Magick->new;
[code]...
View 1 Replies
View Related
Jul 22, 2011
I'm reading "OReilly Learning Perl 5th Edition", and there are such words:Code:You can use an array element like $fred[2] in every place? where you could use any other scalavariable like $fred.At the bottom of the page, it explains the ? like this:Code:The most notable exception is that the control variable of a foreach loop, which you?ll see later in this chapter, must be a simple scalar.Since Perl has the save-and-restore mechanism for the control variable, why an array element can't be used as the control variable
View 1 Replies
View Related
Jul 26, 2010
I'm using libxml2 to handle/manipulate some XML files. In order to check the consistency of a XML file, I have a DTD and I'm using the xmlValidateDtd method to compute the check.
However, when an error occures during the check (for example an attribute is missing in a XML tag), then libxml2 writes the error on the stdout/stderr. For exemple:
Code:
/home/XML/FreeFour.xml:18: element CA: validity error : Element CA does not carry attribute maxlength
The method return the right result (true or false depending on the check result), but occurring errors are written on the stdout/stderr, and I actually don't want that.
View 4 Replies
View Related
May 31, 2010
I just downloaded slackware 13.1(x86) and i'm trying to compile ndiswrapper-1.56 using the slackbuild from slackbuils.org and i'm getting this error:
Code:
Makefile:535: /usr/src/linux-2.6.33.4/arch/i486/Makefile: No such file or directory
make[2]: *** No rule to make target `/usr/src/linux-2.6.33.4/arch/i486/Makefile'. Stop.
make[1]: *** [modules] Error 2
make: *** [all] Error 2
looks like the folder i486 doesn't exist
View 2 Replies
View Related
May 19, 2010
I have problems with linking object files.
This is what I get:
View 8 Replies
View Related
Jul 20, 2010
I want to define _LINUX in my makefile which I would be using in my source code like #if _Linux. I do not want to #define _Linux __linux__ in my source code.
View 2 Replies
View Related
Oct 8, 2010
at present I compile the same code for different systems (cross compilers)I need to call libs and include paths for the different processors. At present I simply comment out the paths not needed
eg
#INCDIR = -I/cross1/.......
#INCDIR = -I/cross2/.......
[code]....
View 2 Replies
View Related
Jun 6, 2011
I'm building an install CD from CentOS 5.6 and some custom packages using anaconda-11.1.2.224-1.el5 from the CentOS 5.6 repo.
splittree fails with
Traceback (most recent call last):
File "./splittree.py", line 481, in ?
logfile = timber.main()
File "./splittree.py", line 398, in main
[Code].....
View 1 Replies
View Related
Feb 25, 2009
I am a beginner in Linux. Never did any kernel programming in Linux/Windows before. I am now on a project and I am supposed to understand a Linux Device Driver Code. It contains 6 .c files and 1 Makefile.
The make file goes as this:
I have a.c b.c c.c d.c d.c e.c f.c in the director along with the Makefile mentioned.
I am using Fedora Red Hat Linux 32 bit.
How to compile the Makefile.
View 4 Replies
View Related
Mar 26, 2011
How to create a simple Makefile using C....
View 3 Replies
View Related
Dec 8, 2009
I'm trying to figure out how Make handles directories.
How can I modify this makefile so it will put all of the .o files in a separate build directory?
Code:
But make ignores this and still puts main.o in the base directory. And if I refer to the build directory in the dependencies for bandit, make complains about "no rule ..."
I want to keep main.cpp in the base directory, all other sources in the src directory, and all object files in the build directory.
View 14 Replies
View Related
Jan 6, 2010
When I put a "test" target in my Makefile containing
Code:
@echo "CXX= $(CXX)"
it tells me "CXX= g++".
But I have nothing in the Makefile assigning any value to CXX, and as far as I can tell I have no CXX environment variable (no "CXX" appears when I run the shell command "env", and "echo $CXX" returns a blank line. So where's the g++ value coming from. Is this just built into Gnu Make, or is there a configuration file for make somewhere?
View 2 Replies
View Related
Jan 26, 2010
I'm trying to compile a program and it gives me the following:
I checked cmath-util.h:46 and cmath-util.h:48:
I'm not a C person, and the author is unavailable so far.
View 5 Replies
View Related
Apr 5, 2010
I am trying to run a script to setup environment variables and then run other commands in a make file. But the source or the dot operator (shell is bash) does not seem to take any effect as the subsequent command didn't pick the environment up. Do I have to put every lines of the environment setup in the first script into the makefile instead?
sample setenv.sh
#!/bin/sh
export MYDIR=/somedir
sample makefile:
all: source ./setenv.sh
echo $(MYDIR)
View 5 Replies
View Related
Nov 25, 2010
I'm learning about how to write Makefiles, and am a bit lost at how to run a command in a target depending on the value of a variable.
What I'm trying to do, is run "strip" only if the user is running a given version of a C compiler.
Here's the code:
Code:
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
#FDPIC ELF binaries can be stripped, but not FLAT binaries
$(if($(CROSS),bfin-linux-uclibc-),
$(STRIP) $@
;)
Does someone know the correct way to do this?
View 2 Replies
View Related
Jun 25, 2011
I am new to automake. When running automake command, there is an error "cannot open > py/Makefile.in: No such file or directory". How to create that file? And, what is that file for?
View 1 Replies
View Related
Apr 10, 2011
If I would normal compile using the following line:
Code:
Where should those library flags go in a makefile? Say I having the following makefile:
Code:
all: ${PROGS}
clean:
View 8 Replies
View Related
Oct 4, 2010
I am trying to use a software package written in ANSI C. It has a makefile which has to be executed first.
As soon as I execute it I get messages like: line i: command not found.
Commands for which I am getting errors :
CC = /usr/bin/gcc
GCCFLAGS = -c -Wall
ROOTDIR = .
My gcc compiler is located in the above directory only. In ROOTDIR also I tried giving the path in which all the required files & folders are present but still I get the command not found error in all the lines.
View 7 Replies
View Related
Apr 26, 2010
I created a quick makefile with the following lines:
Code:
$(BINARY):
echo "----- Linking $(BINARY)----"
gcc -m32 -g src/* -Iinclude -I$(HOME)/include -I$(HOME)/include2 -D_LINUX -DSYSV -DPOSIX -L$(HOME)/shared/lib32 -lidlib -lid2lib -o bin/sampleapp
echo "---- done ----"
It builds fine when I build from the command line ( make -f sample.mk).
However, it does not build when building from eclipse (which essentially calling the same makefile). The make output shows exactly the same as what I got from the command line build, except the last line showing
Code:
collect2: cannot find 'ld'
make: *** [sampleapp] Error 1
I am not sure why it tries to call "ld" when building from eclipse.
View 6 Replies
View Related
Jun 19, 2010
I'd like to write a Makefile for my CUDA/C++ code but I didn't know how things work with CUDA, I mean there is a nvcc compiler but I don't know what I've got to do with this.
Do I have to firstly run nvcc and then g++ or only nvcc to compile my CUDA/C++ code ? I found nothing on the web explaining such basic things .
View 1 Replies
View Related
Mar 13, 2009
im trying to write a makefile which contains :two cpp files and two header files. now i've put cppfiles in a folder called source whose path is: /root/workspace/source and header files in a folder called header whose path is:
/root/workspace/makedemo/header
my makefile is in the path:/root/workspace/makedemo my makefile was like this:
Code:
HEADERS = $(shell /root/workspace/makedemo/header ls *.h)
SOURCES = $(shell /root/workspace/source ls *.cpp)
COMPILERFLAGS = -W -Wall
DEBUGFLAGS = -g
[code].....
im sure that i've given the correct path but it is showing errors like this:
[root@localhost makedemo]# make
/bin/sh: /root/workspace/source: is a directory
/bin/sh: /root/workspace/source: is a directory
g++ -W -Wall -I. -o output
g++: no input files
make: *** [output] Error 1
View 4 Replies
View Related
May 17, 2011
I know how to manually writing a makefile for my project, but I am new in using makefile & configure file generation tools like automake to generate a makefile and a configure script file.
I had done research on tutorials for generating makefile and configure script file.
I know that I need to manually write two files (makefile.am and configure.in).
I use wxWidgets GUI library, libconfig library, and libpcap library to do my project.
wx-config is a tool that can return the library files and include directory for wxWidgets library.
When using g++ to compile my files, I need to add in this line "`/wxlib/bin/wx-config --version=2.9 --static=yes --unicode=yes --debug=yes --libs`"
How to add that line to the makefile.am file?
View 1 Replies
View Related
Jun 8, 2011
I'm trying to make recursive makefile work but it's giving me two problems. I have a top folder with the main Makefile and one Makefile for each sub folder 'one' and 'two'. Makefile in subfolder 'one' and 'two' are identical. The top Makefile (still a bit messy) looking like this:
Code:
# Directories
CC = gcc
CFLAGS = -Wall -Wextra
TARGET_DIR = bin
MAIN_FILE = one.c
[Code]...
View 4 Replies
View Related