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++ objects
$(BDIR)/%.o: ${SOURCELOC}/%.cpp
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

# compile src c objects
$(BDIR)/%.o: ${SOURCELOC}/%.c
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

I just added,

# compile src server c++ objects
$(BDIR)/%.o: ${SOURCELOC}/src_server/%.cpp
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

# compile src c objects
$(BDIR)/%.o: ${SOURCELOC}/src_server/%.c
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

but I am getting a make error, *** No rule to make target `bldprinting2.o`

The file printing2.cpp is in src/src_server, but it won't seem to compile it from there. Under cygwin, adding these two compile lines to the exact same trunk works just fine, so I don't get what the difference is. I can post the entire make file if that would help.

The OS is Cent5.5 if anyone cares.

LMHmedchem

Well, either you did not make it, buy it, or place it where it can be seen by make. Often a missing or misplaced *.cpp/c or whatever means no *.o generated. Did you pray for a magic rename to some name inside a file? :smiley:

I will go through it carefully again. What I can't under stand is the exact same file set and directory structure under windows cygwin compiles and builds just fine with the addition of the compile rules for the src subdirectory. The linux make file is a bit different because it has to deal with multiple versions of gcc, but the compile and build rules are the same. It fails on the first file it tries to make an object from, and the src file is definitely where it is supposed to be in /src/src_server. Make is make, so I don't see why it works under cygwin, but not under Cent.

I will check permissions and hard-code simplify the make file to make sure there is nothing set wrong.

Below is the entire make file if that helps. The error occurs while trying to create the first object, printing2.o.

LMHmedchem

SOURCELOC = src

# create build directory name
DATESTR := $(shell date "+0.%y.%m.%d")
DATESTR2 = \"$(DATESTR)\"

# Detects which OS and if it is Linux then it will detect which Linux Distribution.
# cross-compiling is useful between kernel versions

## manually add linux distro to OS ##
OS=CentOS-5.5

ARCH := $(shell uname -m)
ifeq "$(KERN)" ""
  KERN := $(shell uname -r | cut -d. -f 1,2)
endif
cmp=g34

# if no compiler was passed as an arg
ifeq "$(cmp)" "g34"
   # find c++ compiler, 3.4 prefered
   HAVEgcc3 := $(shell which g++34)
   ifeq "$(HAVEgcc3)" ""
      HAVEgcc3 := $(shell which g++-3.4)
   endif

   ifeq "$(HAVEgcc3)" "/usr/bin/g++34"
      CC++ = g++34
      cmp=g34
   else
      ifeq "$(HAVEgcc3)" "/usr/bin/g++-3.4"
         CC++ = g++-3.4
         CMP=g34
      else
         CC++=g++
         cmp=g44
         endif
   endif

   # find fortran compiler, g77 prefered
   HAVEg77 := $(shell which g77)

   ifeq "$(HAVEg77)" "/usr/bin/g77"
      FCOMP = g77
   else
      HAVEgfortran := $(shell which gfortran)
      ifeq "$(HAVEgfortran)" "/usr/bin/gfortran"
         FCOMP = gfortran
      else
         ifeq "$(HAVEgfortran)" "/usr/local/bin/gfortran"
            FCOMP = gfortran
         endif
      endif
   endif
else
   ifeq "$(cmp)" "g44"
      CC++ = g++
      FCOMP = gfortran
   else
      @echo "can't find compiler"
      exit
   endif
endif

# create bld directory name
BDIR := bld_$(OS)_$(cmp)_$(KERN).$(ARCH)

ifeq "$(DEBUG)" "1"
  OPTIMIZE = -O0 -g
  DEFRELS =
endif
ifeq "$(DEBUG)" "2"
  # RTRACE turns on license debugging
  OPTIMIZE = -O0 -g
  DEBUGSETTINGS = -DRTRACE -DDEBUG
else
  OPTIMIZE = -O2
  DEFRELS = -DRELEASEVERSION
endif

ifeq "$(SPECIALDEBUG)" "1"
  OPTIMIZE += -DSPECIALDEBUG
endif

FCFLAGS = $(OPTIMIZE)
VFLAGS = -DVERNUM=$(VERNUM)

ifeq "$(CMP)" "g34"
   CFLAGS =  $(OPTIMIZE)  -DLINVGCC3 -DDATESTR=$(DATESTR2) $(DEFRELS) -I src -Wall
else
   CFLAGS =  $(OPTIMIZE)  -DLINVGCC4 -DDATESTR=$(DATESTR2) $(DEFRELS) -I src -Wall
endif


# create build directory if it doesn't exist
archdir: ${BDIR}
${BDIR}:
    @mkdir -p ${BDIR}

# force recreation of version.cpp each time make is run.
# Use global char so we only have to relink whatever uses this., not recompile
#.SILENT: version.h
.SILENT: version.cpp
version.cpp: FORCE
    @echo "char VERSION[] = \"$(DATESTR)\";" > $@
    @echo "int dummyfuctionXYZ() {;}" >> $@


FORCE:

# VERNUM is evaluated in the src to direct preprocessor for types of outout

# default version is debug
LICNUM = 0

