#****************************************************************************** # # 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 # #***************************************************************************** PACKAGE = propagator DESTDIR = BINDIR ?= /usr/bin LIBDIR ?= /usr/lib BINSDIR ?= $(LIBDIR)/$(PACKAGE)/bin TARGETS = init stage1 gencpio all: version.h $(TARGETS) include Makefile.common DEFS = INIT_DEFS = STAGE1_DEFS = ifneq ($(WITH_SHELL),) STAGE1_DEFS += -DSPAWN_SHELL endif ifneq ($(WITH_SPLASH),) STAGE1_DEFS += -DSPAWN_SPLASH endif ifeq ($(WITH_ADSL),) STAGE1_DEFS += -DDISABLE_ADSL endif ifneq ($(WITHOUT_USBNET),) STAGE1_DEFS += -DDISABLE_USBNET endif COMPILE = $(CC) $(DEFS) $(CFLAGS) #- stage1 "loader" # i386 name is invalid to force this feature off ifeq (xi386, $(ARCH)) 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)) #- frontends NEWT_FRONTEND_SRC = newt-frontend.c GLIBC_NEWT_FRONTEND_LIBS = $(LIBDIR)/libnewt.a $(LIBDIR)/libslang.a DIETLIBC_NEWT_FRONTEND_LIBS = $(DIET_LIBDIR)/libnewt.a $(DIET_LIBDIR)/libslang.a 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) GLIBC_STAGE1_OWN_LIBS = $(LIBDIR)/libmar.a $(LIBDIR)/libbz2.a DIETLIBC_STAGE1_OWN_LIBS = $(DIET_LIBDIR)/libmar.a $(DIET_LIBDIR)/libbz2.a STAGE1_OWN_LIBS = $($(L)_STAGE1_OWN_LIBS) ifeq (DIETLIBC, $(L)) STAGE1_NETWORK_LIBS = $(DIET_LIBDIR)/librpc.a endif ifeq (GLIBC, $(L)) STAGE1_NETWORK_LIBS = $(LIBDIR)/libresolv.a endif ############################################################################### # stage1 itself STAGE1SRC = stage1.c log.c tools.c modules.c probing.c \ mount.c lomount.c automatic.c frontend-common.c \ cdrom.c disk.c \ network.c nfsmount.c dhcp.c url.c dns.c adsl.c ALLSRC = $(INITSRC) $(STAGE1SRC) ############################################################################### STAGE1OBJS = $(subst .c,.o,$(STAGE1SRC)) ifeq (xi386, $(ARCH)) LDFLAGS_INIT = -static -nostdlib /usr/lib/crt1.o else ifeq (ia64, $(ARCH)) LDFLAGS_INIT = $(GLIBC_LDFLAGS_STAGE1) INIT_LIBC = $(GLIBC_LIBC) else LDFLAGS_INIT = $(GLIBC_LDFLAGS_STAGE1) INIT_LIBC = $(GLIBC_LIBC) endif endif init: $(INITOBJS) $(INIT_LIBC) $(CC) -o $@ $^ $(LDFLAGS_INIT) $(STRIPCMD) $@ stage1: $(STAGE1OBJS) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC) $(CC) -o $@ $^ $(LDFLAGS_STAGE1) $(STRIPCMD) $@ $(INITOBJS): %.o: %.c $(COMPILE) $(INIT_DEFS) -c $< $(STAGE1OBJS): %.o: %.c $(COMPILE) $(INCLUDES) $(STAGE1_DEFS) -c $< -o $@ .c.o: $(COMPILE) $(INCLUDES) -c $< version.h: /etc/altlinux-release @sed 's|^ALT Linux \([^ ]\+\)\([^(]\+\)(\([^)]\+\))|\ echo \\#define VERSION \\"\2\\";echo \\#define DISTRIB_NAME \\"ALT Linux\2\1 \\(\3\\)\\"|' < $^ |sh > $@ clean: rm -f *.o .depend $(TARGETS) version.h .depend: $(CPP) $(CFLAGS) -M $(ALLSRC) > .depend ifeq (.depend,$(wildcard .depend)) include .depend endif gencpio: gen_init_cpio.c $(CC) $(CFLAGS) -o $@ $^ install: $(TARGETS) mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(BINSDIR) install -m0755 gencpio $(DESTDIR)$(BINDIR) install -m0755 init stage1 $(DESTDIR)$(BINSDIR)