build pg_config too and install it to staging_dir
[openwrt/svn-archive/archive.git] / openwrt / package / postgresql / Makefile
1 # $Id$
2
3 include $(TOPDIR)/rules.mk
4
5 PKG_NAME:=postgresql
6 PKG_VERSION:=7.4.7
7 PKG_RELEASE:=3
8 PKG_MD5SUM:=32dac2916d16287d95e0c958a75161fa
9
10 PKG_SOURCE_URL:=\
11 ftp://ftp3.us.postgresql.org/pub/postgresql/source/v$(PKG_VERSION)/ \
12 ftp://ftp.br.postgresql.org/pub/PostgreSQL/source/v$(PKG_VERSION)/ \
13 ftp://ftp.au.postgresql.org/pub/postgresql/source/v$(PKG_VERSION)/ \
14 ftp://ftp.tw.postgresql.org/pub/postgresql/source/v$(PKG_VERSION)/
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
16 PKG_CAT:=bzcat
17
18 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
19 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
20
21 include $(TOPDIR)/package/rules.mk
22
23 $(eval $(call PKG_template,LIBPQ,libpq,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
24 $(eval $(call PKG_template,PGSQL_CLI,pgsql-cli,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
25
26 $(PKG_BUILD_DIR)/.configured:
27 # ./configure advertise "--infodir", but does not support it, replaced with "--docdir"
28 (cd $(PKG_BUILD_DIR); rm -rf config.{cache,status} ; \
29 $(TARGET_CONFIGURE_OPTS) \
30 CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
31 CPPFLAGS="$$CPPFLAGS -I$(STAGING_DIR)/usr/include" \
32 LDFLAGS="-L$(STAGING_DIR)/usr/lib" \
33 ./configure \
34 --target=$(GNU_TARGET_NAME) \
35 --host=$(GNU_TARGET_NAME) \
36 --build=$(GNU_HOST_NAME) \
37 --program-prefix="" \
38 --program-suffix="" \
39 --prefix=/usr \
40 --exec-prefix=/usr \
41 --bindir=/usr/bin \
42 --datadir=/usr/share \
43 --includedir=/usr/include \
44 --docdir=/usr/share/info \
45 --libdir=/usr/lib \
46 --libexecdir=/usr/lib \
47 --localstatedir=/var \
48 --mandir=/usr/share/man \
49 --sbindir=/usr/sbin \
50 --sysconfdir=/etc \
51 $(DISABLE_NLS) \
52 $(DISABLE_LARGEFILE) \
53 --enable-shared \
54 --enable-static \
55 --disable-integer-datetimes \
56 --disable-rpath \
57 --without-java \
58 --without-krb4 \
59 --without-krb5 \
60 --without-openssl \
61 --without-pam \
62 --without-perl \
63 --without-python \
64 --without-readline \
65 --without-rendezvous \
66 --without-tcl \
67 --without-tk \
68 --with-zlib="yes" \
69 );
70 touch $@
71
72 $(PKG_BUILD_DIR)/.built:
73 $(MAKE) -C "$(PKG_BUILD_DIR)/src/include" \
74 DESTDIR="$(PKG_INSTALL_DIR)" \
75 all install
76 $(MAKE) -C "$(PKG_BUILD_DIR)/src/interfaces/libpq" \
77 DESTDIR="$(PKG_INSTALL_DIR)" \
78 all install
79 $(MAKE) -C "$(PKG_BUILD_DIR)/src/bin/pg_config" \
80 DESTDIR="$(PKG_INSTALL_DIR)" \
81 includedir="$(STAGING_DIR)/usr/include" \
82 libdir="$(STAGING_DIR)/usr/lib" \
83 all install
84 $(MAKE) -C "$(PKG_BUILD_DIR)/src/bin/psql" \
85 DESTDIR="$(PKG_INSTALL_DIR)" \
86 all install
87 touch $@
88
89 $(IPKG_LIBPQ):
90 install -d -m0755 $(IDIR_LIBPQ)/usr/lib
91 cp -fpR $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(IDIR_LIBPQ)/usr/lib/
92 $(RSTRIP) $(IDIR_LIBPQ)
93 $(IPKG_BUILD) $(IDIR_LIBPQ) $(PACKAGE_DIR)
94
95 $(IPKG_PGSQL_CLI):
96 install -d -m0755 $(IDIR_PGSQL_CLI)/usr/bin
97 cp -fpR $(PKG_INSTALL_DIR)/usr/bin/psql $(IDIR_PGSQL_CLI)/usr/bin/
98 $(RSTRIP) $(IDIR_PGSQL_CLI)
99 $(IPKG_BUILD) $(IDIR_PGSQL_CLI) $(PACKAGE_DIR)
100
101 $(STAGING_DIR)/usr/lib/libpq.so: $(PKG_BUILD_DIR)/.built
102 mkdir -p $(STAGING_DIR)/usr/bin
103 cp -fpR $(PKG_INSTALL_DIR)/usr/bin/pg_config $(STAGING_DIR)/usr/bin/
104 mkdir -p $(STAGING_DIR)/usr/include
105 cp -fpR $(PKG_INSTALL_DIR)/usr/include/libpq $(STAGING_DIR)/usr/include/
106 cp -fpR $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(STAGING_DIR)/usr/include/
107 cp -fpR $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(STAGING_DIR)/usr/include/
108 cp -fpR $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(STAGING_DIR)/usr/include/
109 cp -fpR $(PKG_INSTALL_DIR)/usr/include/postgresql $(STAGING_DIR)/usr/include/
110 mkdir -p $(STAGING_DIR)/usr/lib
111 cp -fpR $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(STAGING_DIR)/usr/lib/
112 touch $@
113
114 install-dev: $(STAGING_DIR)/usr/lib/libpq.so
115
116 uninstall-dev:
117 rm -rf \
118 $(STAGING_DIR)/usr/bin/pg_config \
119 $(STAGING_DIR)/usr/include/libpq \
120 $(STAGING_DIR)/usr/include/libpq-fe.h \
121 $(STAGING_DIR)/usr/include/pg_config.h \
122 $(STAGING_DIR)/usr/include/postgres_ext.h \
123 $(STAGING_DIR)/usr/include/postgresql \
124 $(STAGING_DIR)/usr/lib/libpq.{a,so*} \
125
126 compile: install-dev
127 clean: uninstall-dev