1 # Makefile to get and build all the parts of GBDK
3 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
4 else if [ -x /bin/bash ]; then echo /bin/bash; \
7 TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
9 BUILD = $(TOPDIR)/build/sdcc
15 # Used as a branch name.
19 # linux-linux Building on Linux, targeting Linux
20 # linux-ming32 Building on Linux, targeting mingw32 based win32
21 # cygwin-mingw32 Building via cygwin on win32, targeting mingw32
23 COMPILE_MODE = linux-mingw32
26 ROOT_GBDK = :pserver:anonymous@cvs.gbdk.sourceforge.net:/cvsroot/gbdk
27 ROOT_SDCC = :pserver:anonymous@cvs.sdcc.sourceforge.net:/cvsroot/sdcc
29 ifeq ($(COMPILE_MODE),linux-linux)
33 SDCC_ROOT = /usr/lib/$(SDCC_OR_GBDK)
36 ifeq ($(COMPILE_MODE),linux-mingw32)
37 # For mingw32 hosted on Linux
40 # Source extension - what the gcc generated files have appended
42 # Dest extenstion - what extension we want them to have.
44 SDCC_ROOT = /$(SDCC_OR_GBDK)
45 # Set to cross to bypass the detection
49 ifeq ($(COMPILE_MODE),cygwin-mingw32)
50 # For mingw32 on win32
51 # Source extension - what the gcc generated files have appended
53 # Dest extenstion - what extension we want them to have.
54 SDCC_ROOT = /$(SDCC_OR_GBDK)
60 for i in sdcc gbdk-lib gbdk-support/lcc; do make -C $$i clean; done
62 rm -rf $(BUILD) gbdk-lib gbdk-support sdcc logged_in
65 cd $(DIR); cvs $(CVSFLAGS) -d$(ROOT_SDCC) co -r sdcc-$(SHORTVER) sdcc
66 cd $(DIR); cvs $(CVSFLAGS) -d$(ROOT_GBDK) co -r sdcc-$(SHORTVER) gbdk-lib
67 cd $(DIR); cvs $(CVSFLAGS) -d$(ROOT_GBDK) co -r sdcc-$(SHORTVER) gbdk-support
69 _sdcc: sdcc-bin sdcc-misc sdcc-lib sdcc-doc
72 rm -rf `find $(BUILD) -name "CVS"`
73 rm -rf `find $(BUILD)/lib -name "*.asm"`
74 -$(TNP)strip $(BUILD)/bin/*
76 sdcc-bin: sdcc/sdccconf.h
77 make -C sdcc sdcc-bin CROSS_LIBGC=$(CROSS_LIBGC)
80 sdcc sdcpp link-z80 as-z80 aslink asx8051; \
81 do cp sdcc/bin/$$i$(SE) $(BUILD)/bin/$$i$(E); done
83 sdcc-misc: sdcc/sdccconf.h
84 make -C sdcc sdcc-misc CROSS_LIBGC=$(CROSS_LIBGC)
88 do cp sdcc/bin/$$i$(SE) $(BUILD)/bin/$$i$(E); done
89 cp sdcc/sim/ucsim/s51.src/s51$(E) $(BUILD)/bin
90 cp sdcc/sim/ucsim/z80.src/sz80$(E) $(BUILD)/bin
91 cp sdcc/sim/ucsim/avr.src/savr$(E) $(BUILD)/bin
92 cp sdcc/debugger/mcs51/*.el $(BUILD)/bin
95 (cd sdcc; tar cf - doc) | (cd $(BUILD); tar xf -)
96 cp sdcc/README sdcc/COPYING $(BUILD)
98 for i in COPYING INSTALL README TODO; \
99 do cp sdcc/sim/ucsim/$$i $(BUILD)/sim; done
100 (cd sdcc/sim/ucsim; tar cf - doc) | (cd $(BUILD)/sim; tar xf -)
102 sdcc-lib: sdcc-lib-z80 sdcc-lib-gen
103 mkdir -p $(BUILD)/lib
104 (cd sdcc/device/lib; tar cf - small large) | (cd $(BUILD)/lib; tar xf -)
105 (cd sdcc/device; tar cf - examples include) | (cd $(BUILD); tar xf -)
108 make -C gbdk-lib/libc SDCCLIB=$(BUILD) PORTS=z80 PLATFORMS=consolez80
109 (cd gbdk-lib/build; tar cf - consolez80 z80) | (cd $(BUILD)/lib; tar xf -)
110 mkdir -p $(BUILD)/include/gbdk-lib
111 (cd gbdk-lib/include; tar cf - .) | (cd $(BUILD)/include/gbdk-lib; tar xf -)
114 make -C sdcc sdcc-device
117 make -C gbdk-support/lcc SDCCLIB=$(SDCC_ROOT)/ TNP=$(TNP)
118 cp gbdk-support/lcc/lcc$(SE) $(BUILD)/bin/lcc$(E)
120 sdcc/sdccconf.h: sdcc/configure
123 export CCC=$(TNP)c++; \
124 export RANLIB=$(TNP)ranlib; \
125 export CC=$(TNP)gcc; \
126 ./configure --datadir=$(SDCC_ROOT)
129 cd sdcc; ./configure --datadir=$(SDCC_ROOT)
135 tar czf gbdk-$(VER).tar.gz gbdk
138 cvs -d$(ROOT_GBDK) login
139 cvs -d$(ROOT_SDCC) login
141 make -f build.mak update