generate config.mk.
authorNIIBE Yutaka <gniibe@fsij.org>
Mon, 4 Sep 2017 01:53:49 +0000 (10:53 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Mon, 4 Sep 2017 02:36:08 +0000 (11:36 +0900)
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
.gitignore
ChangeLog
src/Makefile
src/configure

index 1cc3a47..16a55e8 100644 (file)
@@ -6,3 +6,4 @@ src/INDEX
 src/README
 src/*.inc
 src/disk-on-rom.h
+src/config.mk
index c2b01e8..b37423e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2017-09-04  NIIBE Yutaka  <gniibe@fsij.org>
 
        * src/Makefile: Rename from src/Makefile.in (as done in gnuk).
+       * src/configure: Generate config.mk.
 
 2017-09-01  NIIBE Yutaka  <gniibe@fsij.org>
 
index dc7d4a3..6d4726f 100644 (file)
@@ -6,37 +6,31 @@ PROJECT = neug
 CHOPSTX = ../chopstx
 FRAUCHEKY = ../fraucheky
 
-# Define linker script file here
-LDSCRIPT= @LDSCRIPT@
-
 CSRC = main.c sha256.c neug.c
-CHIP=@CHIP@
-USE_SYS = @USE_SYS@
+
+include config.mk
+
 USE_USB = yes
 USE_ADC = yes
-EMULATION=@EMULATION@
-
-@ENABLE_FRAUCHEKY@include $(FRAUCHEKY)/src.mk
 
-@HEXOUTPUT_MAKE_OPTION@
+ifneq ($(ENABLE_FRAUCHEKY),)
+include $(FRAUCHEKY)/src.mk
+endif
 
 ###################################
-CROSS = @CROSS@
 CC   = $(CROSS)gcc
 LD   = $(CROSS)gcc
 OBJCOPY   = $(CROSS)objcopy
 
-MCU   = @MCU@
 CWARN = -Wall -Wextra -Wstrict-prototypes
-# DEFS: Add  
-DEFS  = @USE_SYS3@ @DEF_EMULATION@
 OPT   = -O3 -Os -g
-LIBS  = @LIBS@
 
 #######################
 include $(CHOPSTX)/rules.mk
 
-@ENABLE_FRAUCHEKY@include $(FRAUCHEKY)/build.mk
+ifneq ($(ENABLE_FRAUCHEKY),)
+include $(FRAUCHEKY)/build.mk
+endif
 ###################################
 
 board.h:
@@ -47,5 +41,5 @@ build/sha256.o: OPT = -O3 -g
 build/neug.o: OPT = -O3 -g
 
 distclean:: clean
-       -rm -f neug.ld config.h board.h Makefile \
+       -rm -f neug.ld config.h board.h config.mk \
               usb-strings.c.inc usb-vid-pid-ver.c.inc
index fa5fd0b..ddaae35 100755 (executable)
@@ -145,11 +145,11 @@ fi
 
 if ! test "$with_fraucheky" = "no"; then
   ../fraucheky/configure $with_fraucheky $with_index $REVISION $REVISION_CHOPSTX $REVISION_FRAUCHEKY
-  ENABLE_FRAUCHEKY=""
+  enable_fraucheky=yes
   FRAUCHEKY_DEFINE="#define FRAUCHEKY_SUPPORT 1"
   FRAUCHEKY_MSC_DEFINE="#define MSC_INTERFACE_NO    2"
 else
-  ENABLE_FRAUCHEKY="# "
+  enable_fraucheky=""
   FRAUCHEKY_DEFINE="#undef FRAUCHEKY_SUPPORT"
   FRAUCHEKY_MSC_DEFINE="#undef MSC_INTERFACE_NO"
   if ! test -f ../fraucheky/build.mk; then
@@ -198,11 +198,12 @@ esac
 if test "$target" = "GNU_LINUX"; then
   ldscript=""
   chip="gnu-linux"
-  use_sys=""
+  use_sys="yes"
   emulation="yes"
   cross=""
   mcu="none"
   def_emulation="-DGNU_LINUX_EMULATION"
+  enable_hexoutput=""
   libs="-lpthread"
 else
   ldscript="neug.ld"
@@ -212,6 +213,7 @@ else
   cross="arm-none-eabi-"
   mcu="cortex-m3"
   def_emulation=""
+  enable_hexoutput=yes
   libs=""
 fi
 
@@ -225,13 +227,11 @@ if test "$with_dfu" = "yes"; then
   ORIGIN=0x08003000
   FLASH_SIZE=$(expr $FLASH_SIZE - 12)
   DFU_DEFINE="#define DFU_SUPPORT 1"
-  HEXOUTPUT_MAKE_OPTION="ENABLE_OUTPUT_HEX=yes"
 else
   with_dfu=no
   echo "Configured for bare system (no-DFU)"
   ORIGIN=0x08000000
   DFU_DEFINE="#undef DFU_SUPPORT"
-  HEXOUTPUT_MAKE_OPTION=""
 fi
 
 ### !!! Replace following string of "FSIJ" to yours !!! ####
@@ -332,18 +332,17 @@ else
 fi
 
 
-sed -e "s%@LDSCRIPT@%$ldscript%" \
-    -e "s%@CHIP@%$chip%" \
-    -e "s%@USE_SYS@%$use_sys%" \
-    -e "s%@EMULATION@%$emulation%" \
-    -e "s%@CROSS@%$cross%" \
-    -e "s%@MCU@%$mcu%" \
-    -e "s%@DEF_EMULATION@%$def_emulation%" \
-    -e "s%@LIBS@%$libs%" \
-    -e "s%@USE_SYS3@%$use_sys3%" \
-    -e "s%@ENABLE_FRAUCHEKY@%$ENABLE_FRAUCHEKY%" \
-    -e "s%@HEXOUTPUT_MAKE_OPTION@%$HEXOUTPUT_MAKE_OPTION%" \
-       < Makefile.in > Makefile
+(echo "CHIP=$chip";
+ echo "USE_SYS=$use_sys";
+ echo "EMULATION=$emulation";
+ echo "CROSS=$cross";
+ echo "MCU=$mcu";
+ echo "DEFS=$use_sys3 $flash_override $def_emulation";
+ echo "LDSCRIPT=$ldscript";
+ echo "LIBS=$libs";
+ echo "ENABLE_FRAUCHEKY=$enable_fraucheky";
+ echo "ENABLE_OUTPUT_HEX=$enable_hexoutput"
+)      > config.mk
 sed -e "s/@ORIGIN@/$ORIGIN/" -e "s/@FLASH_SIZE@/$FLASH_SIZE/" \
     -e "s/@MEMORY_SIZE@/$MEMORY_SIZE/" \
     -e "s/@FLASH_PAGE_SIZE@/$FLASH_PAGE_SIZE/" \