Sponsored Content
Top Forums UNIX for Dummies Questions & Answers make and clean in a single rule in the makefile. Post 70159 by vino on Tuesday 26th of April 2005 01:01:03 PM
Old 04-26-2005
make and clean in a single rule in the makefile.

Hi,

This stems from the following thread https://www.unix.com/shell-programming-and-scripting/18299-makefile-not-taking-d-flags.html

I have a makefile which makes either executables or a shared library.
i.e. make -f unix.mak will create the executables and
make -f unix.mak libolsv will create the shared library.

Since these have to be made i.e both executable and the shared library, I need to make the executables and then a clean ( make -f unix.mak cleanobj) and then make the shared library.

But I want to avoid the intermediate step of make -f unix.mak clean; i.e. the user should not do it explicitly. Is there any way I can include it in the rule for the shared library.

This is what I have.

Code:
SO              = SvSocket.o SvStmt.o SvOdbcWrapper.o \
                  OdbcCallReader.o MgrCalls.o OdbcSvProxy.o

$(EXE1): $(EXE) $(O1)
        g++ $(CFLAGS) -o $(EXE1) $(O1)

$(EXE): $(O) *.h
        $(CC) -o $(EXE) $(O)

OdbcSvApp.o: OdbcSvApp.cpp
        $(CC) -DODBCSV_SO OdbcSvApp.cpp -c -o OdbcSvApp.o

$(DAEMON_SO): OdbcSvApp.o $(SO) *.h
        $(CC) -shared -export-dynamic -DODBCSV_SO -o $(DAEMON_SO) OdbcSvApp.o $(SO) 
        @echo $(DAEMON_SO) has been built.

cleanobj::
        -$(RM) *.o

This is what I have tried:
Code:
$(DAEMON_SO): OdbcSvApp.o $(SO) *.h
        -make -f unix.mak cleanobj
        $(CC) -shared -export-dynamic -DODBCSV_SO -o $(DAEMON_SO) OdbcSvApp.o $(SO)

and also this
Code:
$(DAEMON_SO): OdbcSvApp.o $(SO) *.h
        -$(RM) *.o
        $(CC) -shared -export-dynamic -DODBCSV_SO -o $(DAEMON_SO) OdbcSvApp.o $(SO)

and I get the following error in both the cases:

gcc: OdbcSvApp.o: No such file or directory
gcc: SvSocket.o: No such file or directory
gcc: SvStmt.o: No such file or directory
gcc: SvOdbcWrapper.o: No such file or directory
gcc: OdbcCallReader.o: No such file or directory
gcc: MgrCalls.o: No such file or directory
gcc: OdbcSvProxy.o: No such file or directory
make: *** [libolsv20.so] Error 1

So how do I get around this. I want to include the clean rule in $(DAEMON_SO)

Vino
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Clean file in single action

What one finds challenging another finds simple... (HPUX B.11.11) I have a text file named something like 12345.dst that could look like this: DOG CAT NONE TEST CAT What I want to end up with is 12345.dst looking like this: CAT DOG TEST removing "NONE" should it be there and... (1 Reply)
Discussion started by: djp
1 Replies

2. Shell Programming and Scripting

To make sure I don't violate rule #7

I am hoping to find out if it is possible to use some sort of UNIX programming/scripting tools to solve a problem I have with reformatting email messages that are sent out of my IBM UNIX (AIX) system. I'm thinking some advanced awk/sed may work I do not have the time or the ability to do this... (6 Replies)
Discussion started by: toddk
6 Replies

3. Shell Programming and Scripting

Makefile rule being skipped

I can't seem to get a rule in my Makefile to ever run... even if I change the rule to force make to re-enter the rule, or if I change the dependent files the rule depends on. Any ideas why the second rule is being ignored here? #MAKEFILES = $(DIRS:%=$(ROOT)/%/Makefile) #$(MAKEFILES):... (0 Replies)
Discussion started by: foureightyeast
0 Replies

4. Programming

A question about Makefile run by GNU make

Hello everybody, Currently I'm learning how to build projects (C programming) with GNU make. I have a problem with one Makefile and I would appreciate if you could kindly give me a hand. Here is the environment: OS: Redhat linux 5 compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)... (2 Replies)
Discussion started by: dariyoosh
2 Replies

5. Programming

Issue with make, no rule to make target etc.

I have been trying to split up my src directory to clear out files that are not re-compiled very often. Now I have the following setup in my trunk, trunk/bld trunk/src/ trunk/src/src_server trunk/makefile.linux In the make file, I have compile rules SOURCELOC = src # compile src c++... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

6. Shell Programming and Scripting

Need help with a script to make makefile

How do we create a shell script that creates a makefile? what if we want to use the #include header files too? (2 Replies)
Discussion started by: sslokhan
2 Replies

