Link to home
Start Free TrialLog in
Avatar of lguifarro
lguifarro

asked on

Understanding makefiles in Linux

Hello:

I'm new to Linux, I'm using FEDORA 10, for no reason at all, somebody recommended to me and that was it. The thing I'm curios about is when you build something using the make command.

I've attached some of the code of this makefile, and looking at it in essence what it's telling me it's that it'll installed in /usr/local/bin, the progs, that are two files, aiod and dsf2info.py.

The thing is that when you use the make command in the local directory where you have download the source files, it builds it there, i.e, if the directory that contains the source files is /home/johndoe/Desktop/aiod for instance it'll create them there. not in the /usr/local/bin that says in the makefile.

Also it generates some *.o, or object files that ,as well as the main program, builds them in the same directory.

the thing is that i don't know is what to do with these files, theses object ones. I have to move the program i've just build in the usr/local/bin otherwise i get "command not found", because it has to be in one of the directories of the $PATH, as for these object files (*.o) I copied them in /usr/local/lib, for a lack of a better place, because i thought this program might need them. I have not tested them throughly so i don't know which features will not work, and i don't know if it'll be due to this object files, so far the program have worked.

Where do i put these files, these object ones, and am i missing some parameter to the make command so it'll build the files in the directory specified in the makefile?

Regards

Luis
CC      = gcc
CFLAGS := -Wall -O2 -W -g -DNDEBUG -UPREP_BUFS
# CFLAGS  := -Wall -W -g -DPREP_BUFS
CFLAGS += $(CFLAGS) -I.. -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
PROGS   = aiod dsf2info.py
LDLIBS  = -laio -lrt -lm
OBJS    = aiod.o affinity.o args.o misc.o async_io.o lat.o sync_io.o
 
all: depend $(PROGS)
 
INSTALL	= install
prefix	= /usr/local
bindir	= $(prefix)/bin
install: $(PROGS)
	$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
	$(INSTALL) $(PROGS) $(DESTDIR)$(bindir)
 
dist: aiod-0.9.tar.bz2
 
aiod-0.9.tar.bz2:
	-rm -f aiod-0.9.tar aiod-0.9.tar.bz2
	-git-archive --format=tar HEAD | bzip2 > aiod-0.9.tar.bz2
 
depend:
	@$(CC) -MM $(CFLAGS) -I.. *.c 1> .depend
 
clean: docsclean
	-rm -f *.o $(PROGS) .depend
	-rm -f cscope.out tags log
	-rm -f aiod-0.9.tar.bz2 aiod.tar.bz2
	-rm -f instrumentation/*.out
 
docs:
	$(MAKE) -C doc all
 
docsclean:
	$(MAKE) -C doc clean
 
aiod: $(OBJS)
 
dsf2info.py: dsf2info.py.src
	-cp $? $@
 
ifneq ($(wildcard .depend),)
include .depend
endif

Open in new window

Avatar of lguifarro
lguifarro

ASKER

Hello:

I've forgot to ask this too

There are some Header Files .h in the source files, I'm assuming that it needs them for the build when you call the make commando, but shouldn't i put these somewhere, like in the usr/nclude, or the /usr/incclude/linux directories????

Regards

Luis
SOLUTION
Avatar of Monis Monther
Monis Monther
Flag of Iraq image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of ai_ja_nai
ai_ja_nai
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial