Highly optimized makefile for Microsoft

Highly optimized makefile for Microsoft

Postby Antonio Linares » Wed Jul 30, 2014 2:25 pm

Sometime ago I learned how to use "lists" of files and make replacements on those lists (from a Borland makefile). So I have tried the same concept on a Microsoft makefile and finally I was able to implement the same concept. The beauty of this makefile (MyApp.mak) is that only needs one list of files, thats all :-) (previously we have to write down the same files names in different locations)

This code $(PRGS:.prg=.obj) means: In the list of PRGS replace .prg with .obj. As you can see it is used in several places of the makefile.

Enjoy it! :-)

go.bat
Code: Select all  Expand view
@set oldpath=%path%
@set oldinclude=%include%
@set oldlib=%lib%
@set oldlibpath=%libpath%
if exist "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" call "%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" call "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
c:\"Program Files (x86)\Microsoft Visual Studio 12.0"\VC\bin\nmake -fMyApp.mak
@set path=%oldpath%
@set include=%oldinclude%
@set lib=%oldlib%
@set libpath=%oldlibpath%
@set oldpath=""
@set oldinclude=""
@set oldlib=
@set oldlibpath=
if errorlevel==0 MyApp.exe


MyApp.mak
Code: Select all  Expand view
#Microsoft VS2013 make sample, (c) FiveTech Software 2014

HBDIR=c:\harbour
FWDIR=c:\fwh
VCDIR="c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
SDKDIR="c:\Program Files (x86)\Windows Kits\8.1"

PRGS =       \
one.prg  \
two.prg     \
three.prg \
four.prg
#place here as many PRGs as needed

.SUFFIXES: .prg .c .obj .rc .res

MyApp.exe : $(PRGS:.prg=.obj) MyApp.res
   echo $(PRGS:.prg=.obj) > msvc.tmp

   echo $(FWDIR)\lib\FiveH32.lib $(FWDIR)\lib\FiveHC32.lib >> msvc.tmp

   echo $(HBDIR)\lib\vc32\hbrtl.lib    >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbvm.lib     >> msvc.tmp
   echo $(HBDIR)\lib\vc32\gtgui.lib    >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hblang.lib   >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbmacro.lib  >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbrdd.lib    >> msvc.tmp
   echo $(HBDIR)\lib\vc32\rddntx.lib   >> msvc.tmp
   echo $(HBDIR)\lib\vc32\rddcdx.lib   >> msvc.tmp
   echo $(HBDIR)\lib\vc32\rddfpt.lib   >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbsix.lib    >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbdebug.lib  >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbcommon.lib >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbpp.lib     >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbwin.lib    >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbcplr.lib   >> msvc.tmp
   echo $(HBDIR)\lib\vc32\xhb.lib      >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbpcre.lib   >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbct.lib     >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbcpage.lib  >> msvc.tmp
   echo $(HBDIR)\lib\vc32\hbzlib.lib   >> msvc.tmp
   echo $(HBDIR)\lib\vc32\png.lib      >> msvc.tmp

   echo kernel32.lib  >> msvc.tmp
   echo user32.lib    >> msvc.tmp
   echo gdi32.lib     >> msvc.tmp
   echo winspool.lib  >> msvc.tmp
   echo comctl32.lib  >> msvc.tmp
   echo comdlg32.lib  >> msvc.tmp
   echo advapi32.lib  >> msvc.tmp
   echo shell32.lib   >> msvc.tmp
   echo ole32.lib     >> msvc.tmp
   echo oleaut32.lib  >> msvc.tmp
   echo uuid.lib      >> msvc.tmp
   echo odbc32.lib    >> msvc.tmp
   echo odbccp32.lib  >> msvc.tmp
   echo iphlpapi.lib  >> msvc.tmp
   echo mpr.lib       >> msvc.tmp
   echo version.lib   >> msvc.tmp
   echo wsock32.lib   >> msvc.tmp
   echo msimg32.lib   >> msvc.tmp
   echo oledlg.lib    >> msvc.tmp
   echo psapi.lib     >> msvc.tmp
   echo gdiplus.lib   >> msvc.tmp
   echo winmm.lib     >> msvc.tmp

   IF EXIST MyApp.res echo MyApp.res >> msvc.tmp
   
   link @msvc.tmp /nologo /subsystem:windows /NODEFAULTLIB:msvcrt > link.log
   @type link.log
   @del $(PRGS:.prg=.obj)

$(PRGS:.prg=.obj) : $(PRGS:.prg=.c)
$(PRGS:.prg=.c) : $(PRGS)

MyApp.res : MyApp.rc
   rc.exe -r -d__FLAT__ MyApp.rc
   
.prg.c:
   $(HBDIR)\bin\harbour $< /n /i$(FWDIR)\include;$(HBDIR)\include

.c.obj:
   cl.exe -c -TC -W3 -I$(HBDIR)\include -I$(SDKDIR)\include -I$(VCDIR)\include $<
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Highly optimized makefile for Microsoft

Postby TimStone » Wed Jul 30, 2014 3:25 pm

UE Studio has a great way of handling the make file ... it generates it.

You do need to specify the libraries you want to link in, but any .prg you add to the Project ( in Project Manager ) is automatically included in the generated Make file. This makes it very easy to build.

It was a bit more laborious with Visual Studio 2013, but once defined, everything is handled automatically.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2910
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Highly optimized makefile for Microsoft

Postby Antonio Linares » Wed Jul 30, 2014 4:07 pm

Tim,

yes, I know it, thanks for your feedback.

But I like to have a makefile that works standalone without the need of any tool, except the used C compiler. In fact you can call a Microsoft or Borland makefile from UEStudio. So this gives you total freedom :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Highly optimized makefile for Microsoft

Postby TimStone » Wed Jul 30, 2014 4:30 pm

Antonio,

In my UE Studio, I track two builds across the same .prg files.

1) I have an xHarbour/xBuilder file. I need to modify the file list in xBuilder, but mostly I can just call the build command from within UE Studio with a button on the toolbar.

2) I have a Microsoft VC / Harbour build and that is controlled by the UE Studio make file. This is easy because if I add a new .PRG to the project it is also included in the build.

To re-build a program after making changes, it's two button clicks, and I have both an xHarbour and VC 2013 build ready to test.

I personally try to minimize the things I have to change. Part of being a "senior citizen" is to limit some of the challenges to my memory. It's enough to keep up with learning new things and not have to remember to modify various bat files, etc. In that respect UE Studio really helps.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2910
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Highly optimized makefile for Microsoft

Postby Antonio Linares » Wed Jul 30, 2014 5:36 pm

Tim,

I fully understand you :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 150 guests