这是我的生成文件。
#starts here
#Openssl constants
Openssl_include=-I/usr/local/openssl/include
Openssl_lib=-L/usr/local/openssl/lib -lcrypto -ldl
#Wolfssl constants
Wolfssl_include=-I/usr/local/wolfssl/include -LLIBDIR -DWOLFSSL_SHA512
Wolfssl_lib=-L/usr/local/wolfssl/lib -lwolfssl
#Mbedssl constants
Mbedssl_include=-I/usr/local/mbedssl/include
Mbedssl_lib=-L/usr/local/mbedssl/lib -lmbedcrypto
SRC=CAL_aes.c CAL_sha.c CAL_cmac.c CAL_rsa.c
OBJ=$(patsubst %.c,%.o,$(SRC))
M_OBJ=$(patsubst %.c,M_%.o,$(SRC))
M_fpic_OBJ=$(patsubst %.c,M_fpic_%.o,$(SRC))
O_OBJ=$(patsubst %.c,O_%.o,$(SRC))
O_fpic_OBJ=$(patsubst %.c,O_fpic_%.o,$(SRC))
W_OBJ=$(patsubst %.c,W_%.o,$(SRC))
W_fpic_OBJ=$(patsubst %.c,W_fpic_%.o,$(SRC))
.PHONY: clean Openssl Wolfssl Mbedssl compile_openssl compile_wolfssl compile_mbedssl
compile_openssl: $(OBJ)
%.o: %.c
cc -c $^ -o $(patsubst $@,O_$@,$@) $(Openssl_include) $(Openssl_lib)
cc -c -fpic $^ -o $(patsubst $@,O_fpic_$@,$@) $(Openssl_include) $(Openssl_lib)
Openssl: compile_openssl
ar rc libO_CAL_crypto.a $(O_OBJ)
cc -shared -o libO_CAL_crypto.so $(O_fpic_OBJ)
compile_wolfssl: $(OBJ)
%.o: %.c
cc -c $^ -o $(patsubst $@,W_$@,$@) $(Wolfssl_include) $(Wolfssl_lib)
cc -c -fpic $^ -o $(patsubst $@,W_fpic_$@,$@) $(Wolfssl_include) $(Wolfssl_lib)
Wolfssl: compile_wolfssl
ar rc libW_CAL_crypto.a $(W_OBJ)
cc -shared -o libW_CAL_crypto.so $(W_fpic_OBJ)
compile_mbedssl: $(OBJ)
%.o: %.c
cc -c $^ -o $(patsubst $@,M_$@,$@) $(Mbedssl_include) $(Mbedssl_lib)
cc -c -fpic $^ -o $(patsubst $@,M_fpic_$@,$@) $(Mbedssl_include) $(Mbedssl_lib)
Mbedssl: compile_mbedssl
ar rc libM_CAL_crypto.a $(M_OBJ)
cc -shared -o libM_CAL_crypto.so $(M_fpic_OBJ)
#ends here
不管我是调用 Make Openssl 、 Make Wolfssl 还是 Make Mbedssl。始终调用目标 Make Mbedssl。我尝试重新排列目标,并且始终调用最后一个位置的目标,而不管我从命令行传递的目标是什么。谢谢。