summaryrefslogtreecommitdiff
path: root/i386/linux/Makefile.in
blob: 2d7d3a6f0bdd7aef8ce61617e47d1fcaa16938a0 (plain)
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# Makefile for Linux device drivers and the glue codes.
# Copyright 1998, 1999 Free Software Foundation, Inc.
#
# Permission to use, copy, modify and distribute this software and its
# documentation is hereby granted, provided that both the copyright
# notice and this permission notice appear in all copies of the
# software, derivative works or modified versions, and any portions
# thereof, and that both notices appear in supporting documentation.
#
# THE FREE SOFTWARE FOUNDATION ALLOWS FREE USE OF THIS SOFTWARE IN ITS
# "AS IS" CONDITION.  THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY
# LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
# USE OF THIS SOFTWARE.


# Variables from `configure'.
srcdir=@srcdir@
systype=@systype@
device_drivers=@device_drivers@

sysdep=$(srcdir)/..
linuxdir=../../linux
linuxsrcdir=$(srcdir)/$(linuxdir)

# Programs found by configure.
CC = @CC@
LD = @LD@

CFLAGS = @CFLAGS@



# Files for driver support.
linux-c-files = version.c softirq.c delay.c dma.c resource.c printk.c \
		bios32.c irq.c ctype.c vsprintf.c main.c misc.c sched.c \
		kmem.c block.c setup.c

# `dev' directory contains modified and glue source files.
vpath %.c $(linuxsrcdir)/dev/kernel
vpath %.c $(linuxsrcdir)/dev/init
vpath %.c $(linuxsrcdir)/dev/arch/$(systype)/kernel
vpath %.c $(linuxsrcdir)/dev/arch/$(systype)/lib
vpath %.c $(linuxsrcdir)/dev/glue
vpath %.c $(linuxsrcdir)/dev/lib

# `src' directory contains original Linux source files.
vpath %.c $(linuxsrcdir)/src/kernel
vpath %.c $(linuxsrcdir)/src/init
vpath %.c $(linuxsrcdir)/src/arch/$(systype)/kernel
vpath %.c $(linuxsrcdir)/src/arch/$(systype)/lib
vpath %.c $(linuxsrcdir)/src/lib


# XXX: Assembly source files must be treated separately... Uggg...
linux-asm-files = semaphore.S
vpath %.S $(linuxsrcdir)/dev/arch/$(systype)/lib
vpath %.S $(linuxsrcdir)/src/arch/$(systype)/lib


# Linux device drivers.
linux-block-files = cmd640.c floppy.c genhd.c ide-cd.c ide.c rz1000.c triton.c
vpath %.c $(linuxsrcdir)/dev/drivers/block
vpath %.c $(linuxsrcdir)/src/drivers/block

linux-net-files = auto_irq.c 3c501.c 3c503.c 3c505.c 3c507.c 3c509.c \
	3c59x.c 3c515.c 8390.c Space.c ac3200.c apricot.c at1700.c atp.c \
	de4x5.c de600.c de620.c depca.c dev.c e2100.c eepro.c eepro100.c \
	eexpress.c epic100.c eth16i.c ewrk3.c fmv18x.c hp-plus.c hp.c hp100.c \
	lance.c ne.c ne2k-pci.c net_init.c ni52.c ni65.c pcnet32.c rtl8139.c \
	seeq8005.c sk_g16.c smc-ultra.c smc-ultra32.c tlan.c tulip.c \
	via-rhine.c wavelan.c wd.c yellowfin.c znet.c net.c
vpath %.c $(linuxsrcdir)/dev/drivers/net
vpath %.c $(linuxsrcdir)/dev/net/core
vpath %.c $(linuxsrcdir)/src/drivers/net
vpath %.c $(linuxsrcdir)/src/net/core

linux-pci-files = pci.c
vpath %.c $(linuxsrcdir)/dev/drivers/pci
vpath %.c $(linuxsrcdir)/src/drivers/pci

linux-scsi-files = 53c78xx.c AM53C974.c BusLogic.c NCR53c406a.c advansys.c \
	aha152x.c aha1542.c aha1740.c aic7xxx.c constants.c dtc.c eata.c \
	eata_dma.c eata_pio.c fdomain.c g_NCR5380.c gdth.c hosts.c in2000.c \
	ncr53c8xx.c pas16.c ppa.c qlogicfas.c qlogicisp.c scsi.c scsi_ioctl.c \
	scsi_proc.c scsicam.c sd.c sd_ioctl.c seagate.c sr.c sr_ioctl.c \
	t128.c tmscsim.c tmscsiw.c u14-34f.c ultrastor.c wd7000.c
vpath %.c $(linuxsrcdir)/dev/drivers/scsi
vpath %.c $(linuxsrcdir)/src/drivers/scsi


all-linux-files = $(linux-c-files) $(linux-block-files) \
		$(linux-net-files) $(linux-pci-files) $(linux-scsi-files)

# These are always used.
linux-objs := $(subst .c,.o, $(linux-c-files) $(linux-pci-files)) genhd.o
linux-objs += $(subst .S,.o, $(linux-asm-files))

