Skip to content

Commit e284076

Browse files
committed
alx: move Linux Makefile to target/linux/
This should make it cleaner at the top level to understand what belongs to what OS. Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
1 parent 9efaa57 commit e284076

File tree

5 files changed

+178
-149
lines changed

5 files changed

+178
-149
lines changed

Makefile

+5-149
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,12 @@
1-
export KMODDIR?= updates
2-
KMODDIR_ARG:= "INSTALL_MOD_DIR=$(KMODDIR)"
3-
ifneq ($(origin KLIB), undefined)
4-
KMODPATH_ARG:= "INSTALL_MOD_PATH=$(KLIB)"
5-
else
6-
export KLIB:= /lib/modules/$(shell uname -r)
7-
endif
8-
export KLIB_BUILD ?= $(KLIB)/build
9-
export MAKE
10-
11-
DESTDIR?=
12-
13-
ifneq ($(KERNELRELEASE),)
14-
15-
-include $(COMPAT_CONFIG)
16-
include $(COMPAT_CONFIG_CW)
17-
18-
NOSTDINC_FLAGS := -I$(M)/include/ \
19-
-include $(M)/include/linux/compat-2.6.h \
20-
$(CFLAGS)
21-
22-
obj-y := compat/
23-
24-
25-
ifeq ($(BT),)
26-
27-
28-
obj-$(CONFIG_COMPAT_NETWORK_MODULES) += src/
29-
30-
31-
ifeq ($(CONFIG_STAGING_EXCLUDE_BUILD),)
32-
endif
33-
34-
endif
35-
36-
37-
else
38-
39-
export PWD := $(shell pwd)
40-
41-
# The build will fail if there is any space in PWD.
42-
ifneq (,$(findstring $() ,$(PWD)))
43-
$(error "The path to this compat-drivers directory has spaces in it." \
44-
"Please put it somewhere where there is no space")
45-
endif
46-
47-
export CFLAGS += \
48-
-DCOMPAT_BASE="\"$(shell cat $(PWD)/.compat_base)\"" \
49-
-DCOMPAT_BASE_TREE="\"$(shell cat $(PWD)/.compat_base_tree)\"" \
50-
-DCOMPAT_BASE_TREE_VERSION="\"$(shell cat $(PWD)/.compat_base_tree_version)\"" \
51-
-DCOMPAT_PROJECT="\"Compat-wireless\"" \
52-
-DCOMPAT_VERSION="\"$(shell cat $(PWD)/.compat_version)\""
53-
54-
# These exported as they are used by the scripts
55-
# to check config and compat autoconf
56-
export COMPAT_CONFIG_CW=$(PWD)/config.mk
57-
export COMPAT_CONFIG=$(PWD)/.config
58-
export CONFIG_CHECK=$(PWD)/.config.mk_md5sum.txt
59-
export COMPAT_AUTOCONF=include/linux/compat_autoconf.h
60-
export CREL=$(shell cat $(PWD)/.compat_version)
61-
export CREL_PRE:=.compat_autoconf_
62-
export CREL_CHECK:=$(PWD)/$(CREL_PRE)$(CREL)
1+
include target/linux/port.mk
2+
#include target/freebsd/port.mk
633

644
all: help
655

