SHELL = cmd
.SHELLFLAGS = /C

CC = gcc
WINDRES = windres
TARGET = ClassicNotepad.exe
SRC = ClassicNotepad.c
RES = ClassicNotepad.res
ALIAS = notepad.exe
ISCC = iscc
INSTALLER = ClassicNotepadSetup.exe
CP = copy /y
RM = del /f /q

CFLAGS = -Wall -Wextra -std=c11 -mwindows
LDLIBS = -luser32 -lgdi32 -lcomdlg32

$(TARGET): $(SRC) $(RES)
	$(CC) $(CFLAGS) -o $@ $(SRC) $(RES) $(LDLIBS)

$(ALIAS): $(TARGET)
	$(CP) $(TARGET) $(ALIAS) >NUL

$(RES): ClassicNotepad.rc app.ico
	$(WINDRES) -O coff ClassicNotepad.rc $(RES)

.PHONY: all clean install
all: $(TARGET) $(ALIAS)

install: $(INSTALLER)

$(INSTALLER): ClassicNotepad.iss $(TARGET) $(ALIAS) app.ico
	$(ISCC) ClassicNotepad.iss

clean:
	-$(RM) $(TARGET) $(RES) $(ALIAS) $(INSTALLER) 2>NUL
