Jump to content

help with makefile


Dimitree
 Share

Recommended Posts

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

post-5811-0-47859900-1326732692_thumb.jp

Edited by Dimitree
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by Hawkeye
Link to comment
Share on other sites

  • 4 weeks later...

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...