From c31648e2e42cbbae7cb406d1df6ec3db7b6d4d4a Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Wed, 12 Jun 2013 16:23:34 +0200 Subject: [PATCH] moved native board drivers into separate directory split up drivers to avoid building unnecessary files --- native/Makefile | 11 ++++++---- native/Makefile.include | 4 ++-- native/drivers/Makefile | 30 +++++++++++++++++++++++++++ native/{ => drivers}/native-led.c | 0 native/{ => drivers}/native-ltc4150.c | 0 native/{ => drivers}/native-uart0.c | 0 6 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 native/drivers/Makefile rename native/{ => drivers}/native-led.c (100%) rename native/{ => drivers}/native-ltc4150.c (100%) rename native/{ => drivers}/native-uart0.c (100%) diff --git a/native/Makefile b/native/Makefile index 86ddb4a6ff..ded96b6cf2 100644 --- a/native/Makefile +++ b/native/Makefile @@ -2,14 +2,16 @@ SRC = $(wildcard *.c) BINDIR = bin/ OBJ = $(SRC:%.c=$(BINDIR)%.o)## defines DEP = $(SRC:%.c=$(BINDIR)%.d) +export ARCH = native_base.a INCLUDES += -I$(RIOTBASE)/cpu/native/include/ INCLUDES += -I$(RIOTBOARD)/native/include/ -all: $(BINDIR)native_base.a +all: $(BINDIR)$(ARCH) + $(MAKE) -C drivers -$(BINDIR)native_base.a: $(OBJ) - $(AR) rcs $(BINDIR)native_base.a $(OBJ) +$(BINDIR)$(ARCH): $(OBJ) + $(AR) rcs $(BINDIR)$(ARCH) $(OBJ) # pull in dependency info for *existing* .o files -include $(OBJ:.o=.d) @@ -23,6 +25,7 @@ $(BINDIR)%.o: %.c # remove compilation products clean: - rm -f $(BINDIR)native_base.a $(OBJ) $(DEP) + ${MAKE} -C drivers clean + rm -f $(BINDIR)$(ARCH) $(OBJ) $(DEP) -rmdir -p $(BINDIR) diff --git a/native/Makefile.include b/native/Makefile.include index d360b2248f..e8e5d48e4d 100644 --- a/native/Makefile.include +++ b/native/Makefile.include @@ -5,7 +5,7 @@ export CPU = native export PREFIX = #export CC = @$(PREFIX)gcc export AR = @$(PREFIX)ar -export CFLAGS = -std=gnu99 -Wall -m32 +export CFLAGS += -std=gnu99 -Wall -m32 export ASFLAGS = export AS = $(PREFIX)as export LINK = $(PREFIX)gcc @@ -14,7 +14,7 @@ export OBJCOPY = $(PREFIX)objcopy FLASHER = lpc2k_pgm TERM = pyterm.py -LINKFLAGS = -m32 +LINKFLAGS = -m32 -gc ifeq ($(strip $(PORT)),) export PORT = /dev/ttyUSB0 diff --git a/native/drivers/Makefile b/native/drivers/Makefile new file mode 100644 index 0000000000..f0516a8530 --- /dev/null +++ b/native/drivers/Makefile @@ -0,0 +1,30 @@ +SRC = $(wildcard *.c) +BINDIR = $(RIOTBOARD)/$(BOARD)/bin/ +OBJ = $(BINDIR)native-led.o +ifneq (,$(findstring ltc4150,$(USEMODULE))) + OBJ += $(BINDIR)native-ltc4150.o +endif +ifneq (,$(findstring uart0,$(USEMODULE))) + OBJ += $(BINDIR)native-uart0.o +endif +DEP = $(SRC:%.c=$(BINDIR)%.d) + +INCLUDES += -I$(RIOTBOARD)/native/include/ + +$(BINDIR)native_drivers.a: $(OBJ) + @$(AR) rcs $(BINDIR)${ARCH} $(OBJ) + +# pull in dependency info for *existing* .o files +-include $(OBJ:.o=.d) + +# compile and generate dependency info +$(BINDIR)%.o: %.c + $(CC) $(CFLAGS) $(INCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -c $*.c -o $(BINDIR)$*.o + @$(CC) $(CFLAGS) $(INCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -MM $*.c > $(BINDIR)$*.d + @printf "$(BINDIR)" | cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d + +# remove compilation products + +clean: + rm -f $(OBJ) $(DEP) + diff --git a/native/native-led.c b/native/drivers/native-led.c similarity index 100% rename from native/native-led.c rename to native/drivers/native-led.c diff --git a/native/native-ltc4150.c b/native/drivers/native-ltc4150.c similarity index 100% rename from native/native-ltc4150.c rename to native/drivers/native-ltc4150.c diff --git a/native/native-uart0.c b/native/drivers/native-uart0.c similarity index 100% rename from native/native-uart0.c rename to native/drivers/native-uart0.c