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
ifndef HOST_OS
ifeq ($(OS),Windows_NT)
$(warning Windows (NT) deteced.)
HOST_OS := Windows
else
HOST_OS := $(shell uname)
endif
endif
usage:
@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 $
### Check if we are running under Windows
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
.SUFFIXES:
### 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)
$(OBJECTDIR)/board.h: $(OBJECTDIR)
ifneq (,$(findstring Windows,$(OS)))
${info Cygwin detected.}
ifeq ($(HOST_OS),Windows)
ln -f $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
else
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
# Check if we are running under Windows
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
ifeq ($(HOST_OS),Windows)
FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/stm32w_flasher.exe
endif
endif

View File

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

View File

@ -11,14 +11,6 @@ ifndef CONTIKI
$(error CONTIKI not defined!)
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
ifndef LIBNAME
QUICKSTART=1

View File

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

View File

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

View File

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

View File

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

View File

@ -26,23 +26,15 @@ include $(CONTIKIAVR)/Makefile.avr
avr-objdump -zhD $< > $@
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
ifeq ($(PRGBOARD), )
PRGBOARD = mib510
endif
ifeq ($(PORT), )
ifndef WINDIR
PORT = /dev/ttyS0
else
ifeq ($(HOST_OS),Windows)
PORT = COM1
else
PORT = /dev/ttyS0
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
ifeq ($(OS),Windows_NT)
ifeq ($(HOST_OS),Windows)
CONTIKI_TARGET_SOURCEFILES += wpcap-drv.c wpcap.c
else
CONTIKI_TARGET_SOURCEFILES += tapdev-drv.c
@ -21,7 +21,7 @@ endif
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
ifeq ($(OS),Windows_NT)
ifeq ($(HOST_OS),Windows)
TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
endif

View File

@ -24,25 +24,17 @@ endif
### System dependent Makefile
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
ifeq (${HOSTTYPE},FreeBSD)
ifeq ($(HOST_OS),FreeBSD)
# settings for FreeBSD
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.freebsd
else
ifndef WINDIR
# settings for unix
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix
else
# settings for windows
ifeq ($(HOST_OS),Windows)
# settings for Windows
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.win
endif
else
# settings for an arbitary unix-like platform
-include $(CONTIKI)/platform/$(TARGET)/buildscripts/Makefile.unix
endif
endif
# 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 \
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
TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a
else

View File

@ -43,8 +43,7 @@ NUMPAR=20
IHEXFILE=tmpimage.ihex
# Check if we are running under Windows
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
USBDEVPREFIX=/dev/com
SERIALDUMP = $(CONTIKI)/tools/sky/serialdump-windows
MOTELIST = $(CONTIKI)/tools/sky/motelist-windows
@ -65,7 +64,6 @@ ifdef OS
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

View File

@ -27,12 +27,3 @@ ifndef BASE_IP
BASE_IP := 172.16.1.1
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
endif
### System dependent Makefile
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif