補齊 mingw32/mingw64 的 hbcurl、hbssl 檔案!
現在 bcc32、msvc、msvc64、mingw、mingw64 都可以完整編譯包含使用 hbssl、hbcurl 套件的程式!!
Fill in mingw32/mingw64 about hbcurl、hbssl.
Now We have bcc32、msvc、msvc64、mingw、mingw64 full package to use hbssl、hbcurl.
說明:因為 mingw32、mingw64 的 hbssl、hbcurl 都會有 libcrypto.a、libssl.a,
因此將 hbcurl 內的改名為 libcrypto_curl.a、libssl_curl.a,
連結時請特別注意!
但是在 bcc32、msvc、msvc64 卻沒有這個問題!
Note!! about mingw and mingw64, I have rename .\hbcurl\libcrypt.a to .\libcurl\libcrypt_curl.a and .\hbcurl\libssl.a to .\libcurl\libssl_curl.a,
because name same hbssl!!
But in bcc32, msvc, msvc64, there is no such problem!
另外提供一份腳本編譯一位開發者 Rafa 的 restFul 程式碼的 makefile:
Supply Developer Rafa package 'restFul' makefile to test!!
save filename as 'makefile.mak'
代碼: 選擇全部
# CopyRight: WenSheng
# date: 2021.06.26
# desc: 我自己建立的 mingw32 make 檔案, 原生地 resful.hbm 建立失敗,只好自己重新建立
# mingw32/mingw64/bcc7432 make file
# 若為指定(compiler、link、makedir.... ,前面第一碼要用 <tab> 分開
#--------------------------------------------------------
# export : 最終設定變數
#--------------------------------------------------------
# tools config
#CC=mingw32
#CC=mingw64
CC=bcc32
# cpp config
ifeq ($(CC),bcc32)
CPP_DIR := \bcc74
endif
ifeq ($(CC),mingw32)
CPP_DIR := \mingw32
endif
ifeq ($(CC),mingw64)
CPP_DIR := \mingw64
endif
CPP_INC_DIR := $(CPP_DIR)\include
CPP_LIB_DIR := $(CPP_DIR)\lib
# harbour config
HRB_DIR := \hb32
HRB_INC_DIR := $(HRB_DIR)\include
ifeq ($(CC),bcc32)
HRB_LIB_DIR := $(HRB_DIR)\lib\win\bcc
endif
ifeq ($(CC),mingw32)
HRB_LIB_DIR := $(HRB_DIR)\lib\win\mingw
endif
ifeq ($(CC),mingw64)
HRB_LIB_DIR := $(HRB_DIR)\lib\win\mingw64
endif
# harbour/cpp compiler config
ifeq ($(CC),bcc32)
HRB_EXE := $(HRB_DIR)\bin\win\bcc\harbour.exe
CPP_EXE := $(CPP_DIR)\bin\bcc32.exe
LNK_EXE := $(CPP_DIR)\bin\ilink32.exe
RCC_EXE := $(CPP_DIR)\bin\rc.exe
endif
ifeq ($(CC),$(filter $(CC),mingw32 mingw64))
ifeq ($(CC),mingw32)
HRB_EXE := $(HRB_DIR)\bin\win\mingw\harbour.exe
endif
ifeq ($(CC),mingw64)
HRB_EXE := $(HRB_DIR)\bin\win\mingw64\harbour.exe
endif
CPP_EXE := $(CPP_DIR)\bin\gcc.exe
LNK_EXE := $(CPP_DIR)\bin\gcc.exe
RCC_EXE := $(CPP_DIR)\bin\windres.exe
endif
# user config
APP_DIR := \hb32\mylib\restful
PRG_DIR := $(APP_DIR)
OBJ_DIR := $(APP_DIR)\obj
TMP_DIR := $(APP_DIR)
ifeq ($(CC),bcc32)
APP_EXE := $(TMP_DIR)\restful_bc32.exe
endif
ifeq ($(CC),mingw32)
APP_EXE := $(TMP_DIR)\restful_mg32.exe
endif
ifeq ($(CC),mingw64)
APP_EXE := $(TMP_DIR)\restful_mg64.exe
endif
# prg compiler config
PRG_FLAGS := /m /n /i$(HRB_INC_DIR);$(PRG_DIR)
ifeq ($(CC),bcc32)
CPP_FLAGS := -D__HARBOUR__ -DHB_FM_STATISTICS_OFF -5 -6 -a8 -O2 -OS -tW -c -w3 -I$(CPP_INC_DIR);$(HRB_INC_DIR);$(FWH_INC_DIR)
endif
ifeq ($(CC),$(filter $(CC),mingw32 mingw64))
# -Wall : mingw:編譯時顯示所有的警告訊息
CPP_FLAGS := -c -Wall -pthread -I$(HRB_INC_DIR) -I$(CPP_INC_DIR)
endif
###################
APP_EXE_C = \
$(OBJ_DIR)\basecontroller.c \
$(OBJ_DIR)\baseservice.c \
$(OBJ_DIR)\status_controller.c \
$(OBJ_DIR)\status_service.c \
$(OBJ_DIR)\wsRestful.c \
$(OBJ_DIR)\hbhttpd_core.c
#----------------------------------------------
# 將 $(APP_EXE_C) 內的 .c 替換為 .obj/.o,就不用全部再定義一次
APP_EXE_OBJ = $(APP_EXE_C:.c=.o)
PROJECT = \
$(APP_EXE_OBJ) \
$(APP_EXE_C) \
$(APP_EXE)
all : $(PROJECT)
CLEAN:
del $(OBJ_DIR)\*.c $(OBJ_DIR)\*.o $(APP_EXE)
# mingw32/mingw64
ifeq ($(CC),$(filter $(CC),mingw32 mingw64))
# Console
CPP_LIBS=-lwinmm -lkernel32 -luser32 -lgdi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lmsimg32 -lwininet -ladvapi32 -lmapi32 -limm32
HRB_LIBS = -lgtwin -lgtstd -lhbpcre -lhbrtl -lhbvmmt -lhbcpage -lhblang -lhbmacro -lhbcommon -lhbpp -lhbwin -lhbtip
HRB_LIBS += -lhbrdd -lrddntx -lrddcdx -lrddfpt -lhbsix -lxhb -lhbcplr -lhbziparc -lhbzlib -lhbzebra -lhbmzip -lminizip -lpng -lhbct
HRB_LIBS += -lhbxpp -lhbhttpd
# hbssl
HRB_LIBS += -lhbssl -lhbssls -llibeay32 -lssleay32 -lcrypto -lssl
# hbcurl
HRB_LIBS += -llibcurl -lcrypto_curl -lssl_curl
APP_LIBS=$(CPP_LIBS) $(HRB_LIBS)
LNK_FLAGS=-Wl,--allow-multiple-definition -Wall -s -mconsole -L$(CPP_LIB_DIR) -L$(HRB_LIB_DIR) -L$(HRB_LIB_DIR)\hbssl -L$(HRB_LIB_DIR)\hbcurl -Wl,--enable-stdcall-fixup -Wl,--start-group $(APP_LIBS) -Wl,--end-group
endif
#bcc32
ifeq ($(CC),bcc32)
CPP_LIBS = winmm.lib kernel32.lib user32.lib gdi32.lib advapi32.lib ws2_32.lib iphlpapi.lib winspool.lib comctl32.lib comdlg32.lib shell32.lib uuid.lib ole32.lib oleaut32.lib mpr.lib mapi32.lib imm32.lib msimg32.lib wininet.lib hbpcre.lib hbzlib.lib cw32mt.lib import32.lib
HRB_LIBS = gtgui gtwin gtstd hbpcre hbrtl hbvmmt hbcpage hblang hbmacro hbcommon hbpp hbwin hbtip
HRB_LIBS += hbrdd rddntx rddcdx rddfpt hbsix xhb hbcplr hbziparc hbzlib hbzebra hbmzip minizip png hbct hbxpp hbhttpd
# hbssl
HRB_LIBS += hbssl hbssls libeay32 ssleay32
# hbcurl
HRB_LIBS += hbcurl hbcurls libcurl libcrypto libssl libssh2 libz
APP_LIBS = $(CPP_LIBS) $(HRB_LIBS)
LNK_FLAGS := -Gn -aa -Tpe -s -L$(CPP_LIB_DIR) -L$(CPP_LIB_DIR)\win32 -L$(CPP_LIB_DIR)\win32\psdk -L$(HRB_LIB_DIR) -L$(HRB_LIB_DIR)\hbssl -L$(HRB_LIB_DIR)\hbcurl
endif
$(APP_EXE) : $(APP_EXE_OBJ)
ifeq ($(CC),$(filter $(CC),mingw32 mingw64))
$(LNK_EXE) -o $(APP_EXE) $(APP_EXE_OBJ) $(LNK_FLAGS)
endif
ifeq ($(CC),bcc32)
$(LNK_EXE) $(LNK_FLAGS) c0x32.obj $(APP_EXE_OBJ),$(APP_EXE),,$(APP_LIBS),,
endif
#------------------------------------------------------------
# .prg -> .c -> .obj
#------------------------------------------------------------
#--------------------------------------------------------
# $@:目前的目標項目名稱。
# $<:代表目前的相依性項目。
# $*:代表目前的相依性項目,但不含副檔名。
# $?:代表需要重建(被修改)的相依性項目。
#--------------------------------------------------------
$(OBJ_DIR)\basecontroller.c : $(PRG_DIR)\basecontroller.prg
$(HRB_EXE) $(PRG_FLAGS) $< -o$@
$(OBJ_DIR)\basecontroller.o : $(OBJ_DIR)\basecontroller.c
$(CPP_EXE) $(CPP_FLAGS) -o$@ $<
#
$(OBJ_DIR)\baseservice.c : $(PRG_DIR)\baseservice.prg
$(HRB_EXE) $(PRG_FLAGS) $< -o$@
$(OBJ_DIR)\baseservice.o : $(OBJ_DIR)\baseservice.c
$(CPP_EXE) $(CPP_FLAGS) -o$@ $<
#
$(OBJ_DIR)\status_controller.c : $(PRG_DIR)\status_controller.prg
$(HRB_EXE) $(PRG_FLAGS) $< -o$@
$(OBJ_DIR)\status_controller.o : $(OBJ_DIR)\status_controller.c
$(CPP_EXE) $(CPP_FLAGS) -o$@ $<
#
$(OBJ_DIR)\status_service.c : $(PRG_DIR)\status_service.prg
$(HRB_EXE) $(PRG_FLAGS) $< -o$@
$(OBJ_DIR)\status_service.o : $(OBJ_DIR)\status_service.c
$(CPP_EXE) $(CPP_FLAGS) -o$@ $<
#
$(OBJ_DIR)\wsRestful.c : $(PRG_DIR)\wsRestful.prg
$(HRB_EXE) $(PRG_FLAGS) $< -o$@
$(OBJ_DIR)\wsRestful.o : $(OBJ_DIR)\wsRestful.c
$(CPP_EXE) $(CPP_FLAGS) -o$@ $<
#
$(OBJ_DIR)\hbhttpd_core.c : $(PRG_DIR)\hbhttpd_core.prg
$(HRB_EXE) $(PRG_FLAGS) $< -o$@
$(OBJ_DIR)\hbhttpd_core.o : $(OBJ_DIR)\hbhttpd_core.c
$(CPP_EXE) $(CPP_FLAGS) -o$@ $<
#---[end]---
修改要使用的 CC=???、restFul 存放路徑、hb32 路徑、C compiler 路徑.
Change CC=???、restFul path、hb32 path、C compiler path.
然後執行 : 清除: mingw32-make.exe -f makefile.mak clean
編譯: mingw32-make.exe -f makefile.mak
Then run: clean: mingw32-make.exe -f makefile.mak clean
compiler: mingw32-make.exe -f makefile.mak
執行結果:
Result:
download:
https://app.box.com/s/yqsgz2u8i3s0c8o4ey9y6s68lse42aub