666
help:
677
@echo Possible build options:
688
@echo
69-
@echo make linux-src - Transforms code for integration into linux-next
70-
@echo make linux - Builds alx for any Linux kernel 2.6.28 - 3.x
71-
72-
$(COMPAT_CONFIG): ;
73-
74-
# Convert unified driver code to Linux, always targeting linux-next
75-
linux-src:
76-
@cp -a src target/linux/
77-
78-
# Uses compat-drivers to provide backport functionality
79-
# to support the linux-next driver down to all supported
80-
# compat-drivers kernels.
81-
linux: $(CREL_CHECK)
82-
@patch -p6 -d target/linux/src/ < unified-drivers/network/0001-backport-alx.patch
83-
$(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules
84-
@touch $@
85-
86-
# We use a CREL_CHECK variable which will depend on the environment used to
87-
# build. If the environment requirements change it forces a reconfiguration
88-
# check. This means we force a new reconfiguration check if a the user gets a
89-
# new updates of compat-drivers or when the user updates the $(COMPAT_CONFIG)
90-
# file.
91-
# XXX: add kernel target to the CREL_CHECK mix, this would ensure we also
92-
# reconfigure and build again fresh if we detect a new target kernel is
93-
# being used.
94-
$(CREL_CHECK):
95-
@# Force to regenerate compat autoconf
96-
+@./compat/scripts/gen-compat-config.sh > $(COMPAT_CONFIG)
97-
@rm -f $(CONFIG_CHECK)
98-
+@./scripts/check_config.sh
99-
@md5sum $(COMPAT_CONFIG_CW) > $(CONFIG_CHECK)
100-
@touch $@
101-
102-
install: uninstall install-modules install-scripts
103-
104-
install-modules: modules
105-
$(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \
106-
modules_install
107-
@./scripts/update-initramfs
108-
109-
install-scripts:
110-
@# All the scripts we can use
111-
@mkdir -p $(DESTDIR)/usr/lib/compat-drivers/
112-
@install scripts/modlib.sh $(DESTDIR)/usr/lib/compat-drivers/
113-
@# If on distributions like Mandriva which like to
114-
@# compress their modules this will find out and do
115-
@# it for you. Reason is some old version of modutils
116-
@# won't know mac80211.ko should be used instead of
117-
@# mac80211.ko.gz
118-
@./scripts/compress_modules
119-
@# Mandrake doesn't have a depmod.d/ conf file to prefer
120-
@# the updates/ dir which is what we use so we add one for it
121-
@# (or any other distribution that doens't have this).
122-
@./scripts/check_depmod
123-
@# Udev stuff needed for the new compat_firmware_class.
124-
@./compat/scripts/compat_firmware_install
125-
@/sbin/depmod -a
126-
@echo
127-
@echo Now run:
128-
@echo
129-
@echo sudo make unload to unload all: ethernet modules
130-
@echo
131-
@echo Run sudo modprobe 'driver-name' to load your desired driver.
132-
@echo If unsure reboot.
133-
@echo
134-
135-
uninstall:
136-
@# New location, matches upstream
137-
@rm -rf $(KLIB)/$(KMODDIR)/compat/
138-
@rm -rf $(KLIB)/$(KMODDIR)/drivers/net/ethernet/atheros/alx/alx.ko*
139-
@# Lets only remove the stuff we are sure we are providing
140-
@# on the misc directory.
141-
@/sbin/depmod -a
142-
@echo
143-
144-
clean:
145-
$(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean
146-
@rm -f $(CREL_PRE)*
147-
@rm -rf target/linux/src/
148-
unload:
149-
@./scripts/unload.sh
150-
151-
.PHONY: all clean install uninstall unload modules Makefile linux linux-src
152-
153-
endif
9+
@make -s linux-help
10+
@#make -s freebsd-help
15411

155-
clean-files += Module.symvers Module.markers modules modules.order
156-
clean-files += $(CREL_CHECK) $(CONFIG_CHECK) $(COMPAT_CONFIG)
12+
.PHONY: help
File renamed without changes.

target/linux/Makefile

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
export KMODDIR?= updates
2+
KMODDIR_ARG:= "INSTALL_MOD_DIR=$(KMODDIR)"
3+
ifneq ($(origin KLIB), undefined)
4+
KMODPATH_ARG:= "INSTALL_MOD_PATH=$(KLIB)"
5+
else
6+
export KLIB:= /lib/modules/$(shell uname -r)
7+
endif
8+
export KLIB_BUILD ?= $(KLIB)/build
9+
export MAKE
10+
11+
DESTDIR?=
12+
13+
ifneq ($(KERNELRELEASE),)
14+
15+
-include $(COMPAT_CONFIG)
16+
include $(COMPAT_CONFIG_CW)
17+
18+
NOSTDINC_FLAGS := -I$(M)/include/ \
19+
-include $(M)/include/linux/compat-2.6.h \
20+
$(CFLAGS)
21+
22+
obj-y := compat/
23+
24+
25+
ifeq ($(BT),)
26+
27+
28+
obj-$(CONFIG_COMPAT_NETWORK_MODULES) += src/
29+
30+
31+
ifeq ($(CONFIG_STAGING_EXCLUDE_BUILD),)
32+
endif
33+
34+
endif
35+
36+
37+
else
38+
39+
export PWD := $(shell pwd)
40+
41+
# The build will fail if there is any space in PWD.
42+
ifneq (,$(findstring $() ,$(PWD)))
43+
$(error "The path to this compat-drivers directory has spaces in it." \
44+
"Please put it somewhere where there is no space")
45+
endif
46+
47+
export CFLAGS += \
48+
-DCOMPAT_BASE="\"$(shell cat $(PWD)/.compat_base)\"" \
49+
-DCOMPAT_BASE_TREE="\"$(shell cat $(PWD)/.compat_base_tree)\"" \
50+
-DCOMPAT_BASE_TREE_VERSION="\"$(shell cat $(PWD)/.compat_base_tree_version)\"" \
51+
-DCOMPAT_PROJECT="\"Compat-wireless\"" \
52+
-DCOMPAT_VERSION="\"$(shell cat $(PWD)/.compat_version)\""
53+
54+
# These exported as they are used by the scripts
55+
# to check config and compat autoconf
56+
export COMPAT_CONFIG_CW=$(PWD)/config.mk
57+
export COMPAT_CONFIG=$(PWD)/.config
58+
export CONFIG_CHECK=$(PWD)/.config.mk_md5sum.txt
59+
export COMPAT_AUTOCONF=include/linux/compat_autoconf.h
60+
export CREL=$(shell cat $(PWD)/.compat_version)
61+
export CREL_PRE:=.compat_autoconf_
62+
export CREL_CHECK:=$(PWD)/$(CREL_PRE)$(CREL)
63+
64+
all: linux
65+
66+
$(COMPAT_CONFIG): ;
67+
68+
# Uses compat-drivers to provide backport functionality
69+
# to support the linux-next driver down to all supported
70+
# compat-drivers kernels.
71+
linux: $(CREL_CHECK)
72+
@-patch -N -p6 -d src/ < patches/unified-drivers/network/0001-backport-alx.patch
73+
$(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules
74+
@touch $@
75+
76+
# We use a CREL_CHECK variable which will depend on the environment used to
77+
# build. If the environment requirements change it forces a reconfiguration
78+
# check. This means we force a new reconfiguration check if a the user gets a
79+
# new updates of compat-drivers or when the user updates the $(COMPAT_CONFIG)
80+
# file.
81+
# XXX: add kernel target to the CREL_CHECK mix, this would ensure we also
82+
# reconfigure and build again fresh if we detect a new target kernel is
83+
# being used.
84+
$(CREL_CHECK):
85+
@# Force to regenerate compat autoconf
86+
+@./compat/scripts/gen-compat-config.sh > $(COMPAT_CONFIG)
87+
@rm -f $(CONFIG_CHECK)
88+
+@./scripts/check_config.sh
89+
@md5sum $(COMPAT_CONFIG_CW) > $(CONFIG_CHECK)
90+
@touch $@
91+
92+
install: uninstall install-modules install-scripts
93+
94+
install-modules: modules
95+
$(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \
96+
modules_install
97+
@./scripts/update-initramfs
98+
99+
install-scripts:
100+
@# All the scripts we can use
101+
@mkdir -p $(DESTDIR)/usr/lib/compat-drivers/
102+
@install scripts/modlib.sh $(DESTDIR)/usr/lib/compat-drivers/
103+
@# If on distributions like Mandriva which like to
104+
@# compress their modules this will find out and do
105+
@# it for you. Reason is some old version of modutils
106+
@# won't know mac80211.ko should be used instead of
107+
@# mac80211.ko.gz
108+
@./scripts/compress_modules
109+
@# Mandrake doesn't have a depmod.d/ conf file to prefer
110+
@# the updates/ dir which is what we use so we add one for it
111+
@# (or any other distribution that doens't have this).
112+
@./scripts/check_depmod
113+
@# Udev stuff needed for the new compat_firmware_class.
114+
@./compat/scripts/compat_firmware_install
115+
@/sbin/depmod -a
116+
@echo
117+
@echo Now run:
118+
@echo
119+
@echo sudo make unload to unload all: ethernet modules
120+
@echo
121+
@echo Run sudo modprobe 'driver-name' to load your desired driver.
122+
@echo If unsure reboot.
123+
@echo
124+
125+
uninstall:
126+
@# New location, matches upstream
127+
@rm -rf $(KLIB)/$(KMODDIR)/compat/
128+
@rm -rf $(KLIB)/$(KMODDIR)/drivers/net/ethernet/atheros/alx/alx.ko*
129+
@# Lets only remove the stuff we are sure we are providing
130+
@# on the misc directory.
131+
@/sbin/depmod -a
132+
@echo
133+
134+
clean:
135+
$(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean
136+
@rm -f $(CREL_PRE)*
137+
@rm -rf target/linux/src/
138+
unload:
139+
@./scripts/unload.sh
140+
141+
.PHONY: all clean install uninstall unload modules Makefile linux linux-src
142+
143+
endif
144+
145+
clean-files += Module.symvers Module.markers modules modules.order
146+
clean-files += $(CREL_CHECK) $(CONFIG_CHECK) $(COMPAT_CONFIG)

target/linux/port.mk

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
TARGET_LINUX=target/linux/
2+
3+
all: help
4+
5+
linux-help:
6+
@echo " make linux-src - Transforms code for integration into linux-next"
7+
@echo " make linux - Builds alx for any Linux kernel 2.6.28 - 3.x"
8+
@echo " make linux-install - Install linux target"
9+
10+
# Convert unified driver code to Linux, always targeting linux-next
11+
linux-src:
12+
@cp -a src $(TARGET_LINUX)
13+
14+
# Uses compat-drivers to provide backport functionality
15+
# to support the linux-next driver down to all supported
16+
# compat-drivers kernels.
17+
linux:
18+
$(TARGET_LINUX)/refresh-compat
19+
make -C $(TARGET_LINUX)
20+
21+
install-linux:
22+
$(MAKE) -C $(TARGET_LINUX) install-modules
23+
24+
uninstall-linux:
25+
$(MAKE) -C $(TARGET_LINUX) uninstall
26+
27+
.PHONY: linux-help linux-src linux install-linux uninstall-linux
File renamed without changes.

0 commit comments

Comments
 (0)