objdir-libafs-ko-20040607
[openafs.git] / src / libafs / MakefileProto.LINUX.in
1 # Copyright 2000, International Business Machines Corporation and others.
2 # All Rights Reserved.
3
4 # This software has been released under the terms of the IBM Public
5 # License.  For details, see the LICENSE file in the top-level source
6 # directory or online at http://www.openafs.org/dl/license10.html
7
8 srcdir=@srcdir@
9
10 include @TOP_OBJDIR@/src/config/Makefile.config
11
12 # OS specific object files:
13 AFS_OS_OBJS = \
14         osi_alloc.o \
15         osi_cred.o \
16         osi_groups.o \
17         osi_inode.o \
18         osi_file.o \
19         osi_misc.o \
20         osi_module.o \
21         osi_sleep.o \
22         osi_sysctl.o \
23         osi_vfsops.o \
24         osi_vm.o \
25         osi_vnodeops.o 
26
27 AFS_OS_NFSOBJS =
28
29 AFS_OS_NONFSOBJS =
30
31 COMMON_KERN_CFLAGS=$(KERN_DBG) $(KERN_OPTMZ) @LINUX_GCC_KOPTS@
32
33 COMMON_DEFINES=-D__KERNEL__ -DKERNEL -D_KERNEL -DMODULE ${SMP_DEF}
34
35 LINUX_KERNEL_PATH=@LINUX_KERNEL_PATH@
36
37 # System specific build commands and flags
38 <i386_linux26>
39 # All the platform-specific and kernel-related things are provided by
40 # the kernel build system.  So we should _not_ use COMMON_KERN_CFLAGS!
41 CCFLAGS = -Wno-strict-prototypes
42 DEFINES = $(COMMON_DEFINES)
43
44 <i386_linux22 i386_linux24>
45 CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@
46 DEFINES = $(COMMON_DEFINES) -DCPU=586
47
48 <amd64_linux24>
49 CCFLAGS = $(COMMON_KERN_CFLAGS) -mcmodel=kernel
50 DEFINES = $(COMMON_DEFINES) 
51
52 <i386_umlinux22 i386_umlinux24>
53 CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@ -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
54 DEFINES = $(COMMON_DEFINES) -DCPU=586
55
56 <alpha_linux_22 alpha_linux_24>
57 CCFLAGS = $(COMMON_KERN_CFLAGS) -mno-fp-regs -ffixed-8
58 DEFINES = $(COMMON_DEFINES)
59
60 <s390_linux22 s390_linux24>
61 CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char
62 DEFINES = $(COMMON_DEFINES) -D__s390__ 
63
64 <sparc_linux22 sparc_linux24>
65 LD = ld -m elf32_sparc
66 CCFLAGS = $(COMMON_KERN_CFLAGS) -mcpu=v8 -mno-fpu -fcall-used-g5 -fcall-used-g7
67 DEFINES = $(COMMON_DEFINES) -DCPU=sparc
68
69 <sparc64_linux22 sparc64_linux24>
70 CC = sparc64-linux-gcc
71 LD = ld -m elf64_sparc
72 CCFLAGS = $(COMMON_KERN_CFLAGS) \
73       -mcpu=ultrasparc -m64 -mno-fpu -mcmodel=medlow -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare
74 DEFINES = $(COMMON_DEFINES) -DCPU=sparc64
75
76 <ppc_linux22 ppc_linux24 ppc64_linux24>
77 CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char -msoft-float -fno-builtin -ffixed-r2
78 DEFINES = $(COMMON_DEFINES) -D__powerpc__
79
80 <parisc_linux24>
81 CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char -mno-space-regs \
82       -mfast-indirect-calls -mdisable-fpregs -ffunction-sections \
83       -march=1.1 -mschedule=7100
84 DEFINES = $(COMMON_DEFINES) -D__linux__
85
86 <ia64_linux24>
87 CCFLAGS = $(COMMON_KERN_CFLAGS) -ffixed-r13 -mfixed-range=f10-f15,f32-f127 -falign-functions=32 -mb-step
88 DEFINES = $(COMMON_DEFINES)
89
90 <all>
91 INCLUDES = -I. -I../ -I${TOP_OBJDIR}/src/config \
92   -I${TOP_SRCDIR}/rx -I${TOP_OBJDIR}/src/rxstat
93
94 CFLAGS = $(CCFLAGS) $(DEFINES) $(INCLUDES)
95
96 # Name of directory to hold object files and libraries.
97 KOBJ = MODLOAD
98 MPS = @MPS@
99
100 # COMPDIRS is called in Makefile.common to do the actual builds.
101 COMPDIRS=linux_compdirs
102 INSTDIRS=linux_instdirs
103 DESTDIRS=linux_destdirs
104
105 include Makefile.common
106
107 <i386_linux26>
108 LINUX_MODULE_EXT=ko
109 <all -i386_linux26>
110 LINUX_MODULE_EXT=o
111 <all>
112
113 LINUX_MODULE_NAME=
114 LOCAL_SMP_DEF=
115
116 setup:
117         -$(RM) -f h net netinet sys rpc
118         -ln -fs rx rpc
119         for m in ${MPS} ; do \
120                 KDIR=$(KOBJ)-${LINUX_VERSION}${LINUX_MODULE_NAME}-$$m; \
121                 mkdir -p $${KDIR}; \
122                 ln -fs ../Makefile $${KDIR}/Makefile.afs ; \
123                 ln -fs ../Makefile.common $${KDIR}/Makefile.common; \
124                 ln -fs ../config $${KDIR}/config; \
125         done 
126         
127 # Compile SP and MP clients as requested
128
129 ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
130         $(RM) -f h 
131         ln -fs ${LINUX_KERNEL_PATH}/include/linux h 
132         $(RM) -f linux 
133         ln -fs ${LINUX_KERNEL_PATH}/include/linux linux 
134         $(RM) -f net 
135         ln -fs ${LINUX_KERNEL_PATH}/include/net net 
136         $(RM) -f netinet 
137         ln -fs ${LINUX_KERNEL_PATH}/include/linux netinet 
138         $(RM) -f sys
139         ln -fs ${LINUX_KERNEL_PATH}/include/linux sys
140         $(RM) -f asm-generic
141         ln -fs ${LINUX_KERNEL_PATH}/include/asm-generic asm-generic
142         $(RM) -f asm
143 <parisc_linux22 parisc_linux24>
144         ln -fs ${LINUX_KERNEL_PATH}/include/asm-parisc asm
145 <alpha_linux_22 alpha_linux_24>
146         ln -fs ${LINUX_KERNEL_PATH}/include/asm-alpha asm
147 <i386_linux22 i386_linux24>
148         ln -fs ${LINUX_KERNEL_PATH}/include/asm-i386 asm
149 <i386_umlinux22 i386_umlinux24>
150         ln -fs ${LINUX_KERNEL_PATH}/include/asm-um asm
151 <amd64_linux24>
152         ln -fs ${LINUX_KERNEL_PATH}/include/asm-x86_64 asm
153 <s390_linux22 s390_linux24>
154         ln -fs ${LINUX_KERNEL_PATH}/include/asm-s390 asm
155 <ppc_linux22 ppc_linux24>
156         ln -fs ${LINUX_KERNEL_PATH}/include/asm-ppc asm 
157 <ppc64_linux24>
158         ln -s ${LINUX_KERNEL_PATH}/include/asm-ppc64 asm 
159 <sparc_linux22 sparc_linux24>
160         ln -fs ${LINUX_KERNEL_PATH}/include/asm-sparc asm
161 <sparc64_linux22 sparc64_linux24>
162         ln -fs ${LINUX_KERNEL_PATH}/include/asm-sparc64 asm
163 <ia64_linux24>
164         ln -fs ${LINUX_KERNEL_PATH}/include/asm-ia64 asm
165 <all>
166         for m in ${MPS} ; do \
167                 KDIR=${KOBJ}-${LINUX_VERSION}${LINUX_MODULE_NAME}-$$m ; \
168                 echo Building in directory: $${KDIR} ; \
169                 if [ "$$m" = "MP" ] ; then \
170                         SMP_DEF="-DAFS_SMP @RHCONFIG_MP@ ${LOCAL_SMP_DEF}" ; \
171                         TARG="libafs.mp" ; \
172                 elif [ "$$m" = "EP" ] ; then \
173                         SMP_DEF="-DAFS_SMP @RHCONFIG_MP@ ${LOCAL_SMP_DEF}" ; \
174                         TARG="libafs.ep" ; \
175                 elif [ "$$m" = "BM" ] ; then \
176                         SMP_DEF="-DAFS_SMP @RHCONFIG_MP@ ${LOCAL_SMP_DEF}" ; \
177                         TARG="libafs.bm" ; \
178                 else  \
179                         SMP_DEF="@RHCONFIG_SP@ ${LOCAL_SMP_DEF}" ; \
180                         TARG=libafs ; \
181                 fi ; \
182                 cd $${KDIR} ; \
183                 $(MAKE) -f Makefile.afs SMP_DEF="$${SMP_DEF}" $@_$${TARG} CLIENT=${LINUX_VERSION}${LINUX_MODULE_NAME} KDIR=$${KDIR} || exit $$?; \
184                 cd ../ ; \
185 <all>
186         done
187
188 linux_compdirs_libafs: depsrcs libafs
189 linux_compdirs_libafs.mp: depsrcs libafs.mp
190 linux_compdirs_libafs.ep: depsrcs libafs.ep
191 linux_compdirs_libafs.bm: depsrcs libafs.bm
192 linux_instdirs_libafs: install_libafs
193 linux_instdirs_libafs.mp: install_libafs.mp
194 linux_instdirs_libafs.ep: install_libafs.ep
195 linux_instdirs_libafs.bm: install_libafs.bm
196 linux_destdirs_libafs: dest_libafs
197 linux_destdirs_libafs.mp: dest_libafs.mp
198 linux_destdirs_libafs.ep: dest_libafs.ep
199 linux_destdirs_libafs.bm: dest_libafs.bm
200
201
202 # Below this line are targets when in the COMMON directory:
203 # For Linux there is no kernel NFS server.
204 LIBAFS = libafs-${CLIENT}.${LINUX_MODULE_EXT}
205 LIBAFS_MP = libafs-${CLIENT}.mp.${LINUX_MODULE_EXT}
206 LIBAFS_EP = libafs-${CLIENT}.ep.${LINUX_MODULE_EXT}
207 LIBAFS_BM = libafs-${CLIENT}.bm.${LINUX_MODULE_EXT}
208
209 INST_LIBAFS = ${DESTDIR}${afskerneldir}/${LIBAFS}
210 INST_LIBAFS_MP = ${DESTDIR}${afskerneldir}/${LIBAFS_MP}
211 INST_LIBAFS_EP = ${DESTDIR}${afskerneldir}/${LIBAFS_EP}
212 INST_LIBAFS_BM = ${DESTDIR}${afskerneldir}/${LIBAFS_BM}
213
214 DEST_LIBAFS = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS}
215 DEST_LIBAFS_MP = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS_MP}
216 DEST_LIBAFS_EP = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS_EP}
217 DEST_LIBAFS_BM = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS_BM}
218
219
220 libafs: $(LIBAFS) 
221         echo SP Build Complete
222
223 libafs.mp: $(LIBAFS_MP)
224         echo MP Build Complete
225
226 libafs.ep: $(LIBAFS_EP)
227         echo EP Build Complete
228
229 libafs.bm: $(LIBAFS_BM)
230         echo BM Build Complete
231
232 <i386_linux26>
233 ${LIBAFS} ${LIBAFS_MP} ${LIBAFS_EP} ${LIBAFS_BM}: libafs.ko
234         cp libafs.ko $@
235
236 .FORCE:
237 libafs.ko: .FORCE
238         ../$(srcdir)/make_kbuild_makefile.pl ${KDIR} $@ \
239           @TOP_OBJDIR@/src/config/Makefile.config Makefile.afs Makefile.common
240         $(MAKE) -C ${LINUX_KERNEL_PATH} M=@TOP_OBJDIR@/src/libafs/${KDIR} modules
241         
242 <all -i386_linux26>
243 ${LIBAFS}: $(AFSAOBJS) $(AFSNONFSOBJS)
244         $(RM) -f $@
245         $(LD) -r -o $@ $(AFSAOBJS) $(AFSNONFSOBJS)
246
247 ${LIBAFS_MP}: $(AFSAOBJS) $(AFSNONFSOBJS)
248         $(RM) -f $@
249         $(LD) -r -o $@ $(AFSAOBJS) $(AFSNONFSOBJS)
250
251 ${LIBAFS_EP}: $(AFSAOBJS) $(AFSNONFSOBJS)
252         $(RM) -f $@
253         $(LD) -r -o $@ $(AFSAOBJS) $(AFSNONFSOBJS)
254
255 ${LIBAFS_BM}: $(AFSAOBJS) $(AFSNONFSOBJS)
256         $(RM) -f $@
257         $(LD) -r -o $@ $(AFSAOBJS) $(AFSNONFSOBJS)
258 <all>
259
260 install_libafs: $(INST_LIBAFS) 
261         echo SP Install Complete
262
263 install_libafs.mp: $(INST_LIBAFS_MP)
264         echo MP Install Complete
265
266 install_libafs.ep: $(INST_LIBAFS_EP)
267         echo EP Install Complete
268
269 install_libafs.bm: $(INST_LIBAFS_BM)
270         echo BM Install Complete
271
272 dest_libafs:    $(DEST_LIBAFS) 
273         echo SP Install Complete
274
275 dest_libafs.mp: $(DEST_LIBAFS_MP)
276         echo MP Install Complete
277
278 dest_libafs.ep: $(DEST_LIBAFS_EP)
279         echo EP Install Complete
280
281 dest_libafs.bm: $(DEST_LIBAFS_BM)
282         echo BM Install Complete
283
284 $(INST_LIBAFS): $(LIBAFS)
285         ${INSTALL} -f $? $@
286
287 $(INST_LIBAFS_MP): $(LIBAFS_MP)
288         ${INSTALL} -f $? $@
289
290 $(INST_LIBAFS_EP): $(LIBAFS_EP)
291         ${INSTALL} -f $? $@
292
293 $(INST_LIBAFS_BM): $(LIBAFS_BM)
294         ${INSTALL} -f $? $@
295
296 $(DEST_LIBAFS): $(LIBAFS)
297         ${INSTALL} -f $? $@
298
299 $(DEST_LIBAFS_MP): $(LIBAFS_MP)
300         ${INSTALL} -f $? $@
301
302 $(DEST_LIBAFS_EP): $(LIBAFS_EP)
303         ${INSTALL} -f $? $@
304
305 $(DEST_LIBAFS_BM): $(LIBAFS_BM)
306         ${INSTALL} -f $? $@