Skip to content

Commit

Permalink
buildsystem: add support for freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Dietrich committed Jun 12, 2010
1 parent efe142f commit 5e7d237
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 19 deletions.
15 changes: 8 additions & 7 deletions Makefile
Expand Up @@ -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
Expand Down Expand Up @@ -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` $^ > $@

##############################################################################

Expand Down Expand Up @@ -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

Expand All @@ -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

##############################################################################
Expand All @@ -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; \
Expand Down Expand Up @@ -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) > $@


##############################################################################
Expand Down
2 changes: 1 addition & 1 deletion core/portio/Makefile
Expand Up @@ -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 \
Expand Down
5 changes: 4 additions & 1 deletion core/vfs/do-embed
Expand Up @@ -21,6 +21,9 @@
# http://www.gnu.org/copyleft/gpl.html
#

STAT_ARGS="-c %s"
[ `uname` = "FreeBSD" ] && STAT_ARGS="-f %z"

(cat <<EOF
#include <avr/pgmspace.h>
SPM_PAGESIZE
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/Menuconfig
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/add-hardware
@@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/sh

usage() {
echo "Usage:"
Expand Down Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions scripts/defaults.mk
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/m4-defines
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions 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

0 comments on commit 5e7d237

Please sign in to comment.