Can anyone explain the strange behaviour of this part of a makefile:


libs\AsmDB.lib: $(ASMDB_DIR)\bin\AsmDB.lib
copy $(ASMDB_DIR)\bin\AsmDB.lib libs\AsmDB.lib

bin\AsmDB.dll: $(ASMDB_DIR)\bin\AsmDB.dll
copy $(ASMDB_DIR)\bin\AsmDB.dll bin\AsmDB.dll


This is basically a copy of two files from one location to another, the source files already exist, but the destinitions (libs\AsmDB.lib and bin\AsmDB.dll) not.
The problem is that the first one executes, the second doesn't. In the above example the lib is copied, but the dll isn't. If I swap both, it goes the other way around, the dll is copied then but the lib isn't.

Thomas
Posted on 2001-11-03 14:31:43 by Thomas
How are the rules executed?
I'm clueless - I'd have to see the whole file.
Posted on 2001-11-03 15:16:27 by bitRAKE
this is the full make file:




#####
# If no build type set, assume release build
#####
!IFNDEF build
build=release
!ENDIF


!IF "$(build)"=="release"
ML_BUILD_OPT=
LNK_BUILD_OPT=
!ELSEIF "$(build)"=="debug"
ML_BUILD_OPT="/Zi"
LNK_BUILD_OPT="/DEBUG /DEBUGTYPE:CV"
!ENDIF


# NOTE: do not change this path, it's only added for readability
# If you really need to change it, you need to change all the cd ..\.. etc too.
ASMDB_DIR=source\AsmDB_SE

#------------------------------------------------------------------------------------------
# AsmDB copied lib (libs\asmdb.lib)
#------------------------------------------------------------------------------------------
libs\AsmDB.lib: $(ASMDB_DIR)\bin\AsmDB.lib
copy $(ASMDB_DIR)\bin\AsmDB.lib libs\AsmDB.lib

#------------------------------------------------------------------------------------------
# AsmDB copied dll (bin\asmdb.dll)
#------------------------------------------------------------------------------------------
bin\AsmDB.dll: $(ASMDB_DIR)\bin\AsmDB.dll
copy $(ASMDB_DIR)\bin\AsmDB.dll bin\AsmDB.dll

#------------------------------------------------------------------------------------------
# AsmDB dll & lib
#------------------------------------------------------------------------------------------
$(ASMDB_DIR)\bin\AsmDB.dll \
$(ASMDB_DIR)\bin\AsmDB.lib: $(ASMDB_DIR)\src\AsmDB.obj \
$(ASMDB_DIR)\res\Asmdbrc.res
cd $(ASMDB_DIR)\bin
link /DLL /DEF:..\src\AsmDB.def $(LNK_BUILD_OPT) ..\src\AsmDB.obj ..\res\asmdbrc.res
cd ..\..\..

#------------------------------------------------------------------------------------------
# AsmDB resource
#------------------------------------------------------------------------------------------
$(ASMDB_DIR)\res\Asmdbrc.res: $(ASMDB_DIR)\res\asmdbrc.rc \
$(ASMDB_DIR)\res\resource.h
rc $(ASMDB_DIR)\res\Asmdbrc.rc

#------------------------------------------------------------------------------------------
# AsmDB object file
#------------------------------------------------------------------------------------------
$(ASMDB_DIR)\src\AsmDB.obj: $(ASMDB_DIR)\src\AsmDB.asm
cd $(ASMDB_DIR)\src
mx /c /coff $(ML_BUILD_OPT) AsmDB.asm
cd ..\..\..

#------------------------------------------------------------------------------------------
# AsmDB combined asm file:
#------------------------------------------------------------------------------------------
$(ASMDB_DIR)\src\AsmDB.asm: $(ASMDB_DIR)\src\source\*.*
cd $(ASMDB_DIR)\src
combine
cd ..\..\..



and this is the output:


D:\win32\progs\ft2>nmake /A

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

cd source\AsmDB_SE\src
combine
--------------------------------------------------------------------------------
Combiner 3.0 - (C) Copyright 2001 by Exagone. All rights reserved
--------------------------------------------------------------------------------
cd ..\..\..
cd source\AsmDB_SE\src
mx /c /coff AsmDB.asm
Microsoft (R) Macro Assembler Version 6.15.8803
Copyright (C) Microsoft Corp 1981-2000. All rights reserved.

Assembling: AsmDB.asm
cd ..\..\..
rc source\AsmDB_SE\res\Asmdbrc.rc
cd source\AsmDB_SE\bin
link /DLL /DEF:..\src\AsmDB.def ..\src\AsmDB.obj ..\res\asmdbrc.res
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Creating library AsmDB.lib and object AsmDB.exp
cd ..\..\..
copy source\AsmDB_SE\bin\AsmDB.lib libs\AsmDB.lib
1 file(s) copied.
Posted on 2001-11-03 15:39:52 by Thomas
By default NMAKE only executes the first rule in a file.
Add this this line before the other rules. :)

all: libs\AsmDB.lib bin\AsmDB.dll
Posted on 2001-11-03 15:46:43 by bitRAKE
Thanks tons, works fine know.. But there's one thing I don't understand. This line..
bin\AsmDB.dll: $(ASMDB_DIR)\bin\AsmDB.dll

..says that bin\AsmDB.dll depends on $(ASMDB_DIR)...dll, but even when I delete the the latter, and run nmake, that dll is created again but not copied.. :confused:
Why not?

Thomas
Posted on 2001-11-03 15:53:20 by Thomas
I forgot to say that it does work with your modifcation, but I think it should work without because of the depend.
Posted on 2001-11-03 15:54:23 by Thomas
Where is the <root> dependancy for the .lib and .dll at?
Posted on 2001-11-03 16:00:52 by bitRAKE
bin\AsmDB.dll: $(ASMDB_DIR)\bin\AsmDB.dll
This line says, "Execute this rule if '$(ASMDB_DIR)\bin\AsmDB.dll' changes." Without that dependancy NMAKE doesn't know when to execute that rule. This rule doesn't create $(ASMDB_DIR)\bin\AsmDB.dll
Posted on 2001-11-03 16:06:24 by bitRAKE
I think I get it now.. I haven't included the lib & dll in any dependancy yet as the makefile isn't finished yet.. Asmdb is just one module in the whole project.
Thanks for all your replies,

Thomas
Posted on 2001-11-03 16:27:30 by Thomas