Makefile 2.32 KB
Newer Older
1 2 3 4
#
# Alessandro Rubini for CERN, 2011 -- public domain
#

5 6 7 8
# The default is not extension. Uncomment here or set on the command line
# PROTO_EXT ?= whiterabbit

# The default architecture is hosted GNU/Linux stuff
9
ARCH ?= unix
10

11 12 13
# Also, you can set USER_CFLAGS, like this (or on the command line)
# USER_CFLAGS = -DVERB_LOG_MSGS -DCONFIG_PPSI_RUNTIME_VERBOSITY

14 15
#### In theory, users should not change stuff below this line (but please read)

16 17 18 19 20 21 22 23 24 25 26
# classic cross-compilation tool-set
AS              = $(CROSS_COMPILE)as
LD              = $(CROSS_COMPILE)ld
CC              = $(CROSS_COMPILE)gcc
CPP             = $(CC) -E
AR              = $(CROSS_COMPILE)ar
NM              = $(CROSS_COMPILE)nm
STRIP           = $(CROSS_COMPILE)strip
OBJCOPY         = $(CROSS_COMPILE)objcopy
OBJDUMP         = $(CROSS_COMPILE)objdump

27
# Instead of repeating "ppsi" over and over, bless it TARGET
Alessandro Rubini's avatar
Alessandro Rubini committed
28
TARGET = ppsi
29 30 31 32 33

# The main target is the big object file.
all: $(TARGET).o

# CFLAGS to use. Both this Makefile (later) and app-makefile may grow CFLAGS
34
CFLAGS = $(USER_CFLAGS)
35
CFLAGS += -Wall -O2 -ggdb -Iinclude -fno-common
36 37

# to avoid ifdef as much as possible, I use the kernel trick for OBJ variables
38
OBJ-y := fsm.o diag.o
39

40 41
# include pp_printf code, by default the "full" version. Please
# set CONFIG_PRINTF_NONE or CONFIG_PRINTF_XINT if needed.
42
ifndef CONFIG_NO_PRINTF
43 44 45 46
OBJ-y += pp_printf/pp-printf.o

pp_printf/pp-printf.o: $(wildcard pp_printf/*.[ch])
	$(MAKE) -C pp_printf pp-printf.o
47
endif
48

49 50
# proto-standard is always included, as it provides default function
# so the extension can avoid duplication of code.
51 52 53
ifdef PROTO_EXT
  include proto-ext-$(PROTO_EXT)/Makefile
endif
54
include proto-standard/Makefile
55

56
# Include arch code
57
# we need this -I so <arch/arch.h> can be found
58 59
CFLAGS += -Iarch-$(ARCH)/include
include arch-$(ARCH)/Makefile
60
export CFLAGS
61 62 63 64 65 66 67 68 69 70 71 72 73 74

# And this is the rule to build our target.o file. The architecture may
# build more stuff. Please note that ./MAKEALL looks for $(TARGET)
# (i.e., the ELF which is either the  output or the input to objcopy -O binary)
#
# The object only depends on OBJ-y because each subdirs added needed
# libraries: see proto-standard/Makefile as an example.

$(TARGET).o: $(OBJ-y)
	$(LD) -Map $(TARGET).map1 -r -o $@ $(OBJ-y) $(LIBS)

# Finally, "make clean" is expected to work
clean:
	rm -f $$(find . -name '*.[oa]') *.bin $(TARGET) *~ $(TARGET).map*