Make file in linuz

I would like now how to create a make file say, I want to create a make file to compile the opengl program in linux.

Would any one explain this in simple term & more detail, Don’t prefer me to going help documentation of make in linuz, I am doing that but to cumbersome. So,would any one help me…

Here’s my generic makefile that I use for almost every single project.

EXECUTABLE = demo
CPPFLAGS = -ggdb3 -Wall -Wshadow -Wpointer-arith -Wdisabled-optimization
LIBS = -lpthread -lGL -lGLU -lglfw -lXxf86vm

-lSDL \

-lIL -lILU -lILUT

SLIBS = #./lib/lib3ds.a
LIBPATH = -L/usr/X11R6/lib -L./lib
#################################################
CC = gcc
SRCS := (wildcard *.cpp) OBJS := (patsubst %.cpp,%.o,(SRCS)) DEPS := (patsubst %.cpp,%.d,(SRCS)) ################################################# all: (EXECUTABLE)

(EXECUTABLE): (DEPS) (OBJS) (CC) (CPPFLAGS) -o (EXECUTABLE) (OBJS) (SLIBS) (LIBPATH) (LIBS)

%.d: %.cpp
(CC) -M (CPPFLAGS) < | sed s/\\.o/.d/ > @

%.d: %.h
(CC) -M (CPPFLAGS) < | sed s/\\.o/.d/ > @

clean:
-rm (OBJS) (EXECUTABLE) $(DEPS) *~ &> /dev/null

explain:
@echo “--------Some Info--------”
@echo “Executable name: (EXECUTABLE)" @echo "Source files: (SRCS)”
@echo “Object files: (OBJS)" @echo "Dependency files: (DEPS)”

depends: $(DEPS)
@echo “Dependencies updated”

-include $(DEPS)

tags:
etags .h .cpp /usr/include/.h /usr/include/GL/.h /usr/include/SDL/*.h

run: all
./$(EXECUTABLE)

debug: all
gdb $(EXECUTABLE)

Would any one explain this in simple term & more detail, Don’t prefer me to going help documentation of make in linuz, I am doing that but to cumbersome.

Life is cumbersome, deal with it. But google is your friend. http://www.google.ca/search?q=makefile

PK,

I’m glad I poked my head in here. That’s a nice little default makefile – thanks for posting it. I’m just learning pattern rules and what -include means, so I think I’ll learn something from your post.

Hadn’t thought of the “explain” or “tags” targets. Nice.

Hmm… I think I’m finally understanding how make depends works. Sweet indeed. Thanks again PK!

Or learn how to use the Autotools, they really are your best friend(s) once you know how to work with them

(especially automake/libtool is quite handy)

How about using a GUI interface like Kdevelope under the KDE desktop to create you programs and make files, all controls are windows like and easy to use.
That way you need not learn linux to create a make file.

Originally posted by Sameer Ahmed:
[b]I would like now how to create a make file say, I want to create a make file to compile the opengl program in linux.

Would any one explain this in simple term & more detail, Don’t prefer me to going help documentation of make in linuz, I am doing that but to cumbersome. So,would any one help me…

[/b]

Originally posted by jmg:
[b]
I’m glad I poked my head in here. That’s a nice little default makefile – thanks for posting it. I’m just learning pattern rules and what -include means, so I think I’ll learn something from your post.

Hadn’t thought of the “explain” or “tags” targets. Nice.

Hmm… I think I’m finally understanding how make depends works. Sweet indeed. Thanks again PK![/b]

It’s a moving, changing piece of work. I’d appreciate if anyone would like to contribute tricks that they have learned over the years.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.