LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Whats wrong with "my" makefile? (https://www.linuxquestions.org/questions/programming-9/whats-wrong-with-my-makefile-296879/)

BBB 03-02-2005 05:16 PM

Whats wrong with "my" makefile?
 
Hi!
Im currently learning linux programming and ive come across a library tutorial:
http://users.actcom.co.il/~choo/lupg...ynamic-shared/
( http://users.actcom.co.il/~choo/lupg...ynamic-shared/ )

Ive downloaded all files but when i type "make" in the consoles it sez:
"Makefile:35 *** missing separator. stop."
Ive looked at line 35 in the makefile and it looks fine as far as I know.

Here is the makefile (you can download the entire program from the link):

Code:


# Compiler/Linker/dynamic linker
CC = gcc
LD = gcc

# flags to compile object files that can be used in a dynamic library
CFLAGS = -fPIC
# on some platforms, use '-fpic' instead.

# Flags to create a dynamic library.
DYNLINKFLAGS = -shared -nostdlib
# on some platforms, use '-G' instead.

# files removal
RM = /bin/rm -f

# program's object files
PROG_OBJS = main.o

# program's executable
PROG = prog

# libraries to link with the program during compile time.
LIBS = -ldl

# shared library files
LIB_FILES = lib1.so lib2.so

# shared libraries object files
LIB_OBJS = lib1.o lib2.o

# top-level rule
all: $(LIB_FILES) $(PROG)

$(PROG): $(PROG_OBJS)
$(LD) $(LDFLAGS) $(PROG_OBJS) $(LIBS) -o $(PROG) # <- this is the incorrect line -------------

# create our librarys
lib1.so: lib1.o
$(LD) $(DYNLINKFLAGS) $< -o $@

lib2.so: lib2.o
$(LD) $(DYNLINKFLAGS) $< -o $@

# compile C source files into object files.
%.o: %.c
$(CC) $(CFLAGS) -c $<


# clean everything
clean:
$(RM) $(PROG_OBJS) $(PROG) $(LIB_OBJS) $(LIB_FILES)

# clean the program and its object files, don't touch the library.
cleanprog:
$(RM) $(PROG_OBJS) $(PROG)

# clean the library and its object files only
cleanlib:
$(RM) $(LIB_OBJS) $(LIB_FILES)

# clean the library's object files only
cleanlibobjs:
$(RM) $(LIB_OBJS)


linuxzealot 03-02-2005 05:30 PM

You need a tab on that line, makefiles use tabs instead of spaces.

So try changing
Code:

clean:
$(RM) $(PROG_OBJS) $(PROG) $(LIB_OBJS) $(LIB_FILES)

to
Code:

clean:
        $(RM) $(PROG_OBJS) $(PROG) $(LIB_OBJS) $(LIB_FILES)


Hko 03-02-2005 05:47 PM

Note that you need a tab on all those command lines.

linuxzealot 03-02-2005 05:51 PM

I was gonna say that, but I figured he would of eventually found out :p

BBB 03-02-2005 05:53 PM

Yay it works! I had to add some stuff to the makefile
(wierd ,unfinished tutorial...) but it seems to be working
fine. Thx for the help!


All times are GMT -5. The time now is 06:05 AM.