# makefile
#  Googleニュース検索
#
# @copyright	(c)studio pahoo
# @author		パパぱふぅ
# @動作環境		MinGW C++ + cURL + OpenSSL + Boost C++ Libraries
# @参考URL		https://www.pahoo.org/e-soul/webtech//cpp01-08-01.shtm
#
PROGRAM=googlenewswin
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 -lwinpthread -lcurl -lssl -llzma -lz -lws2_32 ".\Release\libcurl-x64.dll"

$(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)

