Sponsored Content
Top Forums Shell Programming and Scripting Question in creating targets in makefile Post 302843976 by Anand Venkatesa on Friday 16th of August 2013 02:09:51 AM
Old 08-16-2013
Question Question about creating targets in makefile

Hi,

I have a question related to makefile. I'm new to makefile and I'm in the process of writing a makefile for my RBT build. I have multiple source files and when I compile them I will get multiple object files (one object file for each source file). I'm having problem in creating a target for each object file with out hardcoding the object file names. I read the list of source file names from another make file. Assume the variable SRC_NAMES contains list of source file names (say test1.c test2.c test3.c). Now I want to create target for each objects for it (say test1.obj test2.obj test3.obj). Currently I have written some thing like below,

Code:
 
#############################################
OBJS_LIST := $(foreach file,$(SRC_NAMES),$(notdir ${file}))
OBJS_LIST := $(DSP_COMMON_OBJ_LIST:.c=.obj)
 
all: final.exe
 
final.exe: $(OBJS_LIST)
   create exe here
 
$(OBJS_LIST): $(SRC_NAMES)
    compile and generate object file for each source files here.
 
#############################################

This is not working. Since OBJS_LIST contains many object names, compilation action is repeated for many times for the target $(OBJS_LIST). My question is how to split the obj target into multiple targets without hard-coding the target obj names?

Thanks,
Anand

Last edited by Anand Venkatesa; 08-16-2013 at 03:46 AM.. Reason: Trivial Change in Title
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Creating new system Makefile template

I am attempting to set-up a Makefile to use for a new system on a Sun Unix machine. I am new to creating Makefiles. I am trying to start simply by compiling a program. I am getting the following error message but an uncertain what 'Error Code 1' is. Is there a web site with Error Codes... (1 Reply)
Discussion started by: CaptainRo
1 Replies

2. UNIX for Dummies Questions & Answers

Makefile question

I'm trying to do string replacement with a Makefile and this is my scenario: Inside file "fileA", I have "#include<text>" statements and I want to replace it with the text inside a file called "params". I wish to perform this task using Makefiles. I've tried using m4 but that only works if... (1 Reply)
Discussion started by: hc29
1 Replies

3. Programming

Tough makefile question

At my company, we build some stuff using a makefile. While the makefile script is running, a developer may check in a newer version of a source file. The problem is, when we next run the make command, the target file isn't rebuilt, because the date of the target is after the dependency. Any... (1 Reply)
Discussion started by: mbbeaubi
1 Replies

4. UNIX for Dummies Questions & Answers

makefile Q about targets $@

Hi All I need to parse the target something like: ifeq '$@' 'first' echo 1 $@ endif ifeq '$@' 'second' echo 2 $@ endif The thing is to be able compare the target string to any string and then do the commands Thanks a lot ziv (0 Replies)
Discussion started by: zivsegal
0 Replies

5. Shell Programming and Scripting

Makefile question

Hi all, I've a makefile which has this line: @touch $@ I know $@ is for representing the target. But I don't know what's the @ preceding the touch. Can anyone help me? Thanks in advance. (4 Replies)
Discussion started by: mjdousti
4 Replies

6. UNIX for Dummies Questions & Answers

makefile Question

Hello, I'm trying to use the make command with a makefile I've made for an assignment. The professor supplied the code and I've copied it into a new file. I made sure to place the tabs in the correct spaces, however when I try to execute it in UNIX I get: "make: Fatal error in reader:... (5 Replies)
Discussion started by: Shinra1003
5 Replies

7. AIX

makefile question

Hi all, In a makefile I would like to grab the first line of a given parameter file using ‘head' and assign it to a variable, how do I do this? I've got a simple makefile but it does not work? #! /bin/ksh ... .sqc.c: db2prep $*.sqc bindfile if ] DB2_PARM=`/usr/bin/head -1 $*.prm`; fi... (2 Replies)
Discussion started by: apersak
2 Replies

8. UNIX for Advanced & Expert Users

Help in creating a makefile

Hi, I wanted to know whether there is any way to specify in a makefile how to compile sources from a directory directly by giving the directory path name instead of mentioning each and every source file name. Regards, Anil (1 Reply)
Discussion started by: anil_lami
1 Replies

9. UNIX for Advanced & Expert Users

makefile head-scratcher: multiple targets in one go

Hi! I've got a build process where scripts create multiple targets from their sources. But here I'm running into a conceptual problem of GNU make: If one has multiple targets in a dependency, make applies the rules once for every target that is out of sync - which is correct for normal... (3 Replies)
Discussion started by: treczoks
3 Replies

10. Programming

Problem creating a makefile

hello, I'm trying to create a makefile to run multiple c files. I am able to run one c file only with the code I have when I tried to run 2 or more c files I'm not able. here is my code # $Source: /home/hectormasencio/make/Makefile,v $ # $Date: 2012/11/27 11:35:30 $ CC= gcc OBJS= temp.o... (3 Replies)
Discussion started by: Hector M.
3 Replies
Paranoid::Glob(3pm)					User Contributed Perl Documentation				       Paranoid::Glob(3pm)

