######################################################
### Mingw Makefile
######################################################

# define the name of the executable to wrap
# output file will be the same with a 'w' on the end
EXECUTEFILE=makensis-bz2

OBJS=makensisw.res app.o makensisw.o version.o

CC=g++
RC=windres
RM=del
MV=move

TARGET=-mwindows
CFLAGS=-O2 -Wall
RCFLAGS =--input-format rc --output-format coff
EXE=$(EXECUTEFILE)w

all: makensisw.exe Makefile

makensisw.exe: $(OBJS)
	$(CC) $(CFLAGS) $(TARGET) -s -o $(EXE).exe $(OBJS)

makensisw.res: makensisw.rc
	$(RC) $(RCFLAGS) makensisw.rc makensisw.res

makensisw.o: app.c makensisw.cpp
	$(CC) $(CFLAGS) $(TARGET)  -c -o makensisw.o makensisw.cpp

version.o: ../version.c
	$(CC) $(CFLAGS) -c -o version.o ../version.c

app.o:
	echo char *g_makensis="$(EXECUTEFILE)"; > app.c
	$(CC) $(CFLAGS) -c -o app.o app.c

clean:
	$(RM) *.o
	$(RM) *.res
	$(RM) app.c
	$(RM) *.exe