File: Makefile

package info (click to toggle)
gbdk 2.0.17-3
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 8,472 kB
  • ctags: 9,307
  • sloc: ansic: 42,333; asm: 7,010; makefile: 912; yacc: 375; awk: 154; csh: 144; sh: 59
file content (203 lines) | stat: -rw-r--r-- 5,287 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# GBDK-2.0 Top level Makefile
# Michael Hope, Pascal Felber

.EXPORT_ALL_VARIABLES:

VERSION	= 2
PATCHLEVEL = 0
SUBLEVEL = 17

# Housekeeping
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
	else if [ -x /bin/bash ]; then echo /bin/bash; \
	else echo sh; fi ; fi)

TOPDIR	:= $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)

# See if a targets already been defined
ifeq (.target,$(wildcard .target))
include .target
endif

Z80 		:= $(TOPDIR)/z80
LCC		:= lcc-4.1
CFLAGS		:= #-O2 -fomit-frame-pointer -Wall

# Set HOSTCC and HOSTLD to the name of your systems native compiler
HOSTCC	 	:= gcc
HOSTLD		:= gcc
HOSTE		:= 

# If INDEXLIB is uncommented, then link will build an in-memory index of 
# the library files on the first pass.  This gives a 20x speed up on
# low end systems (386/2M) (Honest!)
INDEXLIB	= y

ifdef INDEXLIB
CFLAGS		:= $(CFLAGS) -DINDEXLIB -DMLH_MAP
endif

SUBDIRS		:= as link

# LCC dir is the root of where LCC will expect to find it's bins, include
#  files and libraries

# Currently supported processors: gb, z80
# Currently supported targetos's: rrgb, gb
#PROCESSOR = gb
#TARGETOS = gb

ifndef PROCESSOR
		PROCESSOR	:= gb
		GAMEBOY		:= y
endif
ifndef TARGETOS
		TARGETOS	:= gb
endif

TARGET			= $(PROCESSOR)-$(TARGETOS)
TARGET_STRING		= \"$(TARGET)\"
SDK_VERSION		= $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
SDK_VERSION_STRING	= \"$(SDK_VERSION)\"
ifndef SDK_DIR
SDK_DIR			= $(HOME)
endif

BUILDDIR	:= $(TOPDIR)/build/$(TARGET)/$(SDK_VERSION)
DISTROOT	:= $(TOPDIR)/dist

############################################################
# Setup the compiler, flags and executable extension depending on the target
ifdef DOS
	CC		=  gcc-go32
	LD		=  gcc-go32
	HOSTFILE	=  $(Z80)/lcc/etc/gb-dos.c
	DESTDIR		=  \\\\SDK\\\\$(TARGET)\\\\$(VERSION)-$(PATCHLEVEL)-$(SUBLEVEL)\\\\
	DIST		:= $(DISTROOT)/SDK/$(TARGET)/$(VERSION)-$(PATCHLEVEL)-$(SUBLEVEL)
	ARCHIVE		:= $(TOPDIR)/SDK-$(TARGET)-$(SDK_VERSION).zip
	LCCDIR		=  \"$(TESTDIR)\"
	CFLAGS		:= $(CFLAGS) -DDOS -DWIN32 -D_P_WAIT=P_WAIT -D_spawnvp=spawnvp

	# libemu is the 387 math co-pro emulator
	LDFLAGS		= -lemu
	E		= .exe
else
	CC		=  $(HOSTCC)
	LD		=  $(HOSTLD)
	E		=  $(HOSTE)
	HOSTFILE	=  $(Z80)/lcc/etc/gb-unix.c
	DESTDIR		=  $(SDK_DIR)/SDK/$(TARGET)/$(SDK_VERSION)/
	DIST		:= $(DISTROOT)/SDK/$(TARGET)/$(SDK_VERSION)
	ARCHIVE		:= $(TOPDIR)/sdk-$(TARGET)-$(SDK_VERSION).tar
	CFLAGS		:= $(CFLAGS) -DUNIX
	LDFLAGS         = -lm
endif

LCCDIR		:= \"$(DESTDIR)\"

ifeq ($(PROCESSOR), gb)
	CFLAGS	:= $(CFLAGS) -DGAMEBOY
endif

############################################################

CFLAGS		:= $(CFLAGS) -DSDK -DLCCDIR=$(LCCDIR) -DTARGET=$(TARGET) -DSDK_VERSION_STRING=$(SDK_VERSION_STRING)\
			-DTARGET_STRING=$(TARGET_STRING)

