SRCS := $(wildcard *.c)
RES := $(wildcard *.rc)
OBJS := $(SRCS:%.c=%.o) $(RES:%.rc=%.res)
PRECOMP := precomp.h
CC = gcc
RC = windres
INCLUDES = -I.
LIBS = -ladvapi32 -luser32 -lgdi32 -lcomctl32 -lmsvcrt -lkernel32 -mwindows
CCFLAGS = -DUNICODE -D_UNICODE -municode
RCFLAGS = -DUNICODE -D_UNICODE -DLANGUAGE_EN_US

all: charmap

$(filter %.o,$(OBJS)): %.o : %.c
	$(CC) -c $< $(CCFLAGS) $(INCLUDES)

$(filter %.res,$(OBJS)): %.res : %.rc
	$(RC) $(RCFLAGS) $(INCLUDES) -O coff -F pe-i386 -i $< -o $@

$(PRECOMP).gch: $(PRECOMP)
	$(CC) -o $@ -c $^

charmap : $(OBJS)
	$(CC) $(OBJS) -o $@ $(INCLUDES) $(CCFLAGS) $(LIBS)

clean:
	rm *.o