c++ - Simple Make File
- Ronald Weidner (24/24) Dec 16 2008 # Simple Make File for many projects. Just modify
- Cesar Rabak (11/43) Dec 16 2008 I would require modification of more lines if:
- Ronald Weidner (26/56) Dec 16 2008 That's correct. If someone wanted to use this make file, they would nee...
- Ronald Weidner (6/6) Jan 17 2012 I know this thread is a little long in the tooth now but I was wondering...
- osbornedental (3/11) Aug 03 2012 Yes agree with you dear.. its really littly long..
CC=c:\dm\bin\dmc.exe SRC=Inheritence.cpp CFLAGS= LINK= INCLUDE=-I\dm\stlport\stlport EXE=Inheritence.exe RM=del OBJS=$(SRC:.cpp=.obj) MAPS=$(SRC:.cpp=.map) all:${OBJS} ${CC} ${OBJS} ${LINK} -o ${EXE} %.obj: %.cpp ${CC} ${INCLUDE} ${CFLAGS} -c $*.cpp -o $*.obj clean: - ${RM} ${EXE} - ${RM} ${OBJS} - ${RM} ${MAPS} tidy: all - ${RM} ${OBJS} - ${RM} ${MAPS} rebuild: clean all
Dec 16 2008
Ronald Weidner escreveu:I would require modification of more lines if: DM is not installed in C:\DM if you invoke the make from a drive diferent than C: since your macro for include does not have the drive letter...CC=c:\dm\bin\dmc.exe SRC=Inheritence.cpp CFLAGS= LINK= INCLUDE=-I\dm\stlport\stlport EXE=Inheritence.exe RM=del OBJS=$(SRC:.cpp=.obj) MAPS=$(SRC:.cpp=.map)Your makefile only considers C++ files.all:${OBJS} ${CC} ${OBJS} ${LINK} -o ${EXE} %.obj: %.cpp ${CC} ${INCLUDE} ${CFLAGS} -c $*.cpp -o $*.obj clean: - ${RM} ${EXE} - ${RM} ${OBJS} - ${RM} ${MAPS} tidy: all - ${RM} ${OBJS} - ${RM} ${MAPS}A call to make tidy will first call building of the target, is this what you intent?rebuild: clean allMake takes care of only compiling and linking if necessary if sources are newer that object files, then why do you created a 'rebuild' that cleans all objects?
Dec 16 2008
== Quote from Cesar Rabak (crabak acm.org)'s articleRonald Weidner escreveu:That's correct. If someone wanted to use this make file, they would need to "fix" it to match their project and system configuration. I wrote this to be a "light touch" makefile where this makefile could be copied, slightly edited, and used again for many C++ projects. I could probably make this even more generic with even less need to edit. The trade off is that the makefile may become more complicated/cryptic and harder to extend. It's my anticipation that this simple make file will be sufficient for 80% of my utilities and tests. I'll only need to modify SRC for each project. (since my last post I added a line for Defines). Additional modification would be needed for more complicated source trees such as multi-language projects, dll/lib creation, etc. Perhaps I should call this makefile a nice starting point. Currently I maintain several complex systems for the company I work for. The code base spans 15 years of development by scores of programmers. I've recently revamped all the makefiles for my company to something that isn't much more complicated than this make file.I would require modification of more lines if: DM is not installed in C:\DM if you invoke the make from a drive diferent than C: since your macro for include does not have the drive letter...Yes, this was the intent. I wanted a one shot call to make to build the exe and clean up files that aren't needed anymore. If I use make tidy it's probably because I'm going to zip up the folder and send it somewhere when build is complete.CC=c:\dm\bin\dmc.exe SRC=Inheritence.cpp CFLAGS= LINK= INCLUDE=-I\dm\stlport\stlport EXE=Inheritence.exe RM=del ... tidy: all - ${RM} ${OBJS} - ${RM} ${MAPS}A call to make tidy will first call building of the target, is this what you intent?This is now more out of habit and perhaps paranoia. When I want to be absolutely certain that my exe is the most up to date I run rebuild. Basically, the fear is that some external force (such as a version control system) may mess up make's ability to build correctly. By deleting all obj files make is free from potentially making a bad decision. It will rebuild everything. (Brute force approach) I always rebuild before I bundle a release.rebuild: clean allMake takes care of only compiling and linking if necessary if sources are newer that object files, then why do you created a 'rebuild' that cleans all objects?
Dec 16 2008
I know this thread is a little long in the tooth now but I was wondering if any one else has a makefile to share? Something simple and written with the intent of being reusable in different projects. -- Ronald Weidner http://www.techport80.com
Jan 17 2012
On Wednesday, 18 January 2012 at 03:09:19 UTC, Ronald Weidner wrote:I know this thread is a little long in the tooth now but I was wondering if any one else has a makefile to share? Something simple and written with the intent of being reusable in different projects. -- Ronald Weidner http://www.techport80.comYes agree with you dear.. its really littly long..
Aug 03 2012