please quit breaking things
[openwrt.git] / target / Makefile
1 include $(TOPDIR)/rules.mk
2 include $(TOPDIR)/rules.mk
3
4 # Default target skeleton stuff, may be overridden
5 TARGET_SKEL_DIR=default/target_skeleton
6
7 all: install
8
9 define IMAGE_template
10 $(BIN_DIR)/openwrt-wrt54g-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-4MB,$(1)).trx
11 PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g
12 $(SED) "1s,^W54S,W54G," $$@
13
14 $(BIN_DIR)/openwrt-wrt54gs-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-8MB,$(1)).trx
15 PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g
16
17 ifeq ($(BR2_TARGET_WRT54G),y)
18 IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54g-$(1).bin
19 endif
20 ifeq ($(BR2_TARGET_WRT54GS),y)
21 IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54gs-$(1).bin
22 endif
23 endef
24
25 TARGET_DIRS:=
26 TARGET_FS:=
27 IMAGE_TARGETS:=
28 ifeq ($(strip $(BR2_TARGET_ROOTFS_JFFS2)),y)
29 TARGET_DIRS += jffs2
30 TARGET_FS += jffs2
31 endif
32 ifeq ($(strip $(BR2_TARGET_ROOTFS_SQUASHFS_LZMA)),y)
33 TARGET_DIRS += squashfs-lzma
34 TARGET_FS += squashfs
35 endif
36 $(foreach fs,$(TARGET_FS),$(eval $(call IMAGE_template,$(fs))))
37
38 INSTALL_TARGET_DIRS:=$(patsubst %,%-install,$(TARGET_DIRS))
39 $(INSTALL_TARGET_DIRS): image_clean $(TARGET_DIR)/etc/sysconf $(BIN_DIR)
40
41 prepare: $(patsubst %,%-prepare,$(TARGET_DIRS))
42 mkdir -p $(TARGET_DIR)
43 if [ -f "$(TARGET_SKELETON)" ] ; then \
44 zcat $(TARGET_SKELETON) | tar -C $(BUILD_DIR) -xf -; \
45 fi;
46 if [ -d "$(TARGET_SKEL_DIR)" ] ; then \
47 cp -a $(TARGET_SKEL_DIR)/* $(TARGET_DIR)/; \
48 fi;
49 mkdir -p $(TARGET_DIR)/jffs
50 mkdir -p $(TARGET_DIR)/dev
51 mkdir -p $(TARGET_DIR)/proc
52 mkdir -p $(TARGET_DIR)/tmp
53 mkdir -p $(TARGET_DIR)/lib
54 mkdir -p $(TARGET_DIR)/usr/lib
55 mkdir -p $(TARGET_DIR)/usr/bin
56 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
57 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
58
59 $(BIN_DIR):
60 mkdir -p $(BIN_DIR)
61
62 compile: $(patsubst %,%-compile,$(TARGET_DIRS))
63 install: utils-install $(patsubst %,%-install,$(TARGET_DIRS)) $(IMAGE_TARGETS)
64 clean: $(patsubst %,%-clean,$(TARGET_DIRS)) image_clean
65
66 image_clean:
67 rm -f $(BIN_DIR)/openwrt-*
68
69 $(TARGET_DIR)/etc/sysconf:
70 mkdir -p $(TARGET_DIR)/etc
71 -grep \^BR2_SYSCONF $(TOPDIR)/.config > $(TARGET_DIR)/etc/sysconf
72
73 %-clean:
74 $(MAKE) -C $(patsubst %-clean,%,$@) clean
75 %-prepare:
76 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
77 %-compile: %-prepare
78 $(MAKE) -C $(patsubst %-compile,%,$@) compile
79 %-install: %-compile
80 $(MAKE) -C $(patsubst %-install,%,$@) install
81
82
83
84 # Default target skeleton stuff, may be overridden
85 TARGET_SKEL_DIR=default/target_skeleton
86
87 all: install
88
89 define IMAGE_template
90 $(BIN_DIR)/openwrt-wrt54g-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-4MB,$(1)).trx
91 PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g
92 $(SED) "1s,^W54S,W54G," $$@
93
94 $(BIN_DIR)/openwrt-wrt54gs-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-8MB,$(1)).trx
95 PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g
96
97 ifeq ($(BR2_TARGET_WRT54G),y)
98 IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54g-$(1).bin
99 endif
100 ifeq ($(BR2_TARGET_WRT54GS),y)
101 IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54gs-$(1).bin
102 endif
103 endef
104
105 TARGET_DIRS:=
106 TARGET_FS:=
107 IMAGE_TARGETS:=
108 ifeq ($(strip $(BR2_TARGET_ROOTFS_JFFS2)),y)
109 TARGET_DIRS += jffs2
110 TARGET_FS += jffs2
111 endif
112 ifeq ($(strip $(BR2_TARGET_ROOTFS_SQUASHFS_LZMA)),y)
113 TARGET_DIRS += squashfs-lzma
114 TARGET_FS += squashfs
115 endif
116 $(foreach fs,$(TARGET_FS),$(eval $(call IMAGE_template,$(fs))))
117
118 INSTALL_TARGET_DIRS:=$(patsubst %,%-install,$(TARGET_DIRS))
119 $(INSTALL_TARGET_DIRS): image_clean $(TARGET_DIR)/etc/sysconf $(BIN_DIR)
120
121 prepare: $(patsubst %,%-prepare,$(TARGET_DIRS))
122 mkdir -p $(TARGET_DIR)
123 if [ -f "$(TARGET_SKELETON)" ] ; then \
124 zcat $(TARGET_SKELETON) | tar -C $(BUILD_DIR) -xf -; \
125 fi;
126 if [ -d "$(TARGET_SKEL_DIR)" ] ; then \
127 cp -a $(TARGET_SKEL_DIR)/* $(TARGET_DIR)/; \
128 fi;
129 mkdir -p $(TARGET_DIR)/jffs
130 mkdir -p $(TARGET_DIR)/dev
131 mkdir -p $(TARGET_DIR)/proc
132 mkdir -p $(TARGET_DIR)/tmp
133 mkdir -p $(TARGET_DIR)/lib
134 mkdir -p $(TARGET_DIR)/usr/lib
135 mkdir -p $(TARGET_DIR)/usr/bin
136 ln -sf /tmp/resolv.conf $(TARGET_DIR)/etc/resolv.conf
137 rm -rf $(TARGET_DIR)/var
138 ln -sf /tmp $(TARGET_DIR)/var
139 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
140 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
141
142 $(BIN_DIR):
143 mkdir -p $(BIN_DIR)
144
145 compile: $(patsubst %,%-compile,$(TARGET_DIRS))
146 install: utils-install $(patsubst %,%-install,$(TARGET_DIRS)) $(IMAGE_TARGETS)
147 clean: $(patsubst %,%-clean,$(TARGET_DIRS)) image_clean
148
149 image_clean:
150 rm -f $(BIN_DIR)/openwrt-*
151
152 $(TARGET_DIR)/etc/sysconf:
153 mkdir -p $(TARGET_DIR)/etc
154 -grep \^BR2_SYSCONF $(TOPDIR)/.config > $(TARGET_DIR)/etc/sysconf
155
156 %-clean:
157 $(MAKE) -C $(patsubst %-clean,%,$@) clean
158 %-prepare:
159 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
160 %-compile: %-prepare
161 $(MAKE) -C $(patsubst %-compile,%,$@) compile
162 %-install: %-compile
163 $(MAKE) -C $(patsubst %-install,%,$@) install
164
165
This page took 0.053321 seconds and 5 git commands to generate.