# debug version, all output
VERNUM = 0
CFLAGS := $(CFLAGS) -DLICNUM=0
OBJSC = $(OBJS2) $(OBJSCLSH)
OBJSS = $(OBJS1) $(BDIR)/molMUPar.o
all: archdir $(BDIR)/molMUPar $(BDIR)/molMUChild.2.0
server: $(BDIR)/molMUPar
client: $(BDIR)/molMUChild.2.0


# src server
OBJS1 = \
         $(BDIR)/printing2.o \
         $(BDIR)/printing_classic.o \
         $(BDIR)/Remapper.o \
         $(BDIR)/molAuxFuncs.o \
         $(BDIR)/marshall.o \
         $(BDIR)/molErrDecoder.o \
         $(BDIR)/scramble.o \
         $(BDIR)/wrs_signal.o \
         $(BDIR)/version.o \
         $(BDIR)/printBlurb.o

# src client shell
OBJSCLSH = \
         $(BDIR)/molMUChild.o \
         $(BDIR)/molAuxFuncs.o \
         $(BDIR)/marshall.o \
         $(BDIR)/molthread.o \
         $(BDIR)/Remapper.o \
         $(BDIR)/scramble.o \
         $(BDIR)/wrs_signal.o \
         $(BDIR)/version.o

# src client main function
OBJS2 = \
         $(BDIR)/MolconnA.o \
         $(BDIR)/VERSIONFOR.o \
         $(BDIR)/INITIALIZE_ARRAYS.o \
         $(BDIR)/CSUBS.o \
         $(BDIR)/CSUBS_MOLFILE.o \
         $(BDIR)/csubs_findMolecule.o \
         $(BDIR)/CSUBS_SMIFILE.o \
         $(BDIR)/CSUBS_PROCESS_MOL.o \
         $(BDIR)/AROMATICITY.o \
         $(BDIR)/ESTATE1.o \
         $(BDIR)/ESTATE2.o \
         $(BDIR)/estate2_atoms.o \
         $(BDIR)/estate2_etype.o \
         $(BDIR)/Internal_HBond.o \
         $(BDIR)/MARKS.o \
         $(BDIR)/OPTIONS.o \
         $(BDIR)/Xsubs.o \
         $(BDIR)/DISTMATM.o \
         $(BDIR)/DESCRIPTORS.o \
         $(BDIR)/DES_OUTSET.o \
         $(BDIR)/BLOCK_DATA1.o \
         $(BDIR)/SUMS.o \
         $(BDIR)/UNOTIFY3.o \
         $(BDIR)/MODELS_CALC.o \
         $(BDIR)/DEVEL.o



# fortan include files, I think this insures that changes to these get re-compiled
FDEPEND = \
         $(SOURCELOC)/COMMON.BLK \
         $(SOURCELOC)/PARAM.DAT \
         $(SOURCELOC)/ATSYMB.DAT \
         $(SOURCELOC)/CONTROLPARAMS.DAT \
         $(SOURCELOC)/MOLERRORS.DAT \
         $(SOURCELOC)/MOLPARAM.DAT \
         $(SOURCELOC)/SMILES_IF_STATEMENT.DAT \
         $(SOURCELOC)/UNOTIFYPARAMS.DAT \
         $(SOURCELOC)/UTILPARAMS.DAT


###  make build rules  ###

## server build ##
# build molMUPar version
$(BDIR)/molMUPar: $(OBJSS)
    $(CC++) $(OPTIMIZE) -o $@ $(FCFLAGS) $(OBJSS)

## client build ##
$(BDIR)/molMUChild.2.0: $(OBJSC)
    $(FCOMP) $(OPTIMIZE) -o $@ $(FCFLAGS) $(OBJSC) -lstdc++ -lpthread


# client main compile rules
# compile src gfortran objects with cpp preprocessor
$(BDIR)/%.o: $(SOURCELOC)/%.FPP  $(FDEPEND)
    $(FCOMP) $(FCFLAGS) $(VFLAGS) -c -o $@ $<

# compile src gfortran objects with fortran preprocessor
$(BDIR)/%.o: ${SOURCELOC}/%.FOR  $(FDEPEND)
    $(FCOMP) $(FCFLAGS) $(VFLAGS) -c -o $@ $<

# compile src c++ objects
$(BDIR)/%.o: ${SOURCELOC}/%.cpp
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

# compile src c objects
$(BDIR)/%.o: ${SOURCELOC}/%.c
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<


## src_server compile rules
# compile src c++ objects
$(BDIR)/%.o: ${SOURCELOC}/src_server/%.cpp
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

# compile src c objects
$(BDIR)/%.o: ${SOURCELOC}/src_server/%.c
    $(CC++) $(CFLAGS) $(VFLAGS) -c -o $@ $<

Maybe there is a reason most make setups have a make file in each dir? Often, .c and .cpp in different dirs? You have a lot of ways to make *.o there!

Try adding a specific make group for the first file.

Make can be very chatty if asked.

I am trying to juggle this with several other things. Is there a good link for make? Most of what I have read is pretty simple stuff and doesn't get into much for how to do more advanced things. I have thought about switching to a configure script that would call make, but this file works just fine under cygwin and it was allot of work to get it set up to do make all the different versions I have, with different versions of gcc, different OSs, etc, and I would hate to have to do all of that again.

LMHmedchem