src/config.mk generation.
authorNIIBE Yutaka <gniibe@fsij.org>
Fri, 11 Aug 2017 12:02:43 +0000 (21:02 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Fri, 11 Aug 2017 12:06:59 +0000 (21:06 +0900)
ChangeLog
regnual/Makefile
src/Makefile [new file with mode: 0644]
src/Makefile.in [deleted file]
src/configure

index 299bc32..a0a8f04 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-11  NIIBE Yutaka  <gniibe@fsij.org>
+
+       * src/configure: Define STM32F103_OVERRIDE_FLASH_SIZE_KB for
+       BULE_PILL.
+
+       * src/configure: Let generate src/config.mk.
+       * src/Makefile: Rename from src/Makefile.in.
+       * regnual/Makefile: Use src/config.mk.
+
 2017-08-03  NIIBE Yutaka  <gniibe@fsij.org>
 
        * src/openpgp.c (cmd_terminate_df): Fix for admin-less mode.
index 48447d5..6a0dddd 100644 (file)
@@ -5,6 +5,8 @@ PROJECT = regnual
 OBJS = regnual.o usb-stm32f103.o reset.o
 LDSCRIPT= regnual.ld
 
+include ../src/config.mk
+
 ###################################
 MCU  = cortex-m3
 
@@ -19,7 +21,7 @@ TOPT = -mthumb -DTHUMB -mno-thumb-interwork
 # Define C warning options here
 CWARN = -Wall -Wextra -Wstrict-prototypes
 MCFLAGS= -mcpu=$(MCU)
-DEFS = -DFREE_STANDING
+DEFS += -DFREE_STANDING
 
 CFLAGS = -O2 -g
 CFLAGS += -Wa,-alms=$(notdir $(<:.c=.lst)) -fpie
diff --git a/src/Makefile b/src/Makefile
new file mode 100644 (file)
index 0000000..aefba17
--- /dev/null
@@ -0,0 +1,75 @@
+# Makefile for Gnuk
+
+# Define project name here
+PROJECT = gnuk
+
+CHOPSTX = ../chopstx
+
+# Define linker script file here
+LDSCRIPT= gnuk.ld
+
+CSRC = main.c call-rsa.c mcu-stm32f103.c \
+       usb_desc.c usb_ctrl.c \
+       usb-ccid.c openpgp.c ac.c openpgp-do.c flash.c \
+       bn.c mod.c \
+       modp256r1.c jpc_p256r1.c ec_p256r1.c call-ec_p256r1.c \
+       modp256k1.c jpc_p256k1.c ec_p256k1.c call-ec_p256k1.c \
+       mod25638.c ecc-edwards.c ecc-mont.c sha512.c \
+       random.c neug.c sha256.c
+
+INCDIR =
+
+CRYPTDIR = ../polarssl
+CRYPTSRCDIR = $(CRYPTDIR)/library
+CRYPTINCDIR = $(CRYPTDIR)/include
+CRYPTSRC = $(CRYPTSRCDIR)/bignum.c $(CRYPTSRCDIR)/rsa.c $(CRYPTSRCDIR)/aes.c
+
+CSRC += $(CRYPTSRC)
+INCDIR += $(CRYPTINCDIR)
+
+include config.mk
+
+USE_EVENTFLAG = yes
+
+ifneq ($(ENABLE_DEBUG),)
+CSRC += debug.c
+endif
+
+ifneq ($(ENABLE_PINPAD),)
+CSRC += pin-$(ENABLE_PINPAD).c
+endif
+
+ifeq ($(ENABLE_PINPAD),dnd)
+CSRC += usb-msc.c
+endif
+
+CHIP=stm32f103
+USE_SYS = yes
+USE_USB = yes
+USE_ADC = yes
+
+###################################
+CROSS = arm-none-eabi-
+CC   = $(CROSS)gcc
+LD   = $(CROSS)gcc
+OBJCOPY   = $(CROSS)objcopy
+
+MCU   = cortex-m3
+CWARN = -Wall -Wextra -Wstrict-prototypes
+OPT   = -O3 -Os -g
+LIBS  =
+
+#######################
+include $(CHOPSTX)/rules.mk
+
+board.h:
+       @echo Please run configure to have a symbolic link \'board.h\'
+       @exit 1
+
+sys.c: board.h
+
+build/bignum.o: OPT = -O3 -g
+
+distclean: clean
+       -rm -f gnuk.ld config.h board.h config.mk \
+              usb-strings.c.inc usb-vid-pid-ver.c.inc
diff --git a/src/Makefile.in b/src/Makefile.in
deleted file mode 100644 (file)
index 5b38585..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-# Makefile for Gnuk
-
-# Define project name here
-PROJECT = gnuk
-
-CHOPSTX = ../chopstx
-
-# Define linker script file here
-LDSCRIPT= gnuk.ld
-
-CSRC = main.c call-rsa.c mcu-stm32f103.c \
-       usb_desc.c usb_ctrl.c \
-       usb-ccid.c openpgp.c ac.c openpgp-do.c flash.c \
-       bn.c mod.c \
-       modp256r1.c jpc_p256r1.c ec_p256r1.c call-ec_p256r1.c \
-       modp256k1.c jpc_p256k1.c ec_p256k1.c call-ec_p256k1.c \
-       mod25638.c ecc-edwards.c ecc-mont.c sha512.c \
-       random.c neug.c sha256.c
-
-INCDIR =
-
-CRYPTDIR = ../polarssl
-CRYPTSRCDIR = $(CRYPTDIR)/library
-CRYPTINCDIR = $(CRYPTDIR)/include
-CRYPTSRC = $(CRYPTSRCDIR)/bignum.c $(CRYPTSRCDIR)/rsa.c $(CRYPTSRCDIR)/aes.c
-
-CSRC += $(CRYPTSRC)
-INCDIR += $(CRYPTINCDIR)
-
-@PINPAD_MAKE_OPTION@
-@DEBUG_MAKE_OPTION@
-@HEXOUTPUT_MAKE_OPTION@
-
-USE_EVENTFLAG = yes
-
-ifneq ($(ENABLE_DEBUG),)
-CSRC += debug.c
-endif
-
-ifneq ($(ENABLE_PINPAD),)
-CSRC += pin-$(ENABLE_PINPAD).c
-endif
-
-ifeq ($(ENABLE_PINPAD),dnd)
-CSRC += usb-msc.c
-endif
-
-CHIP=stm32f103
-USE_SYS = yes
-USE_USB = yes
-USE_ADC = yes
-
-###################################
-CROSS = arm-none-eabi-
-CC   = $(CROSS)gcc
-LD   = $(CROSS)gcc
-OBJCOPY   = $(CROSS)objcopy
-
-MCU   = cortex-m3
-CWARN = -Wall -Wextra -Wstrict-prototypes
-# DEFS: Add  
-DEFS  = @USE_SYS3@
-OPT   = -O3 -Os -g
-LIBS  =
-
-#######################
-include $(CHOPSTX)/rules.mk
-
-board.h:
-       @echo Please run configure to have a symbolic link \'board.h\'
-       @exit 1
-
-sys.c: board.h
-
-build/bignum.o: OPT = -O3 -g
-
-distclean: clean
-       -rm -f gnuk.ld config.h board.h Makefile \
-              usb-strings.c.inc usb-vid-pid-ver.c.inc
index 26f2c59..18f1bd3 100755 (executable)
@@ -43,6 +43,7 @@ pinpad=no
 certdo=no
 hid_card_change=no
 factory_reset=no
+flash_override=""
 
 # Revision number
 if test -e ../.git; then
@@ -165,6 +166,8 @@ MEMORY_SIZE=20
 
 # Settings for TARGET
 case $target in
+BLUE_PILL)
+  flash_override="-DSTM32F103_OVERRIDE_FLASH_SIZE_KB" ;;
 CQ_STARM|STBEE_MINI)
   if test "$with_dfu" = "default"; then
     with_dfu=yes;
@@ -365,11 +368,12 @@ else
 fi
 
 
-sed -e "s%@USE_SYS3@%$use_sys3%" \
-    -e "s%@DEBUG_MAKE_OPTION@%$DEBUG_MAKE_OPTION%" \
-    -e "s%@PINPAD_MAKE_OPTION@%$PINPAD_MAKE_OPTION%" \
-    -e "s%@HEXOUTPUT_MAKE_OPTION@%$HEXOUTPUT_MAKE_OPTION%" \
-       < Makefile.in > Makefile
+echo -e "DEFS=$use_sys3 $flash_override" '\n'      \
+     "$DEBUG_MAKE_OPTION" '\n'  \
+     "$PINPAD_MAKE_OPTION" '\n' \
+     "$HEXOUTPUT_MAKE_OPTION"   \
+       > config.mk
+
 if test "$certdo" = "yes"; then
   sed -e "/^@CERTDO_SUPPORT_START@$/ d" -e "/^@CERTDO_SUPPORT_END@$/ d" \
       -e "s/@ORIGIN@/$ORIGIN/" -e "s/@FLASH_SIZE@/$FLASH_SIZE/" \