# makefile
# GUIDを生成する(CUI版)
#
# @copyright	(c)studio pahoo
# @author		パパぱふぅ
# @動作環境		MinGW C++ Boost C++ Libraries
# @参考URL		https://www.pahoo.org/e-soul/webtech/cpp01-10-01.shtm
#
PROGRAM=newguid
RELEASE_DIR=./Release
SOURCES=$(wildcard *.cpp)
OBJS=$(addprefix $(RELEASE_DIR)/, $(SOURCES:.cpp=.o))
RC=resource.rc
WINDRES=$(addprefix $(RELEASE_DIR)/, $(RC:.rc=.o))
EXEC=$(PROGRAM).exe
CC=g++
CFLAGS=-Wall -O3
LDFLAGS1=-s -mwindows
LDFLAGS2=-static -lstdc++ -lgcc -lole32 -lboost_program_options-mt -lpthread -lwinpthread

$(RELEASE_DIR)/$(EXEC): $(OBJS) $(WINDRES)
	@if [ ! -d $(RELEASE_DIR) ]; then \
		echo ";; mkdir $(RELEASE_DIR)"; mkdir $(RELEASE_DIR); \
	fi
	$(CC) $(LDFLAGS1) $(OBJS) $(WINDRES) -o $(RELEASE_DIR)/$(EXEC) $(LDFLAGS2)

$(RELEASE_DIR)/%.o: %.cpp
	@[ -d $(RELEASE_DIR) ]
	$(CC) $(CFLAGS) -o $@ -c $<

$(RELEASE_DIR)/%.o: $(RC) resource.h
	windres $(RC) $(WINDRES)

