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
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
2005-07-08 03:45:12 +04:00
LIBDIR ?= /usr/lib
BINSDIR ?= $( LIBDIR) /propagator/bin
2004-12-07 19:08:11 +03:00
2004-11-22 16:47:29 +03:00
STAGE1BINS = $( METHODS:%= stage1-%)
2005-03-05 18:39:39 +03:00
BINS = init $( STAGE1BINS) gencpio
2004-01-20 21:32:43 +03:00
2005-07-08 03:45:12 +04:00
all : version .h $( BINS )
2005-08-05 17:33:39 +04:00
i n c l u d e M a k e f i l e . c o m m o n
2005-01-21 20:03:46 +03:00
DEFS =
2004-12-06 22:55:19 +03:00
i f n e q ( $( WITH_SHELL ) , )
DEFS += -DSPAWN_SHELL
e n d i f
2005-02-28 22:26:48 +03:00
i f e q ( $( WITH_ADSL ) , )
DEFS += -DDISABLE_ADSL
e n d i f
2004-12-06 22:55:19 +03:00
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
i f e q ( x i 3 8 6 , $( ARCH ) )
2004-01-20 21:32:43 +03:00
INITSRC = minilibc.c init.c
INIT_DEFS = -DINIT_HEADERS= \" minilibc.h\"
e l s e
INITSRC = init.c
i f e q ( i a 6 4 , $( ARCH ) )
INIT_DEFS = -DINIT_HEADERS= \" init-libc-headers.h\" $( GLIBC_INCLUDES)
e l s e
INIT_DEFS = -DINIT_HEADERS= \" init-libc-headers.h\" $( DIETLIBC_INCLUDES)
e n d i f
e n d i f
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)
i f e q ( D I E T L I B C , $( L ) )
2004-11-22 16:47:29 +03:00
STAGE1_NETWORK_LIBS = $( DIET_LIBDIR) /librpc.a
2004-01-20 21:32:43 +03:00
e n d i f
i f e q ( G L I B C , $( L ) )
STAGE1_NETWORK_LIBS = /usr/lib/libresolv.a
e n d i f
2004-11-22 16:47:29 +03:00
###############################################################################
# stage1 itself
2005-02-04 23:28:52 +03:00
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
2004-11-30 14:47:57 +03:00
STAGE1OBJS-MEDIA = $( subst .c,-MEDIA.o,$( STAGE1SRC) $( MEDIASRC) )
2005-01-21 20:03:46 +03:00
MEDIA_DEFS = -DDISABLE_NETWORK
2004-01-20 21:32:43 +03:00
STAGE1OBJS-NETWORK = $( subst .c,-NETWORK.o,$( STAGE1SRC) $( NETWORKSRC) )
2004-11-30 14:47:57 +03:00
NETWORK_DEFS = -DDISABLE_CDROM -DDISABLE_DISK
2004-01-20 21:32:43 +03:00
2004-11-30 14:47:57 +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
i f e q ( x i 3 8 6 , $( ARCH ) )
2004-01-20 21:32:43 +03:00
LDFLAGS_INIT = -static -nostdlib /usr/lib/crt1.o
e l s e
i f e q ( i a 6 4 , $( ARCH ) )
LDFLAGS_INIT = $( GLIBC_LDFLAGS_STAGE1)
INIT_LIBC = $( GLIBC_LIBC)
e l s e
LDFLAGS_INIT = $( DIETLIBC_LDFLAGS_STAGE1)
INIT_LIBC = $( DIETLIBC_LIBC)
e n d i f
e n d i f
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 : $( STAGE 1OBJS -MEDIA ) $( STAGE 1_OWN_LIBS ) $( FRONTEND_LINK ) $( STAGE 1_LIBC )
2004-01-20 21:32:43 +03:00
$( CC) -o $@ $^ $( LDFLAGS_STAGE1)
$( STRIPCMD) $@
stage1-network : $( STAGE 1OBJS -NETWORK ) $( STAGE 1_OWN_LIBS ) $( STAGE 1_NETWORK_LIBS ) $( FRONTEND_LINK ) $( STAGE 1_LIBC )
$( CC) -o $@ $^ $( LDFLAGS_STAGE1)
$( STRIPCMD) $@
2004-02-02 19:34:05 +03:00
stage1-full : $( STAGE 1OBJS -FULL ) $( STAGE 1_OWN_LIBS ) $( STAGE 1_NETWORK_LIBS ) $( FRONTEND_LINK ) $( STAGE 1_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-04-14 22:47:24 +04:00
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 :
2004-12-15 23:43:02 +03:00
rm -f *.o .depend $( BINS) version.h
2004-01-20 21:32:43 +03:00
.depend :
$( CPP) $( CFLAGS) -M $( ALLSRC) > .depend
i f e q ( . d e p e n d , $( wildcard .depend ) )
i n c l u d e . d e p e n d
e n d i f
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
2005-08-05 00:18:57 +04:00
gcc -Wall -O2 $^ -o $@
2004-12-18 02:38:21 +03:00
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