NAME
Paranoid::Glob - Paranoid Glob objects VERSION
$Id: Glob.pm,v 0.2 2010/04/21 09:07:30 acorliss Exp $ SYNOPSIS
$obj = Paranoid::Glob->new( globs => [ qw(/lib/* /sbin/* /etc/foo.conf) ], literals => [ qw(/tmp/{sadssde-asdfak}) ], ); print "Expanded globs: ", join(" ", @$obj); $rv = $obj->addGlobs(qw(/etc/* /bin/*)); $rv = $obj->addLiterals(qw(/etc/foo.conf)); $obj->consolidate; @existing = $obj->exists; @readable = $obj->readable; @writable = $obj->writable; @executable = $obj->executable; @owned = $obj->owned; @directories = $obj->directories; @files = $obj->files; @symlinks = $obj->symlinks; @pipes = $obj->pipes; @sockets = $obj->sockets; @blockDevs = $obj->blockDevs; @charDevs = $obj->charDevs; $obj->recurse(1, 1); DESCRIPTION
The primary purpose of these objects is to allow an easy way to detaint a list of files and/or directories while performing shell expansion of names. It does this with a caveat, however. If a given file or directory name exists on the file system as a literal string (regardless of whether it has shell expansion characters in it) it will be added as such. It is only filtered through bsd_glob if it does not exist on the file system. The objects can also be created with instructions to explicitly treat all names as literal strings. Any undef or zero-length strings passed in the files array are silently removed. As a convenience subsets of the expanded files can be returned based on the common stat/lstat tests. Please note the obvious caveats, however: asking for a list of directories will fail to list directories if the effective user does not have privileges to read the parent directory, etc. This is no different than performing '-d', etc., directly. If you care about privilege/permission issues you shouldn't use these methods. An additional method (recurse) falls outside of what a globbing construct should do, but it seemed too useful to leave out. SUBROUTINES
/METHODS new $obj = Paranoid::Glob->new( globs => [ qw(/lib/* /sbin/* /etc/foo.conf) ], literals => [ qw(/tmp/{sadssde-asdfak}) ], ); This class method creates a Paranoid::Glob object. It can be constructed with optional literal strings and/or globs to expand. All are filtered through a [[:print:]] regex for detainting. Any undefined or zero-length strings are silently removed from the arrays. The object reference is a blessed array reference, which is populated with the expanded (or literal) globs, making it easy to iterate over the final list. If any entry in the globs array fails to detaint this method will return undef instead of an object reference. addGlobs $rv = $obj->addGlobs(qw(/etc/* /bin/*)); Adds more globs to the object that are detainted and filtered through bsd_glob. Returns false if any strings fail to detaint. All undefined or zero-length strings are silently removed. addLiterals $rv = $obj->addLiterals(qw(/etc/foo.conf)); Adds more literal strings to the object that are detainted. Returns false if any strings fail to detaint. All undefined or zero-length strings are silently removed. consolidate $obj->consolidate; This method removes redundant entries and lexically sorts the contents of the glob. exists @existing = $obj->exists; This object method returns a list of all entries that currently exist on the filesystem. In the case of a symlink that exists but links to a nonexistent file it returns the symlink as well. readable @readable = $obj->readable; This method returns a list of all entries that are currently readable by the effective user. In the case of a symlink it returns the symlink only if the target of the symlink is readable, just as a normal stat or -r function would. writable @writable = $obj->writable; This method returns a list of all entries that are currently writable by the effective user. In the case of a symlink it returns the symlink only if the target of the symlink is writable, just as a normal stat or -w function would. executable @executable = $obj->executable; This method returns a list of all entries that are currently executable by the effective user. In the case of a symlink it returns the symlink only if the target of the symlink is executable, just as a normal stat or -x function would. owned @owned = $obj->owned; This method returns a list of all entries that are currently owned by the effective user. In the case of a symlink it returns the symlink only if the target of the symlink is owned, just as a normal stat or -o function would. directories @directories = $obj->directories; This method returns a list of all the directories. In the case of a symlink it returns the symlink if the target of the symlink is a directory, just as a normal stat or -d function would. files @files = $obj->files; This method returns a list of all the files. In the case of a symlink it returns the symlink if the target of the symlink is a file, just as a normal stat or -f function would. symlinks @symlinks = $obj->symlinks; This method returns a list of all the symlinks. pipes @pipes = $obj->pipes; This method returns a list of all the pipes. In the case of a symlink it returns the symlink if the target of the symlink is a pipe, just as a normal stat or -p function would. sockets @sockets = $obj->sockets; This method returns a list of all the sockets. In the case of a symlink it returns the symlink if the target of the symlink is a socket, just as a normal stat or -S function would. blockDevs @blockDevs = $obj->blockDevs; This method returns a list of all the block device nodes. In the case of a symlink it returns the symlink if the target of the symlink is a block device node, just as a normal stat or -b function would. charDevs @charDevs = $obj->charDevs; This method returns a list of all the character device nodes. In the case of a symlink it returns the symlink if the target of the symlink is a character device node, just as a normal stat or -c function would. recurse $obj->recurse; $obj->recurse(1); $obj->recurse(1, 1); This method with recursively load all filesystem entries underneath any directories already listed in the object. It returns true upon completion, or false if any errors occured (such as Permission Denied). Two optional boolean arguments can be passed to it: Option1: Follow Symlinks Option2: Include "Hidden" directories Both options are false by default. If Option1 (Follow Symlinks) is true any symlinks pointing to directories will be recursed into as well. Option2 in its default false setting excludes dot files or directories just as normal shell expansion would. Setting it to true causes it to include (and recurse into) hidden files and directories. DEPENDENCIES
o Carp o Errno o Fcntl o File::Glob o Paranoid o Paranoid::Debug BUGS AND LIMITATIONS
AUTHOR
Arthur Corliss (corliss@digitalmages.com) LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. (c) 2009, Arthur Corliss (corliss@digitalmages.com) perl v5.14.2 2010-05-03 Paranoid::Glob(3pm)
All times are GMT -4. The time now is 10:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy