Discussion:
How to recompile the code when the header file changed?
(too old to reply)
Jiang Miao
2008-10-05 20:25:03 UTC
Permalink
Here is a test code in bakefile/tests/headers

After I run
bakefile -f msvc headers.bkl
nmake -f makefile.vc
bakefile works well.

I try to modify headers/test/hello.h
and run
nmake -f makefile.vc again
but nothing happened
and I found there is no header relation code in the file 'makefile.vc'

How to solve the problem? My bakefile version is 0.2.4

Thanks
JiangMiao

makefile.vc which bakefile generated:
# =========================================================================
# This makefile was generated by
# Bakefile 0.2.4 (http://www.bakefile.org)
# Do not modify, all changes will be overwritten!
# =========================================================================



# -------------------------------------------------------------------------
# These are configurable options:
# -------------------------------------------------------------------------

# C compiler
CC = cl

# Standard flags for CC
CFLAGS =

# Standard preprocessor flags (common for CC and CXX)
CPPFLAGS =

# Standard linker flags
LDFLAGS =

# [0,1]
BUILD_BOTH =



# -------------------------------------------------------------------------
# Do not modify the rest of this file!
# -------------------------------------------------------------------------

### Variables: ###

TESTLIB_CFLAGS = /MD /DWIN32 $(CPPFLAGS) $(CFLAGS)
TESTLIB_OBJECTS = \
testlib_hello.obj
TESTLIB2_CFLAGS = /MD /DWIN32 $(CPPFLAGS) $(CFLAGS)
TESTLIB2_OBJECTS = \
testlib2_hello.obj
TESTDLL_CFLAGS = /MD /DWIN32 /DMAKING_THE_DLL $(CPPFLAGS) $(CFLAGS)
TESTDLL_OBJECTS = \
testdll_hello.obj
TESTEXE_CFLAGS = /MD /DWIN32 $(CPPFLAGS) $(CFLAGS)
TESTEXE_OBJECTS = \
testexe_hello.obj

### Conditionally set variables: ###

!if "$(BUILD_BOTH)" == "1"
__testlib2___depname = testlib2.lib
!endif


### Targets: ###

all: testlib.lib $(__testlib2___depname) myDLL.dll testexe.exe

clean:
-if exist .\*.obj del .\*.obj
-if exist .\*.res del .\*.res
-if exist .\*.pch del .\*.pch
-if exist testlib.lib del testlib.lib
-if exist testlib2.lib del testlib2.lib
-if exist myDLL.dll del myDLL.dll
-if exist myDLL.ilk del myDLL.ilk
-if exist myDLL.pdb del myDLL.pdb
-if exist myLibrary.lib del myLibrary.lib
-if exist testexe.exe del testexe.exe
-if exist testexe.ilk del testexe.ilk
-if exist testexe.pdb del testexe.pdb

testlib.lib: $(TESTLIB_OBJECTS)
if exist $@ del $@
link /LIB /NOLOGO /OUT:$@ @<<
$(TESTLIB_OBJECTS)
<<

!if "$(BUILD_BOTH)" == "1"
testlib2.lib: $(TESTLIB2_OBJECTS)
if exist $@ del $@
link /LIB /NOLOGO /OUT:$@ @<<
$(TESTLIB2_OBJECTS)
<<
!endif

myDLL.dll: $(TESTDLL_OBJECTS)
link /DLL /NOLOGO /OUT:$@ $(LDFLAGS) @<<
$(TESTDLL_OBJECTS) /IMPLIB:myLibrary.lib
<<

testexe.exe: $(TESTEXE_OBJECTS)
link /NOLOGO /OUT:$@ $(LDFLAGS) @<<
$(TESTEXE_OBJECTS)
<<

testlib_hello.obj: .\hello.c
$(CC) /c /nologo /TC /Fo$@ $(TESTLIB_CFLAGS) .\hello.c

testlib2_hello.obj: .\hello.c
$(CC) /c /nologo /TC /Fo$@ $(TESTLIB2_CFLAGS) .\hello.c

testdll_hello.obj: .\hello.c
$(CC) /c /nologo /TC /Fo$@ $(TESTDLL_CFLAGS) .\hello.c

testexe_hello.obj: .\hello.c
$(CC) /c /nologo /TC /Fo$@ $(TESTEXE_CFLAGS) .\hello.c
Zbigniew Zagórski
2008-10-05 20:35:31 UTC
Permalink
Post by Jiang Miao
Here is a test code in bakefile/tests/headers
After I run
bakefile -f msvc headers.bkl
nmake -f makefile.vc
bakefile works well.
I try to modify headers/test/hello.h
and run
nmake -f makefile.vc again
but nothing happened
and I found there is no header relation code in the file 'makefile.vc'
How to solve the problem? My bakefile version is 0.2.4
Makefile for MSVS ont have advanced dependecies included. The only
dependency is between executable/library and source file. Dependencies
of source files are out of scope of this makefile. Use MSVS IDE which
can inter-source track dependencies.

AFAIR only autoconf + gcc makefile can track dependecies.

Best regards,
Zbyszek
Vaclav Slavik
2008-10-05 21:12:17 UTC
Permalink
Post by Zbigniew Zagórski
AFAIR only autoconf + gcc makefile can track dependecies.
Borland's make can do it too and so can OpenWatcom's wmake and GNU make
with the 'mingw' format (not sure if that's what you mean by "gcc
makefile" or if you meant autoconf when using gcc compiler).

For the stupid make variants, this bug describes how to at least somehow
fix this: http://www.bakefile.org/ticket/197

Regards,
Vaclav
Kevin Watters
2009-02-06 15:23:24 UTC
Permalink
Post by Jiang Miao
and I found there is no header relation code in the file 'makefile.vc'
If you have bakefile generate MSVC .sln and .vcproj files with the msvs200x-prj
configuration, you can use Microsoft's "vcbuild" from the commandline to build
the .sln file--something like this should work:

vcbuild myproject.sln "Release|Win32"

vcbuild is nice because it supports colored output, parallel builds, and actual
header dependency tracking.

Loading...