###########################################
#
# makefile
#
###########################################
#
###########################################

# compiler
CC = gcc

# compiler flags
CFLAGS = \
	-O2\
	-fomit-frame-pointer\
	-ffast-math\
	-funroll-loops\
	-W\
	-Wall\
	-D__GTHREAD_HIDE_WIN32API\
	-pedantic

# linker flags
LFLAGS = -lalleg\
	-s\
	-mwindows


# o-files
OBJ_DIR = ./obj

ALL_OBJ = 	button.o \
		hisc.o \
		popem.o


# merge o-files and prepend path
OBJS = $(addprefix $(OBJ_DIR)/, $(ALL_OBJ)) res.o

# compile cpp to o
$(OBJ_DIR)/%.o: ./src/%.c
	$(CC) $(CFLAGS) -c $< -o $@


# output filename
OUTPUT = popem.exe

# output location
OUTPUT_DIR = .

# main rule
$(OUTPUT): $(OBJS)
	$(CC) $(OBJS) -o $(OUTPUT_DIR)/$@ $(LFLAGS)
# add to this line to upx automatically:
#	upx $(OUTPUT)



# resource file
RES_DIR = res
RES_FILE = $(RES_DIR)/popem.rc

# resource rule
res.o : $(RES_FILE)
	windres $(RES_FILE) -o $@

# UPX rule
upx : $(OUTPUT)
	upx $(OUTPUT)



