Advertisement

Crossing over/ makefiles... wtf?

Started by April 20, 2005 11:21 AM
13 comments, last by Leffe 19 years, 7 months ago
Ok, yay! I have successfully crossed over to the the dark side, I have installed windows xp and ubuntu successfully, and I even have my wireless card up and running. Now that I have all this going for me, I figured it was time to jump in and do some development. The water is cold guys... Basicly, where do I begin? Everything I have done so far as installing and downloading packages has involved using make. What is it? Do people generate makefiles by hand? or are they an export from and IDE like you can do with visual studio? I opened one of the makefiles, and it looked prety complicated. I'm sure you can build them by hand, but is there a good program for doing this? In short, I am new to linux development, I can build other people's packages, but on my own, I am screwed. What do I need to do to get started?
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Makefiles arn't that hard to write. I was in the same situation as you but I managed to learn make after a few good tutorials. The IDEs I found didn't impress me, so I decided I'd develop with Visual Studio on Windows, then when I needed to compile on linux just run a makefile. I don't have the tutorials I used anymore, sorry.
Advertisement
You can use Eclipse+CDT to automatically let Eclipse generate makefiles. Or you can write your own. Custom makefiles give you more flexibility. Another option is to let automake generate makefiles for you.
Quote: Original post by nmi
You can use Eclipse+CDT to automatically let Eclipse generate makefiles. Or you can write your own. Custom makefiles give you more flexibility. Another option is to let automake generate makefiles for you.


I'm not on my linux box right now, so I am limmited as to what I can test.

Another thing, how can I automount my fat32 partition when I login?
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
The standard way in linux is to use autotools to generate the makefile (from other text-based rules). However, for simpler or more custom projects, people edit make files by hand.

If you want a simple make file system where you can just copy something and go, take a look at my sample makefile which should be pretty much automatic after a very simple setup process (see readme file).
enum Bool { True, False, FileNotFound };
There are alternatives to makefiles, SCons comes to mind, especially if you like Python (but no Python knowledge is required). It works really well on Windows and Ubuntu.
Advertisement
I'm seconding the SCons recommendation. It's a really powerful and simple build system. Since it knows about many common file types it can easily figure out how to compile things.

Consider this sconstruct file:
env = Environment()env['LIBS'] = Split('X11 m')env.Program('main',Split('Xinterface.cc main.cc backprop.cc universe.cc'))


That is what I wrote for my friend, who was using this Makefile:

CC = g++ -WallINCS = -I/usr/include/X11 -L/usr/X11R6/libLIBS = -lX11 -lmOBJS = Xinterface.o universe.o backprop.o main.omain: $(OBJS)        $(CC) $(INCS) -o main $(OBJS) $(LIBS)main.o: parameters.h universe.h main.cc        $(CC) $(INCS) -c main.cc Xinterface.o: Xinterface.h Xinterface.cc        $(CC) $(INCS) -c Xinterface.cc universe.o: useful.h universe.h universe.cc        $(CC) $(INCS) -c universe.cc backprop.o: backprop.h backprop.cc        $(CC) $(INCS) -c backprop.cc clean:        rm -rf *.o main


Now I should point out that the Makefile could be cleaned up in other ways, such as using rules (ie tell make how to make .cc files into .o files) but in SCons there is no need.

As far as your second question goes, you can add a line to '/etc/fstab' to mount your partition. Here's what I use:
/dev/hda5   /mnt/windata   vfat   defaults,umask=0   0 0

If you need to add extra restrictions (e.g. don't want every user to have access) you can look up the extra mount options with 'man mount' the options used in fstab are the same.
Jam is also a replacement for Makefiles as well. We use it on our project ( fairly large ) and it works pretty well. They are much easier to maintain than Makefiles. The only downside is that they are not as popular so you need to dig a bit to find help on them.
Quote: Original post by PnP Bios
Another thing, how can I automount my fat32 partition when I login?


check /etc/fstab you have to add a new entry there, for example:

/dev/hda1 /mnt/fat32 vfat defaults 0 0
in the wuss/i-just-want-this-to-compile department, there's also iCompile.

nice documentation, and it'll compile in linux *and* osX, which is convenient if your code is already portable and you want to be nice to the mac people out there.

personally i use eclipse+cdt on windows and linux, easy for code crossover, but the auto generated makefiles can be pretty frustrating to customize (eg adding compiler options one by one is *annoying* and slow, and if they're going to make it that way there should at least be an export/import compile settings option).

This topic is closed to new replies.

Advertisement