diff --git a/Makefile b/Makefile index 827b66a..71b3484 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ else all: compile-$(TARGET) @echo "=======The ethersex project========" @echo "Compiled for: $(MCU) at $(FREQ)Hz" - @${TOPDIR}/scripts/size $(TARGET) $(MCU) + @$(CONFIG_SHELL) ${TOPDIR}/scripts/size $(TARGET) $(MCU) @echo "===================================" endif .PHONY: all @@ -169,10 +169,10 @@ $(ECMD_PARSER_SUPPORT)_META_SRC += protocols/ecmd/ecmd_defs.m4 ${named_pin_simpl y_META_SRC += $(y_NP_SIMPLE_META_SRC) meta.c: $(y_META_SRC) - @m4 `scripts/m4-defines` $^ > $@ + $(M4) `scripts/m4-defines` $^ > $@ meta.h: scripts/meta_header_magic.m4 meta.m4 - @m4 `scripts/m4-defines` $^ > $@ + $(M4) `scripts/m4-defines` $^ > $@ ############################################################################## @@ -234,7 +234,7 @@ embed/%: embed/%.cpp embed/%: embed/%.m4 - @if ! m4 `scripts/m4-defines` $< > $@; \ + @if ! $(M4) `scripts/m4-defines` $< > $@; \ then $(RM) $@; echo "--> Don't include $@ ($<)";\ else echo "--> Include $@ ($<)"; fi @@ -247,7 +247,7 @@ embed/%: embed/%.sh $(OBJCOPY) -O binary -R .eeprom $< $@ ifeq ($(VFS_INLINE_SUPPORT),y) @$(MAKE) -C core/vfs vfs-concat TOPDIR=../.. no_deps=t - @core/vfs/do-embed $(INLINE_FILES) + $(CONFIG_SHELL) core/vfs/do-embed $(INLINE_FILES) endif ############################################################################## @@ -263,7 +263,8 @@ endif ############################################################################## -CONFIG_SHELL := $(shell if [ x"$$OSTYPE" = x"darwin10.0" ]; then echo /opt/local/bin/bash; \ +### Special case for MacOS X (darwin10.0) and FreeBSD +CONFIG_SHELL := $(shell if [ x"$$OSTYPE" = x"darwin10.0" ] || [ x"$$OSTYPE" = x"FreeBSD" ]; then echo /opt/local/bin/bash; \ elif [ -x "$$BASH" ]; then echo $$BASH; \ elif [ -x /bin/bash ]; then echo /bin/bash; \ elif [ -x /usr/local/bin/bash ]; then echo /usr/local/bin/bash; \ @@ -323,7 +324,7 @@ PINNING_FILES=pinning/internals/header.m4 \ $(wildcard pinning/internals/hackery_$(MCU).m4) \ $(wildcard pinning/hardware/$(HARDWARE).m4) pinning/internals/footer.m4 pinning.c: $(PINNING_FILES) autoconf.h - @m4 -I$(TOPDIR)/pinning `scripts/m4-defines` $(PINNING_FILES) > $@ + $(M4) -I$(TOPDIR)/pinning `scripts/m4-defines` $(PINNING_FILES) > $@ ############################################################################## diff --git a/core/portio/Makefile b/core/portio/Makefile index 867b1ef..53d95ce 100644 --- a/core/portio/Makefile +++ b/core/portio/Makefile @@ -28,7 +28,7 @@ NP_CONFIG ?= $(TOPDIR)/pinning/named_pin/default core/portio/named_pin.c: core/portio/user_config.c core/portio/user_config.c: $(NP_CONFIG) - @core/portio/cfgpp $< + $(CONFIG_SHELL) core/portio/cfgpp $< # extend normal clean rule CLEAN_FILES += core/portio/user_config.h core/portio/user_config.c \ diff --git a/core/vfs/do-embed b/core/vfs/do-embed index eddd44c..ff01253 100755 --- a/core/vfs/do-embed +++ b/core/vfs/do-embed @@ -21,6 +21,9 @@ # http://www.gnu.org/copyleft/gpl.html # +STAT_ARGS="-c %s" +[ `uname` = "FreeBSD" ] && STAT_ARGS="-f %z" + (cat < SPM_PAGESIZE @@ -40,7 +43,7 @@ fgrep -q "#define VFS_INLINE_HTML_CLEAN_SUPPORT" autoconf.h && do_strip=true while true; do fn="$1"; shift test "x$fn" = "x" && { - SZ=$(stat -c %s ethersex.bin) + SZ=$(stat ${STAT_ARGS} ethersex.bin) echo "Final size of ethersex.bin is $SZ." exit 0 } diff --git a/scripts/Menuconfig b/scripts/Menuconfig index 42a8212..9fb09d4 100644 --- a/scripts/Menuconfig +++ b/scripts/Menuconfig @@ -28,7 +28,7 @@ single_menu_mode= set -h +o posix ### use GNU sed from macports instead of BSD sed on MacOS X -if [ x$OSTYPE = x"darwin10.0" ]; then +if [ x$OSTYPE = x"darwin10.0" ] || [ x$OSTYPE = x"FreeBSD" ] ; then SED=gsed else SED=sed diff --git a/scripts/add-hardware b/scripts/add-hardware index ff77cc4..233d689 100755 --- a/scripts/add-hardware +++ b/scripts/add-hardware @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh usage() { echo "Usage:" @@ -416,7 +416,7 @@ grep -v -e "^HARDWARE=" -e "^$HARDWARE=y" .config > .config.new echo -e "HARDWARE=$hw\n$hw=y" >> .config.new mv -f .config.new .config -function l_editor() { +l_editor() { echo "launching editor for $1 ..." if [ -n "$EDITOR" ]; then $EDITOR $1 diff --git a/scripts/defaults.mk b/scripts/defaults.mk index 7a40826..ff69546 100644 --- a/scripts/defaults.mk +++ b/scripts/defaults.mk @@ -7,11 +7,16 @@ RM = rm -f AVRDUDE = avrdude AVRDUDE_BAUDRATE = 115200 AWK = gawk -M4 = m4 -### use GNU sed from macports instead of BSD sed on MacOS X -SED = $(shell if [ x"$$OSTYPE" = x"darwin10.0" ]; then echo gsed; \ +### use GNU sed from macports instead of BSD sed on MacOS X and FreeBSD +ifeq ($(shell uname),FreeBSD) +M4 = gm4 +SED = gsed +else +M4 = m4 +SED = $(shell if [ x"$$OSTYPE" = x"darwin10.0" ] ; then echo gsed; \ else echo sed; fi) +endif HOSTCC := gcc export HOSTCC diff --git a/scripts/m4-defines b/scripts/m4-defines index b5f6936..05dd7cd 100755 --- a/scripts/m4-defines +++ b/scripts/m4-defines @@ -2,7 +2,7 @@ ### use GNU sed from macports instead of BSD sed on MacOS X ### BSD sed does not support -r option -if [ x"$OSTYPE" = x"darwin10.0" ]; then +if [ x"$OSTYPE" = x"darwin10.0" ] || [ x"$OSTYPE" = x"FreeBSD" ]; then SED="gsed" else SED="sed" diff --git a/scripts/pinning_hardware_list.sh b/scripts/pinning_hardware_list.sh index 2342cca..5ecc265 100755 --- a/scripts/pinning_hardware_list.sh +++ b/scripts/pinning_hardware_list.sh @@ -1,7 +1,10 @@ -#!/bin/bash +#!/bin/sh + +SED=sed +[ `uname` = "FreeBSD" ] && SED=gsed for profile in $(ls pinning/hardware/ | sort | grep '\.m4$'); do - echo $profile | sed 's/_/:\n/; s/.m4//' \ - | sed -e 's/\(^.\)/\U\1/' | tr -d "\n" + echo $profile | ${SED} 's/_/:\n/; s/.m4//' \ + | ${SED} -e 's/\(^.\)/\U\1/' | tr -d "\n" echo " $profile" | sed 's/.m4//'; done