Simplified host OS platform detection in Makefiles

This commit is contained in:
Ilya Dmitrichenko 2012-02-21 23:57:22 +00:00 committed by David Kopf
parent 745f071c98
commit 9c99d46e24
17 changed files with 66 additions and 134 deletions

View File

@ -21,6 +21,15 @@ ifeq ($(DEFINES),)
endif endif
endif endif
ifndef HOST_OS
ifeq ($(OS),Windows_NT)
$(warning Windows (NT) deteced.)
HOST_OS := Windows
else
HOST_OS := $(shell uname)
endif
endif
usage: usage:
@echo "make MAKETARGETS... [TARGET=(TARGET)] [savetarget] [targets]" @echo "make MAKETARGETS... [TARGET=(TARGET)] [savetarget] [targets]"

View File

@ -1,15 +1,5 @@
# $Id: Makefile.avr,v 1.27 2010/12/22 21:13:09 dak664 Exp $ # $Id: Makefile.avr,v 1.27 2010/12/22 21:13:09 dak664 Exp $
### Check if we are running under Windows
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
.SUFFIXES: .SUFFIXES:
### Optimization setting. $make OPTI=0 for easier debugging of changed source file(s) ### Optimization setting. $make OPTI=0 for easier debugging of changed source file(s)

View File

