Use common rules and templates, uniformize package Makefile, move ipkg related files...
[openwrt/openwrt.git] / openwrt / package / libnet / ipkg / rules
1 #!/usr/bin/make -f
2
3 ifneq ($(strip ${IPKG_RULES_INC}),)
4 include $(IPKG_RULES_INC)
5 endif
6
7 ##
8
9 PKG_VERSION := $(shell cat ./ipkg/version)
10 CURRENT_DIR := $(shell pwd)
11 INSTALL_DIR ?= $(CURRENT_DIR)/ipkg-install
12
13 unexport INSTALL_DIR
14
15 I_LIBNET := ipkg/libnet
16 I_LIBNET_DEV := ipkg/libnet-dev
17
18 BUILD_DEPS := \
19 $(STAGING_DIR)/usr/include/pcap.h \
20
21 CONFIGURE_OPTS = \
22 --enable-shared \
23 --enable-static \
24 --with-pf_packet=yes \
25
26 ##
27
28 all: package
29
30
31 .stamp-configured: $(BUILD_DEPS)
32
33 touch configure.in
34 touch include.m4
35 touch aclocal.m4
36 touch Makefile.in
37 touch configure
38
39 rm -rf config.cache
40 $(TARGET_CONFIGURE_OPTS) \
41 CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" \
42 LDFLAGS="-L$(STAGING_DIR)/usr/lib" \
43 ac_libnet_have_pf_packet=yes \
44 ac_cv_lbl_unaligned_fail=no \
45 ac_cv_libnet_endianess=lil \
46 ./configure \
47 --target=$(GNU_TARGET_NAME) \
48 --host=$(GNU_TARGET_NAME) \
49 --build=$(GNU_HOST_NAME) \
50 --program-prefix="" \
51 --program-suffix="" \
52 --prefix=/usr \
53 --exec-prefix=/usr \
54 --bindir=/usr/bin \
55 --datadir=/usr/share \
56 --includedir=/usr/include \
57 --infodir=/usr/share/info \
58 --libdir=/usr/lib \
59 --libexecdir=/usr/lib \
60 --localstatedir=/var \
61 --mandir=/usr/share/man \
62 --sbindir=/usr/sbin \
63 --sysconfdir=/etc \
64 $(DISABLE_LARGEFILE) \
65 $(DISABLE_NLS) \
66 $(CONFIGURE_OPTS) \
67
68 touch config.guess
69 touch config.sub
70
71 touch .stamp-configured
72
73
74 .stamp-built: .stamp-configured
75
76 $(MAKE) \
77 $(TARGET_CONFIGURE_OPTS) \
78 CFLAGS="$(TARGET_CFLAGS)" \
79
80 touch .stamp-built
81
82
83 $(INSTALL_DIR)/usr/include/libnet.h: .stamp-built
84
85 mkdir -p $(INSTALL_DIR)
86
87 $(MAKE) \
88 DESTDIR="$(INSTALL_DIR)" \
89 install
90
91
92 configure: .stamp-configured
93
94
95 build: .stamp-built
96
97
98 install: $(INSTALL_DIR)/usr/include/libnet.h
99
100
101 package: $(INSTALL_DIR)/usr/include/libnet.h
102
103 mkdir -p $(I_LIBNET)/usr/lib
104 cp -fpR $(INSTALL_DIR)/usr/lib/libnet.so.* $(I_LIBNET)/usr/lib/
105 $(STRIP) $(I_LIBNET)/usr/lib/libnet.so.*
106
107 mkdir -p $(I_LIBNET_DEV)/usr/bin
108 cp -fpR $(INSTALL_DIR)/usr/bin/libnet-config $(I_LIBNET_DEV)/usr/bin/
109 mkdir -p $(I_LIBNET_DEV)/usr/include
110 cp -fpR $(INSTALL_DIR)/usr/include/libnet.h $(I_LIBNET_DEV)/usr/include/
111 cp -fpR $(INSTALL_DIR)/usr/include/libnet $(I_LIBNET_DEV)/usr/include/
112 mkdir -p $(I_LIBNET_DEV)/usr/lib
113 cp -fpR $(INSTALL_DIR)/usr/lib/libnet.a $(I_LIBNET_DEV)/usr/lib/
114 cp -fpR $(INSTALL_DIR)/usr/lib/libnet.so* $(I_LIBNET_DEV)/usr/lib/
115
116 chmod 0755 ipkg/*/CONTROL/
117 chmod 0644 ipkg/*/CONTROL/control
118
119 perl -pi -e "s/^Arch.*:.*/Architecture: $(ARCH)/g" ipkg/*/CONTROL/control
120 ifneq ($(strip $(PKG_VERSION)),)
121 perl -pi -e "s/^Vers.*:.*/Version: $(PKG_VERSION)/g" ipkg/*/CONTROL/control
122 endif
123
124 $(IPKG_BUILD) $(I_LIBNET) $(IPKG_TARGET_DIR)
125 $(IPKG_BUILD) $(I_LIBNET_DEV) $(IPKG_TARGET_DIR)
126
127
128 clean:
129
130 -$(MAKE) \
131 DESTDIR="$(INSTALL_DIR)" \
132 uninstall clean
133
134 rm -rf .stamp-* \
135 $(I_LIBNET)/usr \
136 $(I_LIBNET_DEV)/usr \
137
138
139 control:
140
141 @cat $(I_LIBNET)/CONTROL/control
142 @echo
143 @cat $(I_LIBNET_DEV)/CONTROL/control
144 @echo
145
146
147 .PHONY: configure build install package clean control