Add simple config system for both #ifdef's and conditional compilation
This commit is contained in:
parent
736155ce99
commit
3876937ae9
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,7 @@
|
|||||||
aedrix-kernel.elf
|
aedrix-kernel.elf
|
||||||
aedrix-kernel.img
|
aedrix-kernel.img
|
||||||
|
config
|
||||||
|
config.h
|
||||||
*.o
|
*.o
|
||||||
*.swp
|
*.swp
|
||||||
*.d
|
*.d
|
||||||
|
18
Makefile
18
Makefile
@ -18,10 +18,13 @@ OBJDUMP = $(TOOL_PREFIX)objdump
|
|||||||
|
|
||||||
# Define the flags we'll need for our tools
|
# Define the flags we'll need for our tools
|
||||||
INCLUDES = -I include
|
INCLUDES = -I include
|
||||||
KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu99 $(INCLUDES)
|
KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu99 -include config.h $(INCLUDES)
|
||||||
KLDFLAGS = -T link.ld -L /usr/lib/gcc/arm-elf/4.7.0/
|
KLDFLAGS = -T link.ld -L /usr/lib/gcc/arm-elf/4.7.0/
|
||||||
EXTRA_LIBS = -lgcc
|
EXTRA_LIBS = -lgcc
|
||||||
|
|
||||||
|
# Include the config file so we don't compile/link unnecessary objects
|
||||||
|
include config
|
||||||
|
|
||||||
# Define KOBJS as a 'simply expanded' variable
|
# Define KOBJS as a 'simply expanded' variable
|
||||||
KOBJS :=
|
KOBJS :=
|
||||||
|
|
||||||
@ -48,7 +51,7 @@ aedrix-kernel.img: aedrix-kernel.elf
|
|||||||
@echo 'OBJCOPY $@'
|
@echo 'OBJCOPY $@'
|
||||||
$(V)$(OBJCOPY) $< -O binary $@
|
$(V)$(OBJCOPY) $< -O binary $@
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c config.h
|
||||||
@echo ' CC $@'
|
@echo ' CC $@'
|
||||||
$(V)$(CC) $(KCFLAGS) -MD -c -o $@ $<
|
$(V)$(CC) $(KCFLAGS) -MD -c -o $@ $<
|
||||||
@# Automatic dependency generation fixups (http://mad-scientist.net/make/autodep.html)
|
@# Automatic dependency generation fixups (http://mad-scientist.net/make/autodep.html)
|
||||||
@ -57,7 +60,7 @@ aedrix-kernel.img: aedrix-kernel.elf
|
|||||||
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(*D)/.$(*F).d; \
|
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(*D)/.$(*F).d; \
|
||||||
rm -f $*.d
|
rm -f $*.d
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S config.h
|
||||||
@echo ' AS $@'
|
@echo ' AS $@'
|
||||||
$(V)$(CC) $(KCFLAGS) -MD -c -o $@ $<
|
$(V)$(CC) $(KCFLAGS) -MD -c -o $@ $<
|
||||||
@# Automatic dependency generation fixups (http://mad-scientist.net/make/autodep.html)
|
@# Automatic dependency generation fixups (http://mad-scientist.net/make/autodep.html)
|
||||||
@ -66,7 +69,16 @@ aedrix-kernel.img: aedrix-kernel.elf
|
|||||||
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(*D)/.$(*F).d; \
|
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(*D)/.$(*F).d; \
|
||||||
rm -f $*.d
|
rm -f $*.d
|
||||||
|
|
||||||
|
config.h: config
|
||||||
|
@echo ' CONFIG config.h'
|
||||||
|
@cp config config.h
|
||||||
|
@sed -i '/^\w*#/d' config.h
|
||||||
|
@sed -i '/^\s*\(CONFIG_[A-Z0-9_]\+\)\s*=\s*[nN]/d' config.h
|
||||||
|
@sed -i 's/^\s*\(CONFIG_[A-Z0-9_]\+\)\s*=\s*[yY]/#define \1/g' config.h
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@echo ' CLEAN config.h'
|
||||||
|
$(V)rm -f config.h
|
||||||
@echo ' CLEAN *.o'
|
@echo ' CLEAN *.o'
|
||||||
$(V)rm -f $(KOBJS)
|
$(V)rm -f $(KOBJS)
|
||||||
@echo ' CLEAN .*.d'
|
@echo ' CLEAN .*.d'
|
||||||
|
3
config_example
Normal file
3
config_example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
CONFIG_RPI = y
|
||||||
|
#CONFIG_VEXPRESS_A9 = y
|
||||||
|
#CONFIG_INTEGRATOR_CP = n
|
@ -3,13 +3,18 @@ SUBDIRS :=
|
|||||||
|
|
||||||
include $(BASEDIR)/header.mk
|
include $(BASEDIR)/header.mk
|
||||||
|
|
||||||
OBJS_$(d) := $(d)/pl011.o \
|
OBJS_$(d)_$(CONFIG_VEXPRESS_A9) := \
|
||||||
|
$(d)/pl011.o \
|
||||||
|
$(d)/pl111.o
|
||||||
|
|
||||||
|
OBJS_$(d)_$(CONFIG_INTEGRATOR_CP) := \
|
||||||
$(d)/pl110.o \
|
$(d)/pl110.o \
|
||||||
$(d)/pl111.o \
|
|
||||||
|
OBJS_$(d)_$(CONFIG_RPI) := \
|
||||||
$(d)/pi_mini_uart.o \
|
$(d)/pi_mini_uart.o \
|
||||||
$(d)/bcm2835_mailbox.o \
|
$(d)/bcm2835_mailbox.o \
|
||||||
$(d)/bcm2835_videocore.o
|
$(d)/bcm2835_videocore.o
|
||||||
|
|
||||||
KOBJS += $(OBJS_$(d))
|
KOBJS += $(OBJS_$(d)_y)
|
||||||
|
|
||||||
include $(BASEDIR)/footer.mk
|
include $(BASEDIR)/footer.mk
|
||||||
|
@ -23,12 +23,19 @@
|
|||||||
#include <mmu.h>
|
#include <mmu.h>
|
||||||
#include <mm.h>
|
#include <mm.h>
|
||||||
#include <print.h>
|
#include <print.h>
|
||||||
#include <devices/pi_mini_uart.h>
|
|
||||||
|
|
||||||
#include <devices/bcm2835_videocore.h>
|
|
||||||
#include <framebuffer.h>
|
#include <framebuffer.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_VEXPRESS_A9
|
||||||
|
#include <devices/pl011.h>
|
||||||
|
#include <devices/pl111.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_RPI
|
||||||
|
#include <devices/pi_mini_uart.h>
|
||||||
|
#include <devices/bcm2835_videocore.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct fb myfb;
|
struct fb myfb;
|
||||||
|
|
||||||
void print_console_logo() {
|
void print_console_logo() {
|
||||||
@ -41,7 +48,12 @@ void print_console_logo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void video_init(void) {
|
void video_init(void) {
|
||||||
|
#ifdef CONFIG_VEXPRESS_A9
|
||||||
|
pl111_init(&myfb, 16);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_RPI
|
||||||
bcm2835_videocore_init(&myfb, 16);
|
bcm2835_videocore_init(&myfb, 16);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_mm() {
|
void test_mm() {
|
||||||
@ -124,8 +136,13 @@ int main(void) {
|
|||||||
mmu_reinit();
|
mmu_reinit();
|
||||||
|
|
||||||
//initialize the serial console
|
//initialize the serial console
|
||||||
|
#ifdef CONFIG_VEXPRESS_A9
|
||||||
|
print_init(&pl011_putc);
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_RPI
|
||||||
mini_uart_init();
|
mini_uart_init();
|
||||||
print_init(&mini_uart_putc);
|
print_init(&mini_uart_putc);
|
||||||
|
#endif
|
||||||
|
|
||||||
//setup memory
|
//setup memory
|
||||||
mm_init();
|
mm_init();
|
||||||
|
Loading…
Reference in New Issue
Block a user