oasis@watson.ibm.com (GA.Hoffman) (06/14/91)
I just received a bunch of c++ files with suffix .cc, CC wants .C or some such ... is there conventional wisdom on handling this in makefiles? I'm currently making a link during the compile, file by file to a file with the desired suffix. thx, g -- gary a hoffman RISC Systems, Watson Research
steve@taumet.com (Stephen Clamage) (06/14/91)
garvey@johnny5.uucp (Joe Garvey) writes: >It seems there are different convensions for naming programs. >GNU's libg++ has *.hP and *.ccP extensions. ------------- oasis@watson.ibm.com (GA.Hoffman) writes: >I just received a bunch of c++ files with suffix .cc, >CC wants .C or some such ... is there conventional wisdom >on handling this in makefiles? I'm currently making a >link during the compile, file by file to a file with the >desired suffix. ------------- There are no real standards in this area. Different compilers allow or require different sorts of file name endings. Some people want to have different endings to distinguish C from C++ files so that makefiles can invoke the right compiler. When I need to use source files with different compilers requiring different endings, I just rename the files. (They are usually on different machines anyway.) If you want to run the same files through different compilers on the same machine, makeing links is not a bad way to handle it, provided you do it with attention to some details. Editing a file or replacing it via SCCS or RCS will often break the link, leaving two different files which are supposed to be the same file. Symbolic links solve that problem if your system supports them. You can also create rules in your makefile to handle the naming problems. You can use different file endings to call on different compilers, and create a temporary link to satisfy a compiler's requirements. -- Steve Clamage, TauMetric Corp, steve@taumet.com
masa@hpsciz.sc.hp.com (Masayoshi Habu) (06/14/91)
In comp.lang.c++, oasis@watson.ibm.com (GA.Hoffman) writes:
I just received a bunch of c++ files with suffix .cc,
CC wants .C or some such ... is there conventional wisdom
on handling this in makefiles? I'm currently making a
link during the compile, file by file to a file with the
desired suffix.
Just an idea. How about this ?
.SUFFIXES: $(SUFFIXES) .cc
.cc.C:
mv $*.cc $*.C
.C.o:
$(CXX) -c $(CXXFLAGS) $<
Masa
warsaw@nlm.nih.gov (Barry A. Warsaw) (06/15/91)
>>>>> "Gary" == GA.Hoffman <oasis@watson.ibm.com> writes:
Gary> I just received a bunch of c++ files with suffix .cc, CC
Gary> wants .C or some such ... is there conventional wisdom on
Gary> handling this in makefiles? I'm currently making a link
Gary> during the compile, file by file to a file with the desired
Gary> suffix.
Below is an extract from my Makefile's. Using this, it's relatively
simple to change to any suffix just by mv'ing the files and changing
the $(C) macro in the makefiles.
C= .cc
# I have files file1.cc, etc or file1.C, etc.
SOURCES = file1$(C) file2$(C) file3$(C) ...
# this is a SunOS 4.x make-ism
OBJECTS = $(SOURCES:%$(C)=%.o)
# rule to convert any $(C) c++ source file into a .o object file
$(C).o:
$(CC) $(OTHER_USEFUL_FLAGS) -c $<
$(PROGRAM): $(OBJECTS)
$(CC) $(USEFUL_LD_SWITCHES) $(OBJECTS) -o $(PROGRAM)
-Barry
NAME: Barry A. Warsaw INET: warsaw@nlm.nih.gov
TELE: (301) 496-1936 UUCP: uunet!nlm.nih.gov!warsaw