all:
ifdef DOS
	echo "DOS=y" > $(TOPDIR)/.target
else
	echo "UNIX=y" > $(TOPDIR)/.target
endif
	$(MAKE) binary

binary: lcc-binary
	for i in $(SUBDIRS); do $(MAKE) -C $$i; done

# We copy the lcc distribution files to the build directory to avoid
# modifying the original lcc distribution
lcc-binary:
	mkdir -p $(BUILDDIR)/src/lcc
	cp $(LCC)/custom.mk $(BUILDDIR)/src/lcc
	cp -r $(LCC)/lburg $(BUILDDIR)/src/lcc
	cp -r $(LCC)/src $(BUILDDIR)/src/lcc
	cp -r $(LCC)/etc $(BUILDDIR)/src/lcc
	cp -r $(LCC)/cpp $(BUILDDIR)/src/lcc
	cp $(Z80)/lcc/makefile $(BUILDDIR)/src/lcc
	cp -r $(Z80)/lcc/lburg/* $(BUILDDIR)/src/lcc/lburg
	cp -r $(Z80)/lcc/src/* $(BUILDDIR)/src/lcc/src
	cp -r $(Z80)/lcc/etc/* $(BUILDDIR)/src/lcc/etc
	$(MAKE) -C $(BUILDDIR)/src/lcc CC=$(HOSTCC) LD=$(HOSTLD) CFLAGS= LDFLAGS= lburg
	$(MAKE) -C $(BUILDDIR)/src/lcc LCCDIR=$(LCCDIR) rcc lcc cpp

dosify:
ifdef DOS
	for i in $(DIST)/* $(DIST)/doc/* $(DIST)/include/* $(DIST)/lib/* $(DIST)/examples/* $(DIST)/examples/*/*; \
	 do ( \
	  if [ -f $$i ] && [ `expr $$i : '.*\.\(.*\)' \| $$i` != "gbr" ] && [ `expr $$i : '.*\.\(.*\)' \| $$i` != "pdf" ]; then \
	   unix2dos $$i $$i; \
	  fi ); \
	 done
endif

makedirs:
	rm -rf $(DIST)
	mkdir -p $(DIST)/bin
	mkdir -p $(DIST)/doc
	mkdir -p $(DIST)/include
	mkdir -p $(DIST)/lib
	mkdir -p $(DIST)/examples

copyfiles:
	cp -rf include-$(TARGETOS)/* $(DIST)/include
	cp -rf doc-$(TARGETOS)/* $(DIST)/doc
	cp -rf doc-common/* $(DIST)/doc
	cp -rf lib-$(TARGETOS)/* $(DIST)/lib
	cp -rf examples-$(TARGETOS)/* $(DIST)/examples
ifdef DOS
	cp gbdk.bat $(DIST)
	troff -man -a $(LCC)/doc/lcc.1 > $(DIST)/doc/lcc.doc
else
	cp $(LCC)/doc/lcc.1 $(DIST)/doc
endif
	chmod -R a+r $(DIST)/bin
	chmod -R a+r $(DIST)/doc
	chmod -R a+r $(DIST)/include
	chmod -R a+r $(DIST)/lib
	chmod -R a+r $(DIST)/examples

zdist:	dist
	rm -f $(ARCHIVE)
ifdef DOS
	cd $(DISTROOT); \
	zip -r $(ARCHIVE) *
else
	cd $(DISTROOT); \
	tar cf $(ARCHIVE) *
	gzip $(ARCHIVE)
endif

dist:	makedirs copyfiles dosify
	rm -rf bin.zip
	cp $(BUILDDIR)/lcc$E $(DIST)/bin
	cp $(BUILDDIR)/rcc$E $(DIST)/bin
	cp $(BUILDDIR)/cpp$E $(DIST)/bin
	cp as/as$E           $(DIST)/bin
	cp link/link$E	     $(DIST)/bin
	rm -rf `find "dist" -name CVS`
	rm -rf `find "dist" \( -name \*\~ -o -name \*\# -o -name \*\% \) -print`

clean:
	for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
	rm -rf $(BUILDDIR)
	rm -rf $(DIST)
	rm -f $(TOPDIR)/.target

install: dist
ifndef UNIX
	@echo "Panic: dont know how to install on a DOS system"
else
	mkdir -p $(DESTDIR)
	cd $(DIST); tar cf - * | (cd $(DESTDIR); tar xf - )
endif