PDA

View Full Version : makeFile



zeroKelvin
08-08-2002, 04:14 PM
hey can anyone show me how to make a make file for linux? Also how do I set the path and stuff cause I am really lost in all this.

nexusone
08-08-2002, 05:45 PM
If you download the current version Redhat and use QT you do not have to worry about make files.
Works just like visual C++

Try a linux forum for help on make files.


Originally posted by zeroKelvin:
hey can anyone show me how to make a make file for linux? Also how do I set the path and stuff cause I am really lost in all this.

rixed
08-09-2002, 05:20 AM
Makefiles are a whole language by themselves and discussing it here would be long and quite offtopic. So here is just, out of 1000, a little example taken from one of my project :

-----
CC=/usr/bin/g++
LIBCCPATH=$(HOME)/src/libCC
CLFLAGS=-Wl,-rpath,$(LIBCCPATH) -g -lGL -L $(LIBCCPATH) -lCC
CCFLAGS=-Wall -g -fPIC -I $(LIBCCPATH)
CCFILES = $(wildcard *.cc *.c)
OFILES = $(patsubst %.cc,%.o,$(CCFILES)) $(patsubst %.c,%.o,$(CCFILES))

# End of customizations, begining of bugfixes

SUFFIXES=.cc .c .hh .ok .o
COL=^[3;36m # ANSI STUF FOR FUN
NORM=^[0m # ANSI STUF FOR FUN

.cc.o: depends
@echo '$(COL)$@$(NORM)'
$(CC) $(CCFLAGS) -c $<

.c.o: depends
@echo '$(COL)$@$(NORM)'
$(CC) $(CCFLAGS) -c $<

all: srt.o sampleSrv sampleClt writeCoord enum

sampleClt: net.o sys.o crt.o touches.o
@echo '$(COL)$@$(NORM)'
$(CC) $(CLFLAGS) $^ -o $@ -lglut -lGLU -lSDL -lpthread -L /usr/X11R6/lib -lXmu -L /usr/local/lib -lIL -lILU -lILUT

sampleSrv: net.o rt.o srt.o sample.o touches.o
@echo '$(COL)$@$(NORM)'
$(CC) $(CLFLAGS) $^ -o $@ -lglut -lGLU -lSDL -lpthread -L /usr/X11R6/lib -lXmu -L /usr/local/lib -lIL -lILU -lILUT

writeCoord: writeCoord.o
@echo '$(COL)$@$(NORM)'
$(CC) $(CLFLAGS) $^ -o $@ -lglut -lGLU -lSDL -lpthread -L /usr/X11R6/lib -lXmu -L /usr/local/lib -lIL -lILU -lILUT

enum: enum.o
@echo '$(COL)$@$(NORM)'
$(CC) $(CLFLAGS) $^ -o $@ -lglut -lGLU -lSDL -lpthread -L /usr/X11R6/lib -lXmu -L /usr/local/lib -lIL -lILU -lILUT

clean: cleanspec
@echo '$(COL)$@$(NORM)'
rm -f *.o depends

depends: $(wildcard *.cc) $(wildcard *.c) $(wildcard *.hh) $(wildcard *.h) public.hh private.hh
@echo '$(COL)$@$(NORM)'
$(CC) -M -I $(LIBCCPATH) -I /usr/local/include $(CCFILES) > $@

cleanspec:
@echo '$(COL)$@$(NORM)'
rm -f sampleClt sampleSrv writeCoord enum public.hh private.hh

public.hh: enum
@echo '$(COL)$@$(NORM)'
enum tetris public.rep > $@

private.hh: enum
@echo '$(COL)$@$(NORM)'
enum tetris private.rep > $@


include depends

-------------

of course you do not want to use this as is. Just so that you can see how it works. Reading the 'info make' is necessary, anyway.

zeroKelvin
08-12-2002, 01:52 PM
thanks people