propagator/Makefile

207 lines
5.5 KiB
Makefile
Raw Normal View History

2004-01-20 21:32:43 +03:00
#******************************************************************************
#
# mdk-stage1 - the program that will load second-stage install
#
# $Id$
#
# Guillaume Cottenceau (gc@mandrakesoft.com)
#
# Copyright 2000 MandrakeSoft
#
# This software may be freely redistributed under the terms of the GNU
# public license.
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Portions from Erik Troan (ewt@redhat.com) Copyright 1996 Red Hat Software
#
#*****************************************************************************
#
# Currently:
#
# ix86
# init with minilibc
# stage1 with dietlibc except some targets
#
# ppc
# init with dietlibc
# stage1 with glibc
#
# ia64
# init with glibc
# stage1 with glibc
#
#*****************************************************************************
2004-11-22 16:47:29 +03:00
PACKAGE = propagator
RPM = /bin/rpm
RPMSPEC = $(PACKAGE).spec
VERSION = $(shell $(RPM) -q --qf '[%{VERSION} ]' --specfile $(RPMSPEC) |cut -f1 -d ' ')
RELEASE = $(shell $(RPM) -q --qf '[%{RELEASE} ]' --specfile $(RPMSPEC) |cut -f1 -d ' ')
TARFILE = $(PACKAGE)-$(VERSION).tar.bz2
TARDIR = $(shell $(RPM) --define 'name $(PACKAGE)' --eval %_sourcedir)
2004-01-20 21:32:43 +03:00
2004-11-22 16:47:29 +03:00
DESTDIR =
2004-12-06 22:55:19 +03:00
METHODS ?= full medias network
2004-12-18 02:38:21 +03:00
BINDIR ?= /usr/bin
2004-11-22 16:47:29 +03:00
BINSDIR ?= /usr/lib/propagator/bin
2004-12-07 19:08:11 +03:00
2004-11-22 16:47:29 +03:00
include Makefile.common
2004-01-20 21:32:43 +03:00
2004-11-22 16:47:29 +03:00
STAGE1BINS = $(METHODS:%=stage1-%)
BINS = init $(STAGE1BINS)
2004-01-20 21:32:43 +03:00
DEFS =
2004-12-06 22:55:19 +03:00
ifneq ($(WITH_SHELL),)
DEFS += -DSPAWN_SHELL
endif
2004-01-20 21:32:43 +03:00
COMPILE = $(CC) $(DEFS) $(CFLAGS)
2004-11-22 16:47:29 +03:00
#- stage1 "loader"
# i386 name is invalid to force this feature off
2004-03-10 19:54:55 +03:00
ifeq (xi386, $(ARCH))
2004-01-20 21:32:43 +03:00
INITSRC = minilibc.c init.c
INIT_DEFS = -DINIT_HEADERS=\"minilibc.h\"
else
INITSRC = init.c
ifeq (ia64, $(ARCH))
INIT_DEFS = -DINIT_HEADERS=\"init-libc-headers.h\" $(GLIBC_INCLUDES)
else
INIT_DEFS = -DINIT_HEADERS=\"init-libc-headers.h\" $(DIETLIBC_INCLUDES)
endif
endif
INITOBJS = $(subst .c,.o,$(INITSRC))
2004-11-22 16:47:29 +03:00
#- frontends
2004-01-20 21:32:43 +03:00
NEWT_FRONTEND_SRC = newt-frontend.c
GLIBC_NEWT_FRONTEND_LIBS = newt/libnewt.a slang/libslang.a
2004-11-22 16:47:29 +03:00
DIETLIBC_NEWT_FRONTEND_LIBS = $(DIET_LIBDIR)/libnewt.a $(DIET_LIBDIR)/libslang.a
2004-01-20 21:32:43 +03:00
STDIO_FRONTEND_SRC = stdio-frontend.c
GLIBC_STDIO_FRONTEND_LIBS =
DIETLIBC_STDIO_FRONTEND_LIBS =
FRONTEND_OBJS = $(subst .c,.o,$($(F)_FRONTEND_SRC))
FRONTEND_LINK = $(FRONTEND_OBJS) $($(L)_$(F)_FRONTEND_LIBS)
2004-11-22 16:47:29 +03:00
GLIBC_STAGE1_OWN_LIBS = mar/libmar.a /usr/lib/libbz2.a
DIETLIBC_STAGE1_OWN_LIBS = $(DIET_LIBDIR)/libmar.a $(DIET_LIBDIR)/libbz2.a
2004-01-20 21:32:43 +03:00
STAGE1_OWN_LIBS = $($(L)_STAGE1_OWN_LIBS)
ifeq (DIETLIBC, $(L))
2004-11-22 16:47:29 +03:00
STAGE1_NETWORK_LIBS = $(DIET_LIBDIR)/librpc.a
2004-01-20 21:32:43 +03:00
endif
ifeq (GLIBC, $(L))
STAGE1_NETWORK_LIBS = /usr/lib/libresolv.a
endif
2004-11-22 16:47:29 +03:00
###############################################################################
# stage1 itself
STAGE1SRC = stage1.c log.c tools.c modules.c probing.c mount.c lomount.c automatic.c frontend-common.c
MEDIASRC = cdrom.c disk.c
2004-01-20 21:32:43 +03:00
NETWORKSRC = network.c nfsmount.c dhcp.c url.c dns.c adsl.c
2004-11-22 16:47:29 +03:00
ALLSRC = $(INITSRC) $(STAGE1SRC) $(MEDIASRC) $(NETWORKSRC)
###############################################################################
2004-01-20 21:32:43 +03:00
STAGE1OBJS-MEDIA = $(subst .c,-MEDIA.o,$(STAGE1SRC) $(MEDIASRC))
MEDIA_DEFS = -DDISABLE_NETWORK
2004-01-20 21:32:43 +03:00
STAGE1OBJS-NETWORK = $(subst .c,-NETWORK.o,$(STAGE1SRC) $(NETWORKSRC))
NETWORK_DEFS = -DDISABLE_CDROM -DDISABLE_DISK
2004-01-20 21:32:43 +03:00
STAGE1OBJS-FULL = $(subst .c,-FULL.o,$(STAGE1SRC) $(MEDIASRC) $(NETWORKSRC))
2004-11-22 16:47:29 +03:00
USBNET_DEFS = -DENABLE_USBNET
USBSTORAGE_DEFS = -DENABLE_USBSTORAGE
2004-01-20 21:32:43 +03:00
2004-03-10 19:54:55 +03:00
ifeq (xi386, $(ARCH))
2004-01-20 21:32:43 +03:00
LDFLAGS_INIT = -static -nostdlib /usr/lib/crt1.o
else
ifeq (ia64, $(ARCH))
LDFLAGS_INIT = $(GLIBC_LDFLAGS_STAGE1)
INIT_LIBC = $(GLIBC_LIBC)
else
LDFLAGS_INIT = $(DIETLIBC_LDFLAGS_STAGE1)
INIT_LIBC = $(DIETLIBC_LIBC)
endif
endif
2004-12-18 02:38:21 +03:00
all: version.h $(BINS) gencpio
2004-01-20 21:32:43 +03:00
2004-11-22 16:47:29 +03:00
init: $(INITOBJS) $(INIT_LIBC)
2004-01-20 21:32:43 +03:00
$(CC) -o $@ $^ $(LDFLAGS_INIT)
$(STRIPCMD) $@
2004-11-22 16:47:29 +03:00
stage1-medias: $(STAGE1OBJS-MEDIA) $(STAGE1_OWN_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC)
2004-01-20 21:32:43 +03:00
$(CC) -o $@ $^ $(LDFLAGS_STAGE1)
$(STRIPCMD) $@
stage1-network: $(STAGE1OBJS-NETWORK) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC)
$(CC) -o $@ $^ $(LDFLAGS_STAGE1)
$(STRIPCMD) $@
2004-02-02 19:34:05 +03:00
stage1-full: $(STAGE1OBJS-FULL) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC)
2004-01-20 21:32:43 +03:00
$(CC) -o $@ $^ $(LDFLAGS_STAGE1)
$(STRIPCMD) $@
$(INITOBJS): %.o: %.c
$(COMPILE) $(INIT_DEFS) -c $<
2004-11-22 16:47:29 +03:00
$(STAGE1OBJS-MEDIA): %-MEDIA.o: %.c
$(COMPILE) $(INCLUDES) $(MEDIA_DEFS) $(USBSTORAGE_DEFS) -c $< -o $@
2004-01-20 21:32:43 +03:00
$(STAGE1OBJS-NETWORK): %-NETWORK.o: %.c
$(COMPILE) $(INCLUDES) $(NETWORK_DEFS) $(USBNET_DEFS) -c $< -o $@
$(STAGE1OBJS-FULL): %-FULL.o: %.c
2004-11-22 16:47:29 +03:00
$(COMPILE) $(INCLUDES) $(USBNET_DEFS) $(USBSTORAGE_DEFS) -c $< -o $@
2004-01-20 21:32:43 +03:00
.c.o:
$(COMPILE) $(INCLUDES) -c $<
2004-11-22 16:47:29 +03:00
version.h: /etc/altlinux-release
@sed 's|^ALT Linux \([^ ]\+\)\([^(]\+\)(\([^)]\+\))|\
echo \\#define VERSION \\"\2\\";echo \\#define DISTRIB_NAME \\"ALT Linux\2\1 \\(\3\\)\\"|' < $^ |sh > $@
2004-01-20 21:32:43 +03:00
clean:
rm -f *.o .depend $(BINS) version.h
2004-01-20 21:32:43 +03:00
.depend:
$(CPP) $(CFLAGS) -M $(ALLSRC) > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
2004-11-22 16:47:29 +03:00
*-MEDIA.o: %-MEDIA.o: %.o
2004-01-20 21:32:43 +03:00
*-NETWORK.o: %-NETWORK.o: %.o
*-FULL.o: %-FULL.o: %.o
2004-12-18 02:38:21 +03:00
gencpio: gen_init_cpio.c
$(CC) -Wall -O2 $^ -o $@
2004-11-22 16:47:29 +03:00
install: all
2004-12-18 02:38:21 +03:00
mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(BINSDIR)
install -m0755 gencpio $(DESTDIR)$(BINDIR)
2004-11-22 16:47:29 +03:00
install -m0755 init $(DESTDIR)$(BINSDIR)
@methods='$(METHODS)'; for m in $$methods; do \
mkdir -p $(DESTDIR)$(BINSDIR)/$$m; \
install -m0755 stage1-$$m $(DESTDIR)$(BINSDIR)/$$m/stage1; \
done
export: install
bte: clean $(RPMSPEC)
@tar c --exclude CVS --file $(TARDIR)/$(TARFILE) .
cat $(RPMSPEC)