blob: 9fa31f6fb244fbecb2e74c5b80d7f8f405817646 [file] [log] [blame] [raw]
# Copyright (C) 2000-2006 SWsoft. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
INSTALL = install
PREFIX = /usr
SBINDIR = $(PREFIX)/sbin
LIBDIR = $(PREFIX)/lib/vzctl
CACHEDIR = /vz/template/cache
GLBCONFIG = /etc/sysconfig/vz
VPSCONFDIR = /etc/sysconfig/vz-scripts
DISTCONFDIR = $(VPSCONFDIR)/dists
NETSCRIPTDIR = /etc/sysconfig/network-scripts
CRONDDIR = /etc/cron.d
INITDDIR = /etc/init.d
VZLOCKDIR = /vz/lock
VZDUMPDIR = /vz/dump
LOGRDIR = /etc/logrotate.d
LIB_VER = 0.0.2
export LD_LIBRARY_PATH=.
CC = gcc
CFLAGS = -Wall -g2
SHAREDLIB_CFLAGS = -fPIC
#VZKERNEL_HEADERS ?= /lib/modules/$(shell uname -r)/build/include
INC = -I ../include
ARCH=$(shell uname -i)
OBJ_libvzctl = lib/env.lo lib/ub.lo lib/net.lo lib/logger.lo lib/exec.lo \
lib/cap.lo lib/cpu.lo lib/res.lo lib/util.lo lib/dist.lo lib/list.lo \
lib/script.lo lib/dev.lo lib/config.lo lib/lock.lo lib/quota.lo \
lib/modules.lo lib/iptables.lo lib/fs.lo lib/create.lo lib/readelf.lo \
lib/cpt.lo
OBJ_simfs=lib/fs_simfs.lo
OBJ_vzctl = vzctl.o vzctl-actions.o modules.o enter.o
OBJ_vzlist = vzlist.o
OBJ_arp = arpsend.o
OBJ_split = vzsplit.o
OBJ_memcheck = vzmemcheck.o validate.o
OBJ_cfgvalidate = vzcfgvalidate.o validate.o
OBJ_calc = vzcalc.o
OBJ = $(OBJ_vzctl) $(OBJ_vzlist) $(OBJ_arp) $(OBJ_split) $(OBJ_memcheck) \
$(OBJ_cfgvalidate) $(OBJ_calc)
LOBJ = $(OBJ_libvzctl) $(OBJ_simfs)
LIB_vzctl = libvzctl.so.$(LIB_VER)
LIB_simfs = libvzctl-simfs.so.$(LIB_VER)
LIB_fs = libvzctl-fs.so
LD_FLAGS = -L. -Wl,-rpath=$(LIBDIR)/lib -ldl
LIBSCRIPTS = vps-create vps-postcreate vps-net_add vps-net_del vps-stop \
vps-functions
PROGS = vzctl vzlist arpsend vzsplit vzcfgvalidate vzmemcheck vzcalc
LIBS = $(LIB_vzctl) $(LIB_simfs)
INITSCRIPTS = vz
CRONSCRIPTS = vpsreboot vpsnetclean
SCRIPTS = vpsreboot vpsnetclean
NETSCRIPTS = ifcfg-venet0 ifdown-venet ifup-venet
VECONFIG = ve-light.conf-sample ve-vps.basic.conf-sample
VECONFIG_IA64 = ve-light.conf-sample ve-vps.basic.conf-sample
VECONFIG_X86_64 = ve-light.conf-sample ve-vps.basic.conf-sample
default: all
all: $(PROGS) $(LIBS)
%.o: %.c
$(CC) -c $(CFLAGS) $(INC) $< -o $@
%.lo: %.c
$(CC) -c $(CFLAGS) $(SHAREDLIB_CFLAGS) $(INC) $< -o $@
$(LIB_simfs) : $(OBJ_simfs)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_simfs) -shared -o $@
$(LIB_fs): $(LIB_simfs)
ln -sf $(LIB_simfs) $(LIB_fs)
libvzctl.a: $(OBJ_libvzctl)
ar scq $@ $+
ranlib $@
$(LIB_vzctl) : $(LIB_simfs) $(OBJ_libvzctl)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_libvzctl) $(LD_FLAGS) -shared -o $@
vzctl-static: $(OBJ_vzctl) libvzctl.a
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_vzctl) $(OBJ_simfs) libvzctl.a -rdynamic -ldl -lutil -o $@
vzctl: $(LIB_vzctl) $(OBJ_vzctl) $(LIB_fs)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_vzctl) $(LD_FLAGS) $(LIB_vzctl) $(LIB_fs) -lutil -o $@
vzlist: $(OBJ_vzlist) $(LIB_vzctl) $(LIB_fs)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_vzlist) $(LD_FLAGS) $(LIB_fs) $(LIB_vzctl) -o $@
arpsend: $(OBJ_arp)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
vzsplit: $(OBJ_split)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
vzmemcheck: $(OBJ_memcheck) $(LIB_vzctl) $(LIB_fs)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(LD_FLAGS) $(LIB_fs) $(LIB_vzctl) $^ -o $@
vzcfgvalidate: $(OBJ_cfgvalidate) $(LIB_vzctl) $(LIB_fs)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ $(LD_FLAGS) $(LIB_fs) $(LIB_vzctl) -o $@
vzcalc: $(OBJ_calc) $(LIB_vzctl) $(LIB_fs)
$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ $(LD_FLAGS) $(LIB_fs) $(LIB_vzctl) -o $@
inst-sbin :$(PROGS)
for file in $(PROGS); do \
$(INSTALL) $$file $(DESTDIR)$(SBINDIR)/$$file; \
done
install-lib: $(LIB_vzctl) $(LIB_fs)
$(INSTALL) -d $(DESTDIR)$(LIBDIR)/lib
$(INSTALL) -d $(DESTDIR)$(LIBDIR)/scripts
$(INSTALL) $(LIB_vzctl) $(DESTDIR)$(LIBDIR)/lib/$(LIB_vzctl)
$(INSTALL) $(LIB_simfs) $(DESTDIR)$(LIBDIR)/lib/$(LIB_simfs)
cp -a $(LIB_fs) $(DESTDIR)$(LIBDIR)/lib/$(LIB_fs)
for file in $(LIBSCRIPTS); do \
$(INSTALL) ../etc/$$file $(DESTDIR)$(LIBDIR)/scripts/$$file; \
done
inst-scripts:
for file in $(SCRIPTS); do \
$(INSTALL) ../etc/$$file $(DESTDIR)$(VPSCONFDIR)/$$file; \
done
inst-netscripts:
for file in $(NETSCRIPTS); do \
$(INSTALL) ../etc/$$file $(DESTDIR)$(NETSCRIPTDIR)/$$file; \
done
inst-configs:
$(INSTALL) -m 644 ../etc/vz $(DESTDIR)$(GLBCONFIG)
ifeq ($(ARCH),ia64)
for file in $(VECONFIG_IA64); do \
$(INSTALL) ../etc/$$file.ia64 $(DESTDIR)$(VPSCONFDIR)/$$file; \
done
else
ifeq ($(ARCH),x86_64)
for file in $(VECONFIG_X86_64); do \
$(INSTALL) ../etc/$$file.x86_64 $(DESTDIR)$(VPSCONFDIR)/$$file; \
done
else
for file in $(VECONFIG); do \
$(INSTALL) ../etc/$$file $(DESTDIR)$(VPSCONFDIR)/$$file; \
done
endif
endif
inst-initd:
for file in $(INITSCRIPTS); do \
$(INSTALL) ../etc/init.d/$$file $(DESTDIR)$(INITDDIR)/$$file; \
done
inst-cron:
for file in $(CRONSCRIPTS); do \
$(INSTALL) ../etc/cron.d/$$file $(DESTDIR)$(CRONDDIR)/$$file; \
done
inst-dirs:
$(INSTALL) -d $(DESTDIR)$(SBINDIR)
$(INSTALL) -d $(DESTDIR)$(VPSCONFDIR)
$(INSTALL) -d $(DESTDIR)$(DISTCONFDIR)
$(INSTALL) -d $(DESTDIR)$(NETSCRIPTDIR)
$(INSTALL) -d $(DESTDIR)$(VPSCONFDIR)
$(INSTALL) -d $(DESTDIR)$(CRONDDIR)
$(INSTALL) -d $(DESTDIR)$(INITDDIR)
$(INSTALL) -d $(DESTDIR)$(VZLOCKDIR)
$(INSTALL) -d $(DESTDIR)$(VZDUMPDIR)
$(INSTALL) -d $(DESTDIR)$(LOGRDIR)
$(INSTALL) -d $(DESTDIR)$(CACHEDIR)
$(INSTALL) -m 644 ../etc/logrotate.d/vzctl $(DESTDIR)$(LOGRDIR)/vzctl
install: $(PROGS) inst-dirs install-lib inst-sbin inst-scripts \
inst-netscripts inst-configs inst-initd inst-cron
clean:
rm -f *.o lib/*.lo $(PROGS) $(LIB_vzctl) $(LIB_fs) $(LIB_simfs) .depend
.depend:: $(OBJ:.o=.c) $(LOBJ:.lo=.c)
$(CC) -M $(FLAGS) $(DEPFLAGS) $(INC) $^ >.depend
depend:: .depend
include .depend
.PHONY: clean depend install inst-dirs inst-config \
inst-initd install-cron all default inst-config inst-lib