propagator/Makefile
Sergey V Turchin 0d3ff4dabd 20190418-alt1
- compile with _FILE_OFFSET_BITS=64
2019-04-18 12:00:06 +03:00

132 lines
2.9 KiB
Makefile

PACKAGE = propagator
DESTDIR =
bindir = /usr/bin
libdir = /usr/lib
INSTALL = /bin/install
#---------------------------------------------------------------
L ?= GLIBC
#L = KLIBC
ifeq ($(L),KLIBC)
CC = klcc
endif
ifeq ($(F),)
ifeq ($(L),GLIBC)
F = NEWT
else
F = STDIO
endif
endif
CFLAGS += -Os -pipe -Wall
GLIBC_INCLUDES =
KLIBC_INCLUDES =
INCLUDES = $($(L)_INCLUDES)
GLIBC_LDFLAGS = -static
KLIBC_LDFLAGS =
MUSL_LDFLAGS = -static
LDFLAGS += $($(L)_LDFLAGS)
STRIPCMD = strip -R .note -R .comment
#---------------------------------------------------------------
DEFS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
#---------------------------------------------------------------
INITSRC = init.c
INITOBJS = $(addprefix $(L)-,$(subst .c,.o,$(INITSRC)))
#---------------------------------------------------------------
STAGE1_DEFS =
ifneq ($(WITH_CIFS),)
STAGE1_DEFS += -DENABLE_CIFS
endif
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) $(CFLAGS) $(DEFS)
#- 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)
KLIBC_STAGE1_NETWORK_LIBS =
GLIBC_STAGE1_NETWORK_LIBS = $(libdir)/libresolv.a
STAGE1_NETWORK_LIBS = $($(L)_STAGE1_NETWORK_LIBS)
STAGE1SRC = stage1.c log.c tools.c modules.c probing.c \
mount.c lomount.c automatic.c frontend-common.c \
cdrom.c disk.c common.c udev.c \
network.c dhcp.c url.c dns.c adsl.c \
sha256.c
STAGE1OBJS = $(addprefix $(L)-,$(subst .c,.o,$(STAGE1SRC)))
#---------------------------------------------------------------
ALLSRC = $(INITSRC) $(STAGE1SRC)
TARGETS = init gencpio
all: version.h $(TARGETS)
init: $(INITOBJS) $(STAGE1OBJS) $(STAGE1_OWN_LIBS) $(STAGE1_NETWORK_LIBS) $(FRONTEND_LINK) $(STAGE1_LIBC)
$(CC) -o $@ $^ $(LDFLAGS)
$(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:
echo -e \#define VERSION \"$(version)\" \\n\#define DISTRIB_NAME \"ALT Linux\" > $@
gencpio: gen_init_cpio.c
$(CC) $(CFLAGS) $(DEFS) -o $@ $^
install:
$(INSTALL) -D -m0755 gencpio $(DESTDIR)$(bindir)/gencpio
$(INSTALL) -m0755 mkmodpack $(DESTDIR)$(bindir)/mkmodpack
$(INSTALL) -D -m0755 init $(DESTDIR)/usr/sbin/propagator
clean:
rm -f *.o .depend $(TARGETS) version.h
.depend: version.h
$(CPP) $(CFLAGS) -M $(ALLSRC) > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif