# HG changeset patch # User Vadim Misbakh-Soloviov # Date 1368376662 -25200 # Node ID b2df951f261dd9aedfe76c739b725411c0807b30 # Parent 5ba1dd988961b6961dccd3aeb36d26b812e225c1 Makefile improvements (DESTDIR, configuration, ...) diff -r 5ba1dd988961 -r b2df951f261d INSTALL --- a/INSTALL Sat Jun 30 00:37:19 2012 +0200 +++ b/INSTALL Sun May 12 23:37:42 2013 +0700 @@ -3,17 +3,17 @@ Before attempting to build LuaDBI the development libaries for each database must be installed. For Debian/Ubuntu systems, the list of required dependancies are: - + * libsqlite3-dev * libmysqlclient15-dev * libpq-dev * db2exc (optional for DB2 support) * oracle-xe-client (optional for Oracle support) - + = Building = -Run `make` (or `make free`) in the source directory to build the Open Source -database drivers. To build the drivers for DB2 and Oracle, run `make all`. +Run `make` (or `make free`) in the source directory to build the Open Source +database drivers. To build the drivers for DB2 and Oracle, run `make all`. == Windows == @@ -30,6 +30,16 @@ * make db2 * make oracle += Make Targets (install) = + + * make install_free - builds and installs MySQL, PostgreSQL and SQLite3 drivers + * make install_all - as above, but also builds and installs DB2 and Oracle drivers + * make install_mysql + * make install_psql + * make install_sqlite3 + * make install_db2 + * make install_oracle + = Installation = Please consult your distributions documentation on installing Lua modules. diff -r 5ba1dd988961 -r b2df951f261d Makefile --- a/Makefile Sat Jun 30 00:37:19 2012 +0200 +++ b/Makefile Sun May 12 23:37:42 2013 +0700 @@ -1,92 +1,136 @@ -CC=gcc -CFLAGS=-g -pedantic -Wall -O2 -shared -fpic -I /usr/include/lua5.1 -I /usr/include/mysql -I /usr/include/postgresql/ -I /opt/ibm/db2exc/V9.5/include/ -I /usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public/ -I . -AR=ar rcu -RANLIB=ranlib -RM=rm -rf -MKDIR=mkdir -p +CC ?= cc +AR ?= ar rcu +RANLIB ?= ranlib +RM ?= rm -rf +MKDIR ?= mkdir -p +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) +INSTALL_DATA ?= $(INSTALL) -m 644 +LUA_V ?= 5.1 +LUA_LDIR ?= /usr/share/lua/$(LUA_V) +LUA_CDIR ?= /usr/lib/lua/$(LUA_V) -COMMON_LDFLAGS= -MYSQL_LDFLAGS=$(COMMON_LDFLAGS) -lmysqlclient -PSQL_LDFLAGS=$(COMMON_LDFLAGS) -lpq -SQLITE3_LDFLAGS=$(COMMON_LDFLAGS) -lsqlite3 -DB2_LDFLAGS=$(COMMON_LDFLAGS) -L/opt/ibm/db2exc/V9.5/lib64 -L/opt/ibm/db2exc/V9.5/lib32 -ldb2 -ORACLE_LDFLAGS=$(COMMON_LDFLAGS) -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib/ -locixe -BUILDDIR=build +COMMON_CFLAGS = -g -pedantic -Wall -O2 -shared -fPIC -DPIC -std=c99 +LUA_INC ?= -I/usr/include/lua$(LUA_V) +MYSQL_INC ?= -I/usr/include/mysql +PSQL_INC ?= -I/usr/include/postgresql +SQLITE3_INC ?= -I/usr/include +DB2_INC ?= -I/opt/ibm/db2exc/V9.5/include +ORACLE_INC ?= -I/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public +CF = $(LUA_INC) $(COMMON_CFLAGS) $(CFLAGS) -I. -DBDMYSQL=dbdmysql.so -DBDPSQL=dbdpostgresql.so -DBDSQLITE3=dbdsqlite3.so -DBDDB2=dbddb2.so -DBDORACLE=dbdoracle.so +COMMON_LDFLAGS = -shared +MYSQL_LDFLAGS ?= -lmysqlclient +PSQL_LDFLAGS ?= -lpq +SQLITE3_LDFLAGS ?= -lsqlite3 +DB2_LDFLAGS ?= -L/opt/ibm/db2exc/V9.5/lib64 -L/opt/ibm/db2exc/V9.5/lib32 -ldb2 +ORACLE_LDFLAGS ?= -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib/ -locixe +LF = $(COMMON_LDFLAGS) $(LDFLAGS) -OBJS=build/dbd_common.o -MYSQL_OBJS=$(OBJS) build/dbd_mysql_main.o build/dbd_mysql_connection.o build/dbd_mysql_statement.o -PSQL_OBJS=$(OBJS) build/dbd_postgresql_main.o build/dbd_postgresql_connection.o build/dbd_postgresql_statement.o -SQLITE3_OBJS=$(OBJS) build/dbd_sqlite3_main.o build/dbd_sqlite3_connection.o build/dbd_sqlite3_statement.o -DB2_OBJS=$(OBJS) build/dbd_db2_main.o build/dbd_db2_connection.o build/dbd_db2_statement.o -ORACLE_OBJS=$(OBJS) build/dbd_oracle_main.o build/dbd_oracle_connection.o build/dbd_oracle_statement.o +MYSQL_FLAGS = $(CF) $(LF) $(MYSQL_INC) $(MYSQL_LDFLAGS) +PSQL_FLAGS = $(CF) $(LF) $(PSQL_INC) $(PSQL_LDFLAGS) +SQLITE3_FLAGS = $(CF) $(LF) $(SQLITE3_INC) $(SQLITE3_LDFLAGS) +DB2_FLAGS = $(CF) $(LF) $(DB2_INC) $(DB2_LDFLAGS) +ORACLE_FLAGS = $(CF) $(LF) $(ORACLE_INC) $(ORACLE_LDFLAGS) + + +BUILDDIR = build + +DBDMYSQL = dbdmysql.so +DBDPSQL = dbdpostgresql.so +DBDSQLITE3 = dbdsqlite3.so +DBDDB2 = dbddb2.so +DBDORACLE = dbdoracle.so + +OBJS = build/dbd_common.o +MYSQL_OBJS = $(OBJS) build/dbd_mysql_main.o build/dbd_mysql_connection.o build/dbd_mysql_statement.o +PSQL_OBJS = $(OBJS) build/dbd_postgresql_main.o build/dbd_postgresql_connection.o build/dbd_postgresql_statement.o +SQLITE3_OBJS = $(OBJS) build/dbd_sqlite3_main.o build/dbd_sqlite3_connection.o build/dbd_sqlite3_statement.o +DB2_OBJS = $(OBJS) build/dbd_db2_main.o build/dbd_db2_connection.o build/dbd_db2_statement.o +ORACLE_OBJS = $(OBJS) build/dbd_oracle_main.o build/dbd_oracle_connection.o build/dbd_oracle_statement.o free: mysql psql sqlite3 all: mysql psql sqlite3 db2 oracle mysql: $(BUILDDIR) $(MYSQL_OBJS) - $(CC) $(CFLAGS) $(MYSQL_OBJS) -o $(DBDMYSQL) $(MYSQL_LDFLAGS) + $(CC) $(MYSQL_OBJS) -o $(DBDMYSQL) $(MYSQL_FLAGS) psql: $(BUILDDIR) $(PSQL_OBJS) - $(CC) $(CFLAGS) $(PSQL_OBJS) -o $(DBDPSQL) $(PSQL_LDFLAGS) + $(CC) $(PSQL_OBJS) -o $(DBDPSQL) $(PSQL_FLAGS) sqlite3: $(BUILDDIR) $(SQLITE3_OBJS) - $(CC) $(CFLAGS) $(SQLITE3_OBJS) -o $(DBDSQLITE3) $(SQLITE3_LDFLAGS) + $(CC) $(SQLITE3_OBJS) -o $(DBDSQLITE3) $(SQLITE3_FLAGS) db2: $(BUILDDIR) $(DB2_OBJS) - $(CC) $(CFLAGS) $(DB2_OBJS) -o $(DBDDB2) $(DB2_LDFLAGS) + $(CC) $(DB2_OBJS) -o $(DBDDB2) $(DB2_FLAGS) oracle: $(BUILDDIR) $(ORACLE_OBJS) - $(CC) $(CFLAGS) $(ORACLE_OBJS) -o $(DBDORACLE) $(ORACLE_LDFLAGS) + $(CC) $(ORACLE_OBJS) -o $(DBDORACLE) $(ORACLE_FLAGS) clean: - $(RM) $(BUILDDIR) $(MYSQL_OBJS) $(PSQL_OBJS) $(SQLITE3_OBJS) $(DB2_OBJS) $(ORACLE_OBJS) $(DBDMYSQL) $(DBDPSQL) $(DBDSQLITE3) $(DBDDB2) $(DBDORACLE) + $(RM) $(MYSQL_OBJS) $(PSQL_OBJS) $(SQLITE3_OBJS) $(DB2_OBJS) $(ORACLE_OBJS) $(DBDMYSQL) $(DBDPSQL) $(DBDSQLITE3) $(DBDDB2) $(DBDORACLE) build/dbd_common.o: dbd/common.c dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(CF) -build/dbd_mysql_connection.o: dbd/mysql/connection.c dbd/mysql/dbd_mysql.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) +build/dbd_mysql_connection.o: dbd/mysql/connection.c dbd/mysql/dbd_mysql.h dbd/common.h + $(CC) -c -o $@ $< $(MYSQL_FLAGS) build/dbd_mysql_main.o: dbd/mysql/main.c dbd/mysql/dbd_mysql.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(MYSQL_FLAGS) build/dbd_mysql_statement.o: dbd/mysql/statement.c dbd/mysql/dbd_mysql.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(MYSQL_FLAGS) build/dbd_postgresql_connection.o: dbd/postgresql/connection.c dbd/postgresql/dbd_postgresql.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(PSQL_FLAGS) build/dbd_postgresql_main.o: dbd/postgresql/main.c dbd/postgresql/dbd_postgresql.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(PSQL_FLAGS) build/dbd_postgresql_statement.o: dbd/postgresql/statement.c dbd/postgresql/dbd_postgresql.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(PSQL_FLAGS) -build/dbd_sqlite3_connection.o: dbd/sqlite3/connection.c dbd/sqlite3/dbd_sqlite3.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) +build/dbd_sqlite3_connection.o: dbd/sqlite3/connection.c dbd/sqlite3/dbd_sqlite3.h dbd/common.h + $(CC) -c -o $@ $< $(SQLITE3_FLAGS) build/dbd_sqlite3_main.o: dbd/sqlite3/main.c dbd/sqlite3/dbd_sqlite3.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(SQLITE3_FLAGS) build/dbd_sqlite3_statement.o: dbd/sqlite3/statement.c dbd/sqlite3/dbd_sqlite3.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(SQLITE3_FLAGS) -build/dbd_db2_connection.o: dbd/db2/connection.c dbd/db2/dbd_db2.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) +build/dbd_db2_connection.o: dbd/db2/connection.c dbd/db2/dbd_db2.h dbd/common.h + $(CC) -c -o $@ $< $(DB2_FLAGS) build/dbd_db2_main.o: dbd/db2/main.c dbd/db2/dbd_db2.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(DB2_FLAGS) build/dbd_db2_statement.o: dbd/db2/statement.c dbd/db2/dbd_db2.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(DB2_FLAGS) -build/dbd_oracle_connection.o: dbd/oracle/connection.c dbd/oracle/dbd_oracle.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) +build/dbd_oracle_connection.o: dbd/oracle/connection.c dbd/oracle/dbd_oracle.h dbd/common.h + $(CC) -c -o $@ $< $(ORACLE_FLAGS) build/dbd_oracle_main.o: dbd/oracle/main.c dbd/oracle/dbd_oracle.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(ORACLE_FLAGS) build/dbd_oracle_statement.o: dbd/oracle/statement.c dbd/oracle/dbd_oracle.h dbd/common.h - $(CC) -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(ORACLE_FLAGS) build: $(MKDIR) ${BUILDDIR} +install_lua: + $(INSTALL_DATA) -D DBI.lua $(DESTDIR)$(LUA_LDIR)/DBI.lua + +install_mysql: mysql install_lua + $(INSTALL_PROGRAM) -D $(DBDMYSQL) $(DESTDIR)$(LUA_CDIR)/$(DBDMYSQL) + +install_psql: psql install_lua + $(INSTALL_PROGRAM) -D $(DBDPSQL) $(DESTDIR)$(LUA_CDIR)/$(DBDPSQL) + +install_sqlite3: sqlite3 install_lua + $(INSTALL_PROGRAM) -D $(DBDSQLITE3) $(DESTDIR)$(LUA_CDIR)/$(DBDSQLITE3) + +install_db2: db2 install_lua + $(INSTALL_PROGRAM) -D $(DBDDB2) $(DESTDIR)$(LUA_CDIR)/$(DBDDB2) + +install_oracle: oracle install_lua + $(INSTALL_PROGRAM) -D $(DBDORACLE) $(DESTDIR)$(LUA_CDIR)/$(DBDORACLE) + +install_free: install_lua install_mysql install_psql install_sqlite3 + +install_all: install_lua install_mysql install_psql install_sqlite3 install_db2 install_oracle