fix make files to auto env setup
[archipelago] / xseg / base.mk
1 # Setup for xseg Makefiles.
2
3 ifndef TARGET
4 TARGET:=$(shell basename $(shell pwd))
5 endif
6
7 export CC=gcc
8 ifndef MOPTS
9 export MOPTS=
10 endif
11 ifndef COPTS
12 export COPTS=-O2 -g -finline-functions $(MOPTS) $(DEBUG)
13 endif
14 ifndef CSTD
15 export CSTD=-std=gnu99 -pedantic
16 endif
17
18 INC=-I$(BASE)
19 INC+=-I$(BASE)/peers/$(TARGET)
20 INC+=-I$(BASE)/sys/$(TARGET)
21 INC+=-I$(BASE)/drivers/$(TARGET)
22 export INC
23
24 export LIB=$(BASE)/lib/$(TARGET)
25 export CFLAGS=-Wall $(COPTS) $(CSTD)
26
27 #ifeq (,$(XSEG_HOME))
28 #export XSEG_HOME=$(shell ${XSEG_HOME})
29 #endif
30
31 ifeq (,$(XSEG_HOME))
32 export XSEG_HOME=.
33 endif
34
35 CONFIG=./config.mk
36
37 default:
38
39 .PHONY: clean-config
40
41 clean: clean-config
42
43 clean-config:
44         rm -f $(CONFIG)
45
46 ifndef BASE
47 exists=$(shell [ -f "$(CONFIG)" ] && echo exists)
48 ifeq (exists,$(exists))
49 include $(CONFIG)
50 else
51 $(shell $(XSEG_HOME)/envsetup show | sed -e 's/"//g' > "$(CONFIG)")
52 include $(CONFIG)
53 endif
54
55 export XSEG_DOMAIN_TARGETS=$(shell $(XSEG_HOME)/tools/xseg-domain-targets | sed -e 's/^[^=]*=//;s/"//g')
56 export BASE=$(XSEG_HOME)
57 endif