From e8eff6256799dceff016709fe169a6d0bdc27d2b Mon Sep 17 00:00:00 2001 From: kubodera_yuichi Date: Thu, 7 Jan 2010 12:52:49 +0000 Subject: [PATCH] =?UTF-8?q?=E5=BF=85=E8=A6=81=E3=81=AA=E3=82=AA=E3=83=96?= =?UTF-8?q?=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E4=B8=80=E3=81=A4=E3=81=AB=E5=9B=BA=E3=82=81?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@156 ff987cc8-cf2f-4642-8568-d52cce064691 --- Makefile | 31 +++++++++++++++++++------------ tools/merge_lib_objs.plx | 19 +++++++++++++++++++ tools/merge_lib_objs_hsm.plx | 31 +++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 12 deletions(-) create mode 100644 tools/merge_lib_objs.plx create mode 100644 tools/merge_lib_objs_hsm.plx diff --git a/Makefile b/Makefile index 4685314..f60ae0a 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ # DEV_CYGWIN = FALSE # USE_HSM = TRUE -#DEV_CYGWIN = TRUE -USE_HSM = TRUE +DEV_CYGWIN = TRUE +#USE_HSM = TRUE ifeq ($(USE_HSM),TRUE) @@ -68,6 +68,8 @@ PACKAGE_DIR = ./package # OPENSSL_DIR = ./openssl-1.0.0-beta2 OPENSSL_DIR = ./openssl-0.9.8k +TARGET_LIB = lib_gen_id.a + TARGET = gen_id KEYS_C = cr_eFuse_iv_prod.c \ @@ -84,16 +86,19 @@ KEYS_C += cr_eFuse_privKey_prod.c cr_eFuse_pubKey_prod.c \ cr_NCT2_priv_dev.c endif # USE_DUMMY_KEY -SRCS = main.c cr_generate_id.c cr_id_util.c cr_keyPair.c \ +SRCS = main.c +OBJS = $(notdir $(SRCS:.c=.o)) + +LIB_SRCS = cr_generate_id.c cr_id_util.c cr_keyPair.c \ cr_device_cert.c cr_enc_id.c cr_alloc.c \ cr_hsm_code.c cr_hsm_alloc.c cr_hsm_bignum.c - -OBJS = $(notdir $(SRCS:.c=.o)) +LIB_OBJS = $(notdir $(LIB_SRCS:.c=.o)) CFLAGS = -Wall -DMEXP=216091 -msse2 -DHAVE_SSE2 CPPFLAGS= -I. -I$(OPENSSL_DIR)/include -I$(OPENSSL_DIR)/crypto/ec LDFLAGS = -mwindows -L$(OPENSSL_DIR) LDLIBS = -lcrypto -lssl +MERGE_PROG = merge_lib_objs.plx ifeq ($(DEV_CYGWIN),TRUE) CC := C:/Cygwin/bin/gcc @@ -115,12 +120,12 @@ ifeq ($(USE_HSM),TRUE) CFLAGS += -DUSE_HSM CPPFLAGS+= $(NFAST_CPPFLAGS) LDLIBS += $(NFAST_LDLIBS) +MERGE_PROG = merge_lib_objs_hsm.plx endif - .SUFFIXES: -all: package_build $(KEYS_C) $(TARGET) +all: package_build $(KEYS_C) $(TARGET_LIB) $(TARGET) # install: $(TARGET) # install -c -m 777 $(TARGET) ../bin @@ -133,10 +138,12 @@ package_build : cd $(PACKAGE_DIR);make endif -$(TARGET): $(OBJS) - $(LD) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS) +$(TARGET): $(OBJS) $(TARGET_LIB) + $(LD) $(LDFLAGS) $(OBJS) -o $@ $(TARGET_LIB) -$(OBJS): $(HEADS) Makefile +$(TARGET_LIB): $(LIB_OBJS) + ar rcs $@ $(LIB_OBJS) + perl tools/$(MERGE_PROG) %.o:%.c $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ @@ -184,9 +191,9 @@ cr_NCT2_pub_dev.c : $(DEV_DER_KEY_DIR)/NCT2_pub.der .PHONY: clean clobber clean: - $(RM) $(OBJS) $(TARGET).exe $(KEYS_C) $(KEYS_H) + $(RM) $(LIB_OBJS) $(OBJS) $(TARGET).exe $(TARGET_LIB) $(KEYS_C) $(KEYS_H) clobber: - $(RM) $(OBJS) $(TARGET).exe $(KEYS_C) $(KEYS_H) + $(RM) $(LIB_OBJS) $(OBJS) $(TARGET).exe $(TARGET_LIB) $(KEYS_C) $(KEYS_H) cd $(PACKAGE_DIR);make clobber diff --git a/tools/merge_lib_objs.plx b/tools/merge_lib_objs.plx new file mode 100644 index 0000000..b5832b0 --- /dev/null +++ b/tools/merge_lib_objs.plx @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w +use strict; + +print "cd dep_objs/\n"; +chdir 'dep_objs'; + +print "ar x ../openssl-0.9.8k/libcrypto.a\n"; +system "ar", "x", "../openssl-0.9.8k/libcrypto.a"; + +print "ar x ../openssl-0.9.8k/libssl.a\n"; +system "ar", "x", "../openssl-0.9.8k/libssl.a"; + +my @object_files = glob "*.o"; + +print "ar rcs ../lib_gen_id.a @object_files\n"; +system "ar", "rcs", "../lib_gen_id.a", @object_files; + +print "rm @object_files\n"; +system "rm", @object_files; diff --git a/tools/merge_lib_objs_hsm.plx b/tools/merge_lib_objs_hsm.plx new file mode 100644 index 0000000..03f6568 --- /dev/null +++ b/tools/merge_lib_objs_hsm.plx @@ -0,0 +1,31 @@ +#!/usr/bin/perl -w +use strict; + +print "cd dep_objs/\n"; +chdir 'dep_objs'; + +print "ar x ../openssl-0.9.8k/libcrypto.a\n"; +system "ar", "x", "../openssl-0.9.8k/libcrypto.a"; + +print "ar x ../openssl-0.9.8k/libssl.a\n"; +system "ar", "x", "../openssl-0.9.8k/libssl.a"; + +print "ar x /opt/nfast/c/ctd/gcc/lib/libnfkm.a"; +system "ar", "x", "/opt/nfast/c/ctd/gcc/lib/libnfkm.a"; + +print "ar x /opt/nfast/c/ctd/gcc/lib/libnfstub.a"; +system "ar", "x", "/opt/nfast/c/ctd/gcc/lib/libnfstub.a"; + +print "ar x /opt/nfast/c/ctd/gcc/lib/libnflog.a"; +system "ar", "x", "/opt/nfast/c/ctd/gcc/lib/libnflog.a"; + +print "ar x /opt/nfast/c/ctd/gcc/lib/libcutils.a"; +system "ar", "x", "/opt/nfast/c/ctd/gcc/lib/libcutils.a"; + +my @object_files = glob "*.o"; + +print "ar rcs ../lib_gen_id.a @object_files\n"; +system "ar", "rcs", "../lib_gen_id.a", @object_files; + +print "rm @object_files\n"; +system "rm", @object_files;