7. UNIX for Dummies Questions & Answers

Defining a new suffix rule in a Makefile

Hi everybody, I have a Makefile where a single suffix rule is defined: .SUFFIXES: .cpp .cpp.o: ${CXX} ${CXXFLAGS} -c -o $@ $< And I'd like to create another where an additional flag is added to compile in SMP. Right now, I have to do it like this: interface-smp.o:... (2 Replies)
Discussion started by: Zel2008
2 Replies

8. Programming

Makefile No rule to make target

I am trying to create a makefile to build a program and am getting the following error: make -f tsimplex.mk make: *** No rule to make target `/main/tsimplex_main.cpp', needed by `tsimplex_main.o'. Stop. OPSYS = $(shell uname -s ) TARGET = tsimplex ROOTDIR = ../../.. GTSDIR =... (1 Reply)
Discussion started by: kristinu
1 Replies

9. Shell Programming and Scripting

Default rule to be executed in makefile

Hi all, I want to know the entry point (default rule to be executed) in a makefile once all defined variables are evaluated. I do not have all: in my makefile and I give "make" without any parameter in command line. thanks........ (3 Replies)
Discussion started by: useless79
3 Replies

10. Solaris

SunOS 5.5.1 usage of Makefile command in make file

I am new to Solaris and compilation using make files. I have a code base which is organized into different folders. At the root folder is a master make file and in the sub directories, there are make files for that particular folder. In the make files present in subdirectories, I am seeing... (2 Replies)
Discussion started by: rajujayanthy
2 Replies
FORT77(1)						     Linux Programmer's Manual							 FORT77(1)

NAME
fort77 - invoke f2c Fortran translator transparently, like a compiler SYNOPSIS
fort77 [-c] [-g] [-v] [-k] [-P] [-cpp] [f2c option ...] [-L directory ...] [gcc-option ...] [link option ...] [-O optlevel] [-o out- file] [-s] [-w] [-Wx,arg1[,arg2]...] file ... DESCRIPTION
The fort77 script invokes the f2c command transparently, so it can be used like a real Fortran compiler. It can be used to compile For- tran, C and assembler code, and to link it with the f2c libraries. File arguments ending with .f are compiled as Fortran source files. Files which end with .P are passed through to f2c, and files ending with .F are passed to the C preprocessor (invoked as "/lib/cpp -traditional") first. Any switches passed via -D will be passed to the pre- processor. If the translation is successful, the resulting C files will be passed to cc for translation into an object file. Files ending in .c, .C, .cc, .i, .s, .S, .m, .cc or .cxx are passed to the GNU C compiler directly; see gcc(1). All other files are passed to the linker. OPTIONS
-c Supress linking and produce an object ( .o ) file from each source file. -g Include debugging information. -v Be verbose; supplying this twice will also tell the C compilers etc to be verbose. -k Keep the C files generated by f2c around. -cpp Pass Fortran code through the C preprocessor, as if filenames ended in .F. -P Generate f2c .P files. -Ldirectory Include directory in the search for libraries in the final linking stage. -o outfile Send output to outfile. -trapuv Have f2c generate code to trap uninitialized values. -Wx,arg1[,arg2...] Pass the argument[s] argi through to the subprocess x, where x can assume one of the following values: f for the f2c step, p for the preprocessing step, c for the C compiler, a for the assembler (this is actually passed to the C compiler, too), and l for the linker. As an example, defining a preprocessor constant for the C compilation step would be done with -Wc,-DUNIX=1. Specifying the -f option to f2c would be done via -Wf,-f. f2c option fort77 passes through almost all f2c options: -C, -U, -u, -a, -E, -h, -P, -R, -r, -z, -I2, -I4, -onetrip, -!c, -!l, -!P, -!R, -ext, -!bs, -W[n], -trapuv, -w8, -r8 and -w66. gcc options The following options are passed through to gcc: -f*, -W*, -U*, -A*, -m*, -S, -E, -v, -x, -pipe, -o, -I, -V, -b*, -p, -pg. linker option The options passed to the linking stage are -static, -shared, -v, -V, and -symbolic. BUGS
To make debugging work, you need to set a breakpoint at MAIN__ before you start. f2c This script automatically supplies the -I. option to f2c. Older versions of f2c may not support this. This script is for the interaction of gcc and f2c; using it with another compiler will probably require modification. The fort77 script does not strictly conform to Posix.2, because it acceppts long options with one leading slash. This is done for gcc com- patibility. SEE ALSO
f2c(1), cc(1), as(1), ld(1) AUTHOR
Thomas Koenig, ig25@rz.uni-karlsruhe.de Linux Nov 1996 FORT77(1)
All times are GMT -4. The time now is 11:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy