You need a generalized rule for how to get from a "source" file to an "object" file. If your source files carry the extension ".src" and your objects the extension ".obj" this would be:
Now you only need a special variable which contains only the file name which triggered the rule to use in the action part - and fortunately there is such a thing: "$<". A possible rule would look like:
If the rule is triggered by the file "foo.src" the command executed would be:
You might want to read the man page of the make-utility to learn more about the various special variables you can use. For instance, there is also a variable for the file name that will be the target of the rule: "$@".
C compilers per default write a file "a.out" instead of naming the object like the source file only with the extension replaced by ".obj". You would have to explicitly tell the compiler which name it should use for its output file with the "-o" option if you do not want this default behavior. This is what "$@" is for:
I am sure you will be able to adapt this to your needs with careful study of the man page.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT OPENSOLARIS
sip_clear_stale_data
sip_init_conn_object(3SIP) Session Initiation Protocol Library Functions sip_init_conn_object(3SIP)NAME
sip_init_conn_object, sip_clear_stale_data, sip_conn_destroyed - connection object related functions
SYNOPSIS
cc [ flag ... ] file ... -lsip [ library ... ]
#include <sip.h>
int sip_init_conn_object(sip_conn_object_t obj);
void sip_clear_stale_data(sip_conn_object_t obj);
void sip_conn_destroyed(sip_conn_object_t obj);
DESCRIPTION
The sip_init_conn_object() function initializes the connection object obj for use by the stack. The first member of the connection object
(a void *) is used by the stack to store connection object specific stack-private data.
The sip_clear_stale_data() function is used to clear any stack-private data in the connection object obj.
The sip_conn_destroyed() function is used to intimate the stack of the pending destruction of the connection object obj. The stack clean up
any stack-private data in obj and also removes obj from any caches the stack maintains.
RETURN VALUES
The sip_init_conn_object() function returns 0 on success and the appropriate error value on failure.
The value of errno is not changed by these calls in the event of an error.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO libsip(3LIB)SunOS 5.11 25 Jan 2007 sip_init_conn_object(3SIP)