Dimitree Posted January 16, 2012 Report Share Posted January 16, 2012 (edited) hi guys, this is not midibox related, but I hope it's ok to post here since it's about makefile in Linux I'd like to write a makefile for a project (written in C) like shown on the picture. Myfolder contains all the source files of the projects, and the makefile too. I'd need the makefile to: - compile the sources - create the static library - link the library to the sources - install (without the needs of root permission) the bin (and the library) in the $HOME/.myproject naked folder - put the object files in the obj dir - put the lib file in the lib dir - put a copy of the bin to the bid dir I don't even know where to start, I can only write simple makefile to compile 1 file :( can anyone help me? many thanks Edited January 16, 2012 by Dimitree Quote Link to comment Share on other sites More sharing options...
TK. Posted January 16, 2012 Report Share Posted January 16, 2012 There are several approaches to handle this properly (e.g. "configure" mechanism or other makefile generators), but they require some time consuming doc reading to understand the setup. My proposal: If you want to handle this for a small project with only a small number of files, the most simple solution would be to write the required commands into a shell script. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Dimitree Posted January 16, 2012 Author Report Share Posted January 16, 2012 thanks TK! yes they are only few files, just like shown..so I'd like to take the easiest way..but, the main thing is that I need this makefile for my universitary project, and the requirements are those that I wrote before.. so my question is, what you mean with commands into a shell script? would that still be a makefile or something different? Quote Link to comment Share on other sites More sharing options...
Hawkeye Posted January 16, 2012 Report Share Posted January 16, 2012 (edited) As TK said, the easiest way is to create a script that contains exactly what you would type on the command line to do all the things you need to do. It is called "shell script" and contains just a list of commands, which are executed one by one. This works on any platform and always executes all commands given, no matter what. If your university project demands for a "normal" makefile, you should really go the full way and read into http://www.gnu.org/s...anual/make.html An easy way would be to find any open source project, that has a makefile and does what you need, and just copy and alter it. On the other hand, make is really not so difficult, it is just a list of "what to build: how to build it" statements. So, what is the difference between make and the shell script? Make will check for anything already present, which needs not to be made again, whereas the script will always build everything, which really should not be a problem for a small project. Greets, Peter Edited January 16, 2012 by Hawkeye Quote Link to comment Share on other sites More sharing options...
Dimitree Posted January 16, 2012 Author Report Share Posted January 16, 2012 whereas the script will always build everything, which really should not be a problem for a small project. thanks actually that would be against the requirements, so I guess I should take the makefile route.. Quote Link to comment Share on other sites More sharing options...
Dimitree Posted February 11, 2012 Author Report Share Posted February 11, 2012 ok after some work I managed to write this thing :) it works good only question I have now, I can't manage to put output files in differents DIRs, and take input files in differents DIRs, now it only works when files are in the same dir as makefile, and the generated files (objs, bins, lib) are created inside the same folder. any help for this? Quote Link to comment Share on other sites More sharing options...
TK. Posted February 11, 2012 Report Share Posted February 11, 2012 See the rules in http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Finclude%2Fmakefile%2Fcommon.mk It's inspired from the the "super makefile": http://content.gpwiki.org/index.php/Make Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.