@ -72,8 +72,7 @@ CUSTOM_RULE_C_TO_O=yes
CFLAGS += -I$(OBJECTDIR) -I$(CONTIKI_CPU)/board -DBOARD=$(TARGET) CFLAGS += -I$(OBJECTDIR) -I$(CONTIKI_CPU)/board -DBOARD=$(TARGET)
$(OBJECTDIR)/board.h: $(OBJECTDIR) $(OBJECTDIR)/board.h: $(OBJECTDIR)
ifneq (,$(findstring Windows,$(OS))) ifeq ($(HOST_OS),Windows)
${info Cygwin detected.}
ln -f $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h ln -f $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
else else
ln -sf ../$(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h ln -sf ../$(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h

View File

@ -166,10 +166,8 @@ endif
FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/stm32w_flasher FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/stm32w_flasher
# Check if we are running under Windows # Check if we are running under Windows
ifdef OS ifeq ($(HOST_OS),Windows)
ifneq (,$(findstring Windows,$(OS))) FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/stm32w_flasher.exe
FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/stm32w_flasher.exe
endif
endif endif

View File

@ -13,12 +13,12 @@ export doclatex := NO
export docroot := ../ export docroot := ../
# Get appropriate root for doxygen path cutoff # Get appropriate root for doxygen path cutoff
ifneq (,$(findstring Windows,$(OS))) ifeq ($(HOST_OS),Windows)
# on windows need to convert cygwin path to windows path for doxygen # on windows need to convert cygwin path to windows path for doxygen
ifneq (,$(findstring cygdrive,$(pwd))) ifneq (,$(findstring cygdrive,$(pwd)))
cygroot = $(subst /,$(space),$(patsubst /cygdrive/%,%,$(pwd))) cygroot = $(subst /,$(space),$(patsubst /cygdrive/%,%,$(pwd)))
export docroot = $(firstword $(cygroot)):/$(subst $(space),/,$(wordlist 2,$(words $(cygroot)),$(cygroot))) export docroot = $(firstword $(cygroot)):/$(subst $(space),/,$(wordlist 2,$(words $(cygroot)),$(cygroot)))
endif endif
endif endif
.PHONY: clean html pdf upload .PHONY: clean html pdf upload

View File

@ -11,14 +11,6 @@ ifndef CONTIKI
$(error CONTIKI not defined!) $(error CONTIKI not defined!)
endif endif
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
### Assuming simulator quickstart if no JNI library name set from Cooja ### Assuming simulator quickstart if no JNI library name set from Cooja
ifndef LIBNAME ifndef LIBNAME
QUICKSTART=1 QUICKSTART=1

View File

@ -68,23 +68,15 @@ send: $(CONTIKI)/tools/codeprop.c
### System dependent Makefile ### System dependent Makefile
ifndef WINDIR ifeq ($(HOST_OS),FreeBSD)
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
ifeq (${HOSTTYPE},FreeBSD)
# settings for FreeBSD # settings for FreeBSD
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.freebsd -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.freebsd
else else
ifndef WINDIR ifeq ($(HOST_OS),Windows)
# settings for unix # settings for Windows
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.win
else else
# settings for windows # settings for an arbitary unix-like platform
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.win -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix
endif endif
endif endif

View File

@ -31,23 +31,15 @@ include $(CONTIKIAVR)/Makefile.avr
avr-objdump -zhD $< > $@ avr-objdump -zhD $< > $@
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
ifeq ($(PRGBOARD), ) ifeq ($(PRGBOARD), )
PRGBOARD = mib510 PRGBOARD = mib510
endif endif
ifeq ($(PORT), ) ifeq ($(PORT), )
ifndef WINDIR ifeq ($(HOST_OS), Windows)
PORT = /dev/ttyUSB0
else
PORT = COM1 PORT = COM1
else
PORT = /dev/ttyUSB0
endif endif
endif endif

View File

@ -19,10 +19,8 @@ include $(CONTIKI)/cpu/stm32w108/Makefile.stm32w108
SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-linux SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-linux
ifdef OS ifeq ($(HOST_OS),Windows)
ifneq (,$(findstring Windows,$(OS))) SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-windows
SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-windows
endif
endif endif

View File

@ -18,10 +18,8 @@ include $(CONTIKI)/cpu/stm32w108/Makefile.stm32w108
SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-linux SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-linux
ifdef OS ifeq ($(HOST_OS),Windows)
ifneq (,$(findstring Windows,$(OS))) SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-windows
SERIALDUMP = $(CONTIKI)/tools/stm32w/serialdump-windows
endif
endif endif

View File

@ -26,23 +26,15 @@ include $(CONTIKIAVR)/Makefile.avr
avr-objdump -zhD $< > $@ avr-objdump -zhD $< > $@
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
ifeq ($(PRGBOARD), ) ifeq ($(PRGBOARD), )
PRGBOARD = mib510 PRGBOARD = mib510
endif endif
ifeq ($(PORT), ) ifeq ($(PORT), )
ifndef WINDIR ifeq ($(HOST_OS),Windows)
PORT = /dev/ttyS0
else
PORT = COM1 PORT = COM1
else
PORT = /dev/ttyS0
endif endif
endif endif

View File

@ -7,7 +7,7 @@ CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o}
CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c leds.c leds-arch.c cfs-posix.c cfs-posix-dir.c dlloader.c CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c leds.c leds-arch.c cfs-posix.c cfs-posix-dir.c dlloader.c
ifeq ($(OS),Windows_NT) ifeq ($(HOST_OS),Windows)
CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c
else else
CONTIKI_TARGET_SOURCEFILES += tapdev-drv.c CONTIKI_TARGET_SOURCEFILES += tapdev-drv.c
@ -21,7 +21,7 @@ endif
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
ifeq ($(OS),Windows_NT) ifeq ($(HOST_OS),Windows)
TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
endif endif

View File

@ -24,25 +24,17 @@ endif
### System dependent Makefile ### System dependent Makefile
ifndef WINDIR ifeq ($(HOST_OS),FreeBSD)
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
ifeq (${HOSTTYPE},FreeBSD)
# settings for FreeBSD # settings for FreeBSD
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.freebsd -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.freebsd
else else
ifndef WINDIR ifeq ($(HOST_OS),Windows)
# settings for unix # settings for Windows
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.win
else else
# settings for windows # settings for an arbitary unix-like platform
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.win -include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix
endif endif
endif endif
# If we are not running under Windows, we assume Linux # If we are not running under Windows, we assume Linux

View File

@ -13,7 +13,7 @@ CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c leds.c leds-arch.c \
button-sensor.c pir-sensor.c vib-sensor.c xmem.c \ button-sensor.c pir-sensor.c vib-sensor.c xmem.c \
sensors.c irq.c cfs-posix.c cfs-posix-dir.c sensors.c irq.c cfs-posix.c cfs-posix-dir.c
ifeq ($(OS),Windows_NT) ifeq ($(HOST_OS),Windows)
CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c
TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
else else

View File

@ -43,29 +43,27 @@ NUMPAR=20
IHEXFILE=tmpimage.ihex IHEXFILE=tmpimage.ihex
# Check if we are running under Windows # Check if we are running under Windows
ifdef OS
ifneq (,$(findstring Windows,$(OS))) USBDEVPREFIX=/dev/com
USBDEVPREFIX=/dev/com SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-windows
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-windows MOTELIST = $(CONTIKI)/tools/sky/motelist-windows
MOTELIST = $(CONTIKI)/tools/sky/motelist-windows TMOTE_BSL_FILE = tmote-bsl
TMOTE_BSL_FILE = tmote-bsl TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE).exe),1,0)
TMOTE_BSL=$(if $(wildcard $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE).exe),1,0) ifeq ($(TMOTE_BSL), 1)
ifeq ($(TMOTE_BSL), 1) NUMPAR = 1
NUMPAR = 1 BSL = $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE)
BSL = $(CONTIKI)/tools/sky/$(TMOTE_BSL_FILE) MOTES = $(shell $(MOTELIST) | grep COM | \
MOTES = $(shell $(MOTELIST) | grep COM | \ cut -f 4 -d \ )
cut -f 4 -d \ ) else
else BSL = $(CONTIKI)/tools/sky/msp430-bsl-windows --telosb
BSL = $(CONTIKI)/tools/sky/msp430-bsl-windows --telosb BSL_FILETYPE = -I
BSL_FILETYPE = -I MOTES = $(shell $(MOTELIST) | grep COM | \
MOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ | \
perl -ne 'print $$1 - 1 . " " if(/COM(\d+)/);')
endif
CMOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ | \ cut -f 4 -d \ | \
perl -ne 'print $$1 . " " if(/COM(\d+)/);') perl -ne 'print $$1 - 1 . " " if(/COM(\d+)/);')
endif endif
CMOTES = $(shell $(MOTELIST) | grep COM | \
cut -f 4 -d \ | \
perl -ne 'print $$1 . " " if(/COM(\d+)/);')
endif endif
# If we are not running under Windows, we assume Linux # If we are not running under Windows, we assume Linux

View File

@ -27,12 +27,3 @@ ifndef BASE_IP
BASE_IP := 172.16.1.1 BASE_IP := 172.16.1.1
endif endif
### System dependent Makefile
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif

View File

@ -24,12 +24,3 @@ ifndef BASE_IP
BASE_IP := 172.16.1.1 BASE_IP := 172.16.1.1
endif endif
### System dependent Makefile
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif