propagator/Makefile
Sergey Bolshakov 435eacecc6 pre-klibc state
2008-03-01 17:50:20 +03:00

158 lines
3.4 KiB
Makefile

PACKAGE = propagator
DESTDIR =
BINDIR ?= /usr/bin
LIBDIR ?= /usr/lib
BINSDIR ?= $(LIBDIR)/$(PACKAGE)/bin
TARGETS = init stage1
all: version.h $(TARGETS)
#---------------------------------------------------------------
L ?= GLIBC
#L = KLIBC
ifeq (KLIBC, $(L))
CC = klcc
endif
ifeq ($(F),)
ifeq ($(L),GLIBC)
F = NEWT
else
F = STDIO
endif
endif
CFLAGS += -Os -pipe -Wall -D_GNU_SOURCE
GLIBC_INCLUDES =
KLIBC_INCLUDES =
INCLUDES = -I. $($(L)_INCLUDES)
GCC_LIBDIR=$(shell dirname `gcc -print-libgcc-file-name`)
LIBGCC_A=$(shell gcc -print-libgcc-file-name)
GLIBC_LDFLAGS_STAGE1 = -static
KLIBC_LDFLAGS_STAGE1 =
# $(LIBGCC_A)
LDFLAGS_STAGE1 = $($(L)_LDFLAGS_STAGE1)
GLIBC_LIBC =
KLIBC_LIBC =
STAGE1_LIBC = $($(L)_LIBC)
STRIPCMD = strip -R .note -R .comment
#---------------------------------------------------------------
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
INITSRC = init.c
INIT_DEFS = $(INCLUDES)
INITOBJS = $(addprefix $(L)-,$(subst .c,.o,$(INITSRC)))
#- frontends
NEWT_FRONTEND_SRC = newt-frontend.c
NEWT_FRONTEND_LIBS = $(LIBDIR)/libnewt.a $(LIBDIR)/libslang.a
STDIO_FRONTEND_SRC = stdio-frontend.c
STDIO_FRONTEND_LIBS =
FRONTEND_OBJS = $(addprefix $(L)-,$(subst .c,.o,$($(F)_FRONTEND_SRC)))
FRONTEND_LINK = $(FRONTEND_OBJS) $($(F)_FRONTEND_LIBS)
GLIBC_STAGE1_OWN_LIBS =
KLIBC_STAGE1_OWN_LIBS =
STAGE1_OWN_LIBS = $($(L)_STAGE1_OWN_LIBS)
ifeq ($(L),KLIBC)
STAGE1_NETWORK_LIBS =
endif
ifeq ($(L),GLIBC)
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 = $(addprefix $(L)-,$(subst .c,.o,$(STAGE1SRC)))
LDFLAGS_INIT = $($(L)_LDFLAGS_STAGE1)
INIT_LIBC = $($(L)_LIBC)
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): $(L)-%.o: %.c
$(COMPILE) $(INIT_DEFS) -c $< -o $@
$(STAGE1OBJS): $(L)-%.o: %.c
$(COMPILE) $(INCLUDES) $(STAGE1_DEFS) -c $< -o $@
$(FRONTEND_OBJS): $(L)-%.o: %.c
$(COMPILE) $(INCLUDES) -c $< -o $@
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)
initfs: all mkinitfs
sh mkinitfs > $@
test: initfs modpack
cat $^ > $@
qstage -initrd test