# These files need special flags for compilation; each one will
# have a variable like wd7000.c-linux-flags with those flags.
CFLAGS += $($(<F)-linux-flags)
ASFLAGS += $($(<F)-linux-flags)

CPPFLAGS = -DMACH -DCMU -DMACH_KERNEL -DKERNEL -DLINUX_DEV \
	-DCONTINUATIONS -D__ELF__ -Di386 \
	-I. -I.. -I$(srcdir)/.. -I../.. -I$(srcdir)/../.. \
	-I$(srcdir)/../../include -I$(srcdir)/../../bogus \
	-I$(srcdir)/../../util -I$(srcdir)/../../kern \
	-I$(srcdir)/../../device -I$(sysdep)/i386at -I$(sysdep)/i386 \
	-I$(sysdep)/include -I$(sysdep)/include/mach/sa -I$(sysdep)/bogus \
	-I$(sysdep) -Wall

# These flags are:
# Instead of Mach's KERNEL, Linux uses __KERNEL__.  Whee.
# Arrange for special include directories too.
# Because of the use of `extern inline' in some Linux header files without
# corresponding text-segment definitions, we must always optimize.
linux-gen-flags = -D__KERNEL__ -O2 \
	-Idev/include -I$(srcdir)/dev/include \
	-I$(linuxdir)/dev/include -I$(linuxdir)/src/include \
	-I$(linuxsrcdir)/dev/include -I$(linuxsrcdir)/src/include
linux-block-flags = -I$(linuxsrcdir)/dev/drivers/block \
	-I$(linuxsrcdir)/src/drivers/block
linux-net-flags = -I$(linuxsrcdir)/dev/drivers/net \
	-I$(linuxsrcdir)/src/drivers/net
linux-pci-flags = -I$(linuxsrcdir)/dev/drivers/pci \
	-I$(linuxsrcdir)/src/drivers/pci
linux-scsi-flags = -I$(linuxsrcdir)/dev/drivers/scsi \
	-I$(linuxsrcdir)/src/drivers/scsi
linux-asm-spec-flags = -D__KERNEL__ -D__ASSEMBLY__ -traditional \
	-Idev/include -I$(linuxdir)/dev/include -I$(linuxdir)/src/include \
	-I$(srcdir)/dev/include -I$(linuxsrcdir)/dev/include \
	-I$(linuxsrcdir)/src/include


# Here is where those specs are found.
-include linux-flags

# How to make this file:

linux-flags: Makefile
	rm -f $@
	for i in $(linux-c-files); do \
		echo $$i-linux-flags '= $$(linux-gen-flags)' >> $@; \
	done
	for i in $(linux-block-files); do \
		echo $$i-linux-flags \
		  '= $$(linux-gen-flags) $$(linux-block-flags)' >> $@; \
	done
	for i in $(linux-net-files); do \
		echo $$i-linux-flags \
		  '= $$(linux-gen-flags) $$(linux-net-flags)' >> $@; \
	done
	for i in $(linux-pci-files); do \
		echo $$i-linux-flags \
		  '= $$(linux-gen-flags) $$(linux-pci-flags)' >> $@; \
	done
	for i in $(linux-scsi-files); do \
		echo $$i-linux-flags \
		  '= $$(linux-gen-flags) $$(linux-scsi-flags)' >> $@; \
	done
	for i in $(linux-asm-files); do \
		echo $$i-linux-flags '= $$(linux-asm-spec-flags)' >> $@; \
	done
	echo 'linux-flags-done='$(all-linux-files) $(linux-asm-files) >> $@

# If we haven't included `linux-flags' properly, then don't try and build
# .d files.
ifneq ($(linux-flags-done),$(all-linux-files) $(linux-asm-files))
no_deps=t
endif

linux-objs += $(sort $(device_drivers))



# Autoconf support

$(srcdir)/configure: $(srcdir)/Drivers.in $(srcdir)/../../Drivers.macros
	cd $(srcdir) && rm -f configure && autoconf Drivers.in > configure

device-drivers.h: $(srcdir)/Makefile.in config.status
	./config.status

config.status: $(srcdir)/configure
	./config.status --recheck

vpath %.in $(srcdir)
vpath configure $(srcdir)



# Create a linuxdev object file.
all: linux.o

linux.o: $(linux-objs) $(srcdir)/configure
	rm -f $@
	$(LD) -r -o $@ $(linux-objs)

clean:
	rm -f $(linux-objs) linux.o

distclean: clean
	rm -f $(linuxdir)/src/include/asm $(linuxdir)/dev/include/asm
	rm -f config.status config.log Makefile device-drivers.h

mostlyclean: distclean

maintainer-clean: mostlyclean
	rm -f $(srcdir)/configure



#
# Dependency generation
#

# Include dependency files
ifneq ($(no_deps),t)

# For each .o file we need a .d file.
-include $(subst .o,.d,$(filter %.o,$(linux-objs))) /dev/null

endif

# Generic rule for $(CC) based compilation for making dependencies
define make-deps
set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MG $< | \
	sed > $@.new -e 's/$*\.o:/$*.o $@:/'
mv -f $@.new $@
endef

%.d: %.c $(before-compile); $(make-deps)
%.d: %.S $(before-compile); $(make-deps)