Sponsored Content
Top Forums Programming Makefile for more than 1 executable program Post 302386930 by pludi on Thursday 14th of January 2010 05:30:27 AM
Old 01-14-2010
Assuming you're using GNU make:
Code:
SRC=blah1.c blah2.c blah3.c
HDR=$(SRC:.c=.h)
OBJ=$(SRC:.c=.o)

PROG=$(SRC:.c=)

all: $(PROG)

$(PROG): $(OBJ)
        gcc -Wall -ggdb -o $@ $@.o

.c.o: $(SRC) $(HDR)
        gcc -Wall -ggdb -c $<

clean:
        rm -f $(PROG) $(OBJ)

Adjust the compile options as needed.
 

10 More Discussions You Might Find Interesting

1. Programming

launch an executable from a C++ program

Hi everybody! Could you please tell me how can I launch an executable from a C++ (on unix) program? thanks in advance! (2 Replies)
Discussion started by: nadiamihu
2 Replies

2. Programming

problem in creating executable for a client program

Hi, I am trying to run simple client server c program in unix.At the compling stage server is creating an executable but the client is not. below is the link to the source codes: http://www.cs.rpi.edu/courses/sysprog/sockets/server.c http://www.cs.rpi.edu/courses/sysprog/sockets/client.c ... (2 Replies)
Discussion started by: konas
2 Replies

3. Programming

Client and Server program gen by Makefile

I created a "ebanking.x" file and run it as " rpcgen -a ebaning.x" It gen a few of files to me which is - "ebanking.h", "ebanking_server.c", "ebanking_svc.c", "ebanking_client.c", "ebanking_clnt.c", "ebanking_xdr.c" and "Makefile" The content of "ebanking.x" : struct bankargs { ... (0 Replies)
Discussion started by: wongalan48
0 Replies

4. Programming

Makefile compilation Error -Unable to create executable

Hi , While trying to compile a PRO*C code on unix using makefile i get the following errors. i am now working on a 10g migration (from 8i) ... these makefile perfectly work in previous version. ld: fatal: file... (7 Replies)
Discussion started by: sivalives
7 Replies

5. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

6. Programming

how to call c executable inside c program??

hi guys i have only basic knowledge of c so guys plz help me ..... i want 2 call c executable which requires file name as argument and i need to modify file contents before calling that executable now my question is how can i call this c executable inside another c program with arguments ?? i... (9 Replies)
Discussion started by: zedex
9 Replies

7. Programming

Call a C programming executable inside a C program

hi guys i have only basic knowledge of C so guys plz help me ..... is C language support call the C executable inside the C ?? example contect mainA.c have a many function define in the struct,when i compile mainA and make a executable the name is ( A ),can i use executable C inside the C... (5 Replies)
Discussion started by: isnoname
5 Replies

8. Shell Programming and Scripting

To see if a program exist and is executable

Hi, I am making a program that needs to detect if the program name in parameter is a valid runable program. But the line if ; then never seem to work. Even if I run like: ./script cat "-u" cat "-u" inputfile Thank you everyone. #!/bin/bash # usage() { #print usage message and quit... (4 Replies)
Discussion started by: leonmerc
4 Replies

9. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

10. AIX

Error when run makefile to compile C program

I have a make file for C program, which always gives the error ld: 0711-738 ERROR: Input file ../src/file_name.o XCOFF32 object files are not allowed in 64 mode Does anybody know the problem? Thanks for contribution (2 Replies)
Discussion started by: digioleg54
2 Replies
MAKE(1) 						      General Commands Manual							   MAKE(1)

NAME
make - maintain program groups SYNOPSIS
make [ -f makefile ] [ option ] ... file ... DESCRIPTION
Make executes commands in makefile to update one or more target names. Name is typically a program. If no -f option is present, `make- file' and `Makefile' are tried in order. If makefile is `-', the standard input is taken. More than one -f option may appear Make updates a target if it depends on prerequisite files that have been modified since the target was last modified, or if the target does not exist. Makefile contains a sequence of entries that specify dependencies. The first line of an entry is a blank-separated list of targets, then a colon, then a list of prerequisite files. Text following a semicolon, and all following lines that begin with a tab, are shell commands to be executed to update the target. Sharp and newline surround comments. The following makefile says that `pgm' depends on two files `a.o' and `b.o', and that they in turn depend on `.c' files and a common file `incl'. pgm: a.o b.o cc a.o b.o -lm -o pgm a.o: incl a.c cc -c a.c b.o: incl b.c cc -c b.c Makefile entries of the form string1 = string2 are macro definitions. Subsequent appearances of $(string1) are replaced by string2. If string1 is a single character, the parentheses are optional. Make infers prerequisites for files for which makefile gives no construction commands. For example, a `.c' file may be inferred as prereq- uisite for a `.o' file and be compiled to produce the `.o' file. Thus the preceding example can be done more briefly: pgm: a.o b.o cc a.o b.o -lm -o pgm a.o b.o: incl Prerequisites are inferred according to selected suffixes listed as the `prerequisites' for the special name `.SUFFIXES'; multiple lists accumulate; an empty list clears what came before. Order is significant; the first possible name for which both a file and a rule as described in the next paragraph exist is inferred. The default list is .SUFFIXES: .out .o .c .e .r .f .y .l .s The rule to create a file with suffix s2 that depends on a similarly named file with suffix s1 is specified as an entry for the `target' s1s2. In such an entry, the special macro $* stands for the target name with suffix deleted, $@ for the full target name, $< for the com- plete list of prerequisites, and $? for the list of prerequisites that are out of date. For example, a rule for making optimized `.o' files from `.c' files is .c.o: ; cc -c -O -o $@ $*.c Certain macros are used by the default inference rules to communicate optional arguments to any resulting compilations. In particular, `CFLAGS' is used for cc and f77(1) options, `LFLAGS' and `YFLAGS' for lex and yacc(1) options. Command lines are executed one at a time, each by its own shell. A line is printed when it is executed unless the special target `.SILENT' is in makefile, or the first character of the command is `@'. Commands returning nonzero status (see intro(1)) cause make to terminate unless the special target `.IGNORE' is in makefile or the command begins with <tab><hyphen>. Interrupt and quit cause the target to be deleted unless the target depends on the special name `.PRECIOUS'. Other options: -i Equivalent to the special entry `.IGNORE:'. -k When a command returns nonzero status, abandon work on the current entry, but continue on branches that do not depend on the current entry. -n Trace and print, but do not execute the commands needed to update the targets. -t Touch, i.e. update the modified date of targets, without executing any commands. -r Equivalent to an initial special entry `.SUFFIXES:' with no list. -s Equivalent to the special entry `.SILENT:'. FILES
makefile, Makefile SEE ALSO
sh(1), touch(1) S. I. Feldman Make - A Program for Maintaining Computer Programs BUGS
Some commands return nonzero status inappropriately. Use -i to overcome the difficulty. Commands that are directly executed by the shell, notably cd(1), are ineffectual across newlines in make. MAKE(1)
All times are GMT -4. The time now is 08:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy