Makefile Compilation for an SDL-dependant app fails miserably
===

Here's the makefile:

**makefile.win**

    CC=gcc
    CFLAGS=-Wall -ID:\dev\include -LD:\dev\lib -LD:\dev\bin
    LIBS=-l mingw32 -l SDLmain -l SDL
    TARGET=-mwindows
    EXECUTABLE=main.exe
    
    all:
    	$(CC) $(CFLAGS) $(LIBS) $(TARGET) main.c -o $(EXECUTABLE)
    
    clean:
    	rm *o

(libSDL and libSDLmain are in D:\dev\lib. SDL.dll is in D:\dev\bin.)

and here's the code

    #include <SDL/SDL.h>
    
    int main(int argc, char* argv[])
    {
    	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
    		printf("Could not initialize!");
    		
    	SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE|SDL_DOUBLEBUF);
    	if (!screen) printf("Could not load video!");
    	
    	int done = 0;
    	SDL_Event event;
    	
    	while(!done)
    	{
    		while(SDL_PollEvent(&event))
    		{
    			if (event.type == SDL_QUIT)
    				done = 1;
    		}
    		
    		SDL_Flip(screen);
    	}
    	
    	SDL_FreeSurface(screen);
    	printf("Exited cleanly");
    	
    	return 0;
    }

I build it with this command:

    mingw32-make -f makefile.win

and mingw32-make translates the makefile into:

    gcc -Wall -ID:\dev\include -LD:\dev\lib -LD:\dev\bin -l mingw32 -l SDLmain -l SD
    L -mwindows main.c -o main.exe

which is alright.

But then I get all thes charming errors:

    main.c:(.text+0x42): undefined reference to `SDL_SetVideoMode'
    main.c:(.text+0x7c): undefined reference to `SDL_PollEvent'
    main.c:(.text+0x8b): undefined reference to `SDL_Flip'
    main.c:(.text+0x9c): undefined reference to `SDL_FreeSurface'
    collect2: ld returned 1 exit status
    mingw32-make: *** [all] Error 1

So, since I'm linking with mingw32, SDL and SDLmain. And I am adding the directory to the SDL headers. Why am I getting the errors?