help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

implicit versus explicit rules and compiling all source files with autom


From: Dave
Subject: implicit versus explicit rules and compiling all source files with automatic variables. some gnumake install info ??
Date: Sun, 20 Oct 2002 12:53:23 -0400

I am not sure where to start with this discussion. Using make on a HPUX 11.0 system, I have developed a make file which includes other OS dependent make files using the include directive and -I on the command line to find these other includes. This part works to find the includes and I am satisfied with the capability to override implicit rules using the following targets and perquisites.
 
make -r -I $TARGET_ROOT/gobuildtools -f optcore.mak
Using with out -r as well produces similar effects with overridden pattern rules
 
make version is 3.79
 
Where I am perplexed with overriding or writing my own rules is the command for compiling all *.cpp or %.cpp files in my current directory. The cpp files do exist for starters. The output object .o files do not as expected. I expect to place the output files form just compiling to *.o in a subdirectory under the current source directory.
 
I want to use automatic variables and as much wildcard and lists as possible to complete tasks. prerequisites I believe are satisfied with source files *.cpp
 
MYOBJS := $(patsubst %.cpp, %.o, $(wildcard *.cpp))
################################################################################
#  Compute the names of the input/output files
#  STD_DLLDIR should be defined in the environment, outside of
#  these make files
#  TBD need to move this shared library around more on post build
################################################################################
 
DLL_TARGET_NAME=$(BIN_DIR)/lib$(DLL_NAME).sl
 
################################################################################
# Build this DLL:
# 1. Ensure that obj directory exists
# 2. Compile source files for this DLL
# 3. Build the .libs of components we depend on
#    (Rule used is .def -> .lib below)
# 4. Link the DLL
################################################################################
#all: banner1 createobjdir  $(DLL_OBJS) $(DLL_TARGET_NAME)
#all: banner1 createobjdir $(MYOBJS) $(DLL_OBJS)
all: banner1 createobjdir foo
banner1:
   @echo
   @echo --------------------------------------------------------------
   @echo Building component $(DLL_DISPLAY_NAME)
   @echo --------------------------------------------------------------
 
%.cpp :
 
%.o: %.cpp
  $(CPP) $(STD_INCLUDES) $(STD_CPPFLAGS) $(APP_CCFLAGS) $< -o $(addprefix $(OBJ_DIR), \
              $(addprefix $(TSLASH), $(basename $< ))).o
 
foo: $(MYOBJS)
   @echo Herr comes foobar
 
 
createobjdir:
    - mkdir $(OBJ_DIR)      # Release or Debug
 
I have done several variations most revolve around the infomation in the gnumake manual and what I get is one compilation attempt and then it quits using $<. However, using the implicit rule %.o: %.cpp with some variable overrides I see the %.cpp automatic variable and the first dependency $< continue for each cpp file. Whether I use the order of information in the implicit rule or redefine to at least get it to compile is of no difference or consequence to me just yet, but have considered it. I still have errors in my CPPFLAGS yet, so completing the first file compilation successfuly is my work in parallel. Using the implicit rule appears to grab all the cpp files whereas my override does one and quits with an error 2 [myfirstobj.o] All commands start with tabs and I can echo that I am getting there in my overrides
 
I have used the -d flag, the -p flag to look at what and how to override the implicit rule and while I don't have all my flags defined to get a completed compilation for the fist cpp file, I don't understand why it quits. I have redefined the suffixes to just .cpp .o .h or left them wide open to the defaults
 
Is there a install section for gnumake and is there a section which tells me what environment setup to accomplish. gnumake is in my path and that is it.
 
I don't expect this to get some help in this session completely. I am sure there are questions to be asked from your perspective.
 
I am at a loss as to why it quits when using the automatic variables and the implicit versus explicit rules. If someone has a better way of overriding or insuring implicit rules work or are found would help FAQ or something like that. I would be interested in the gnumake environment setup for a user as well.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]