summaryrefslogtreecommitdiffstats
path: root/openwrt/package/sdk/files/Makefile.ib
blob: 915760197b919fdb7af10f60dc81ed1d32f045b8 (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
# OpenWrt SDK Makefile
TOPDIR:=${shell pwd}
BIN_DIR:=$(TOPDIR)/bin
BUILD_DIR:=$(TOPDIR)/build
TARGET_PATH := $(TOPDIR)/utils
MKFS_JFFS2:=$(TOPDIR)/utils/mkfs.jffs2
IMAGE:=$(BUILD_DIR)/root_fs
TARGET_DIR:=$(TOPDIR)/root
SED:=PATH="$(TARGET_PATH)" sed -i -e
PACKAGE_DIR=$(TOPDIR)/packages
LINUX_IMAGE:=$(BUILD_DIR)/buildroot-kernel-image
IPKG:=IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(BUILD_DIR)/etc $(TARGET_DIR)/bin/ipkg -force-defaults -force-depends

all: build

include ./include/jffs2.mk
include ./include/squashfs-lzma.mk

IMAGE_TARGETS := $(JFFS2_TARGETS) $(SQUASHFS_TARGETS)
TARGET_FS:=squashfs jffs2

define IMAGE_template
$(BIN_DIR)/openwrt-wrt54g-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-4MB,$(1)).trx
	PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g
	$(SED) "1s,^W54S,W54G," $$@
	
$(BIN_DIR)/openwrt-wrt54gs-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-8MB,$(1)).trx
	PATH=$(TARGET_PATH) addpattern -2 -i $$< -o $$@ -g
	
IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54g-$(1).bin
IMAGE_TARGETS += $(BIN_DIR)/openwrt-wrt54gs-$(1).bin


$(BIN_DIR)/openwrt-motorola-$(1).bin: $(BIN_DIR)/openwrt-generic-$(patsubst jffs2,jffs2-8MB,$(1)).trx
	PATH=$(TARGET_PATH) motorola-bin $$< $$@

IMAGE_TARGETS += $(BIN_DIR)/openwrt-motorola-$(1).bin
endef

$(foreach fs,$(TARGET_FS),$(eval $(call IMAGE_template,$(fs))))

$(IMAGE_TARGETS): $(TARGET_DIR) $(BIN_DIR) packages_install

$(BIN_DIR):
	mkdir -p $@

$(TARGET_DIR):
	mkdir -p $@
	cp -a $(TOPDIR)/target_skeleton/* $(TARGET_DIR)/

$(BUILD_DIR)/etc/ipkg.conf:
	mkdir -p $(BUILD_DIR)/etc
	echo -e 'dest root /\noption offline_root $(TARGET_DIR)' > $@

packages_install: $(TARGET_DIR) $(BUILD_DIR)/etc/ipkg.conf
	for package in $(PACKAGE_DIR)/*.ipk; do \
		$(IPKG) install $$package; \
	done

build: clean $(IMAGE_TARGETS)
clean:
	rm -rf $(TARGET_DIR) $(BIN_DIR) $(IMAGE)-* $(BUILD_DIR)/etc