834600fea9d9f4c559a67494e82686af622b07f3
[sliver-openvswitch.git] / datapath / linux-2.4 / Makefile.in
1 builddir = @abs_builddir@
2 srcdir = @abs_srcdir@
3 top_srcdir = @abs_top_srcdir@
4 KSRC = @KSRC24@
5 VMDIR = @VMDIR@
6 VERSION = @VERSION@
7
8 # The names vpath and VPATH are very special for GNU Make and Automake.
9 # The following odd construction works around these oddities, whereas
10 # the straightforward "VPATH = $(srcdir)/.." will not work.
11 v = $(srcdir)/..
12 VPATH = $(v)
13
14 include $(srcdir)/../Modules.mk
15 include $(srcdir)/Modules.mk
16
17 default:
18 distclean: clean
19 distdir: clean
20 install:
21 all: default
22 clean:
23         rm -f $(all_objects) *_mod.o $(all_dummies)
24         for d in $(all_objdirs); do             \
25                 while                           \
26                         rmdir $$d 2> /dev/null; \
27                 do                              \
28                         d=`dirname $$d`;        \
29                 done;                           \
30         done
31
32 check: all
33
34 ifneq (,$(KSRC))
35 ifeq (/lib/modules/$(shell uname -r)/source, $(KSRC))
36   KOBJ :=  /lib/modules/$(shell uname -r)/build
37 else
38   KOBJ :=  $(KSRC)
39 endif
40
41 ifneq ($(shell grep -c 'PATCHLEVEL = 4' $(KSRC)/Makefile),1)
42   $(error Linux kernel source in $(KSRC) not 2.4)
43 endif
44
45 VERSION_FILE := $(KOBJ)/include/linux/version.h
46 ifeq (,$(wildcard $(VERSION_FILE)))
47   $(error Linux kernel source not configured - missing version.h)
48 endif
49
50 CONFIG_FILE  := $(KSRC)/include/linux/autoconf.h
51 ifeq (,$(wildcard $(CONFIG_FILE)))
52   $(error Linux kernel source not configured - missing autoconf.h)
53 endif
54
55 K_SUBLEVEL := $(shell sed -n 's/SUBLEVEL = // p' $(KSRC)/Makefile)
56 ifeq ($(shell test $(K_SUBLEVEL) -le 20; echo $?), 0)
57   # 2.4.20 and before require GCC 2.95.
58   CC := gcc-2.95
59 else
60   # Later 2.4 versions are more flexible.
61   CC := gcc-3.4 gcc-3.3 gcc-2.95
62 endif
63 test_cc = $(shell $(cc) --version > /dev/null 2>&1 && echo $(cc))
64 CC := $(foreach cc, $(CC), $(test_cc))
65 CC := $(firstword $(CC))
66 ifeq (,$(CC))
67   $(error Compiler not found)
68 endif
69
70 CFLAGS = -DVERSION=\"$(VERSION)\" -O2 -g
71 CFLAGS += -I $(srcdir)/.. -I $(builddir)/.. -I $(top_srcdir)/include
72 ifeq ($(ARCH),)
73   ARCH := $(shell uname -m | sed 's/i.86/i386/')
74 endif
75 CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
76 CFLAGS += -I$(srcdir)/compat-2.4/include-$(ARCH)
77 CFLAGS += -I$(srcdir)/compat-2.4/include
78 CFLAGS += -I$(srcdir)/compat-2.4
79 CFLAGS += -I$(KSRC)/include -I.
80 CFLAGS += -Wno-sign-compare -fno-strict-aliasing
81 CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
82             echo "-DMODVERSIONS -DEXPORT_SYMTAB \
83                   -include $(KSRC)/include/linux/modversions.h")
84
85 $(all_objects): $(all_dummies)
86 $(all_dummies):
87         mkdir -p $(@D)
88         touch $@
89
90 default: $(patsubst %,%_mod.o,$(all_modules))
91
92 define module_template
93 $(1)_objects = $$(patsubst %.c,%.o,$($(1)_sources))
94 $($(1)_sources): $(headers)
95 $(1)_mod.o: $$($(1)_objects)
96         $(LD) $(LDFLAGS) -r $$^ -o $$@
97 endef
98
99 $(foreach module,$(all_modules),$(eval $(call module_template,$(module))))
100 endif
101
102 # Much of the kernel build system in this file is derived from Intel's
103 # e1000 distribution, with the following license:
104
105 ################################################################################
106 #
107 # Intel PRO/1000 Linux driver
108 # Copyright(c) 1999 - 2007 Intel Corporation.
109 #
110 # This program is free software; you can redistribute it and/or modify it
111 # under the terms and conditions of the GNU General Public License,
112 # version 2, as published by the Free Software Foundation.
113 #
114 # This program is distributed in the hope it will be useful, but WITHOUT
115 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
116 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
117 # more details.
118 #
119 # You should have received a copy of the GNU General Public License along with
120 # this program; if not, write to the Free Software Foundation, Inc.,
121 # 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
122 #
123 # The full GNU General Public License is included in this distribution in
124 # the file called "COPYING".
125 #
126 # Contact Information:
127 # Linux NICS <linux.nics@intel.com>
128 # e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
129 # Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
130 #
131 ################################################################################