Makefile very simple question.

Hi
I tried many times and I dont know what the he... is going on.

Problem:
I hava in /home/marcin/c1_menu/
this file:
menu_item_data.c

I want to compile this file.
so I tried something like this


CC=gcc
LIBS=-lmenu -lncurses
RM=rm

BINS=menu_item_data

%: %.o
    ${CC} -o $@ $< ${LIBS} 

%.o: %.c
    ${CC} -o $@ -c $< 

.PHONY: all clean


all: $(BINS)
    echo "Jeli nie widzisz bd�w to wszystko OKi"

clean:
    ${RM} -f ${BINS}

when I tried make in /home/marcin/c1_menu/.
I get somethig like this

$ make
gcc     menu_item_data.c   -o menu_item_data
menu_item_data.c: In function 'main':
menu_item_data.c:29: warning: incompatible implicit declaration of built-in function 'calloc'
/tmp/ccsA63dp.o: In function `main':
menu_item_data.c:(.text+0x14): undefined reference to `initscr'
(......)
menu_item_data.c:(.text+0x215): undefined reference to `endwin'
collect2: ld returned 1 exit status
make: *** [menu_item_data] Bd 1

but when I try manualy everythign is ok

[marcin@zet c1_menu(0)]$ ls 
makefile  menu_item_data.c
[marcin@zet c1_menu(0)]$ vim m  
makefile          menu_item_data.c  
[marcin@zet c1_menu(0)]$ vim makefile  
[marcin@zet c1_menu(0)]$ gcc -o menu_item_data.o -c menu_item_data.c 
menu_item_data.c: In function 'main':
menu_item_data.c:29: warning: incompatible implicit declaration of built-in function 'calloc'
[marcin@zet c1_menu(0)]$ gcc -o menu_item_data menu_item_data.o -lmenu -lncurses
[marcin@zet c1_menu(0)]$ ls
makefile  menu_item_data  menu_item_data.c  menu_item_data.o
[marcin@zet c1_menu(0)]$ 

Why there are no LIBS ?

[marcin@zet c1_menu(0)]$ make -f makefile -n
gcc     menu_item_data.c   -o menu_item_data
echo "Jeli nie widzisz bd�w to wszystko OKi"

My target is compiling many files in one dir.
for example
if I had
x1.c x2.c ..... x100.c

and I have
BINS= x1.c x2.c .... x100.c
or something like a loop in Makefile

Please help me I can't get clear WORKING example from enybody.

[marcin@zet c1_menu(0)]$ gcc -o menu_item_data.o -c menu_item_data.c 
menu_item_data.c: In function 'main':
menu_item_data.c:29: warning: incompatible implicit declaration of built-in function 'calloc'

Have a look at this file. I assume you use calloc(number,size) in an improper way. While gcc tries to link your binary it therefore does not resolve your call for calloc to the function calloc in libc/stdlib.h.

Maybe it'll help if you try to create and compile a minimum (standalone) example with calloc to check whether you use it properly.