unix/minit

Makefile in master
Repositories | Summary | Log | Files | README | COPYING

Makefile (3630B) download


  1all: minit msvc pidfilehack hard-reboot write_proc killall5 shutdown \
  2minit-update serdo ftrigger waitinterface waitport powersave # governor
  3
  4#CFLAGS=-pipe -march=i386 -fomit-frame-pointer -Os -I../dietlibc/include
  5CC=gcc
  6PIE=
  7CFLAGS=-Wall -W -pipe -fomit-frame-pointer -Os $(PIE)
  8CROSS=
  9#CROSS=arm-linux-
 10LDFLAGS=-s $(PIE)
 11MANDIR=/usr/man
 12
 13path = $(subst :, ,$(PATH))
 14diet_path = $(foreach dir,$(path),$(wildcard $(dir)/diet))
 15ifeq ($(strip $(diet_path)),)
 16ifneq ($(wildcard /opt/diet/bin/diet),)
 17DIET=/opt/diet/bin/diet
 18else
 19DIET=
 20endif
 21else
 22DIET:=$(strip $(diet_path))
 23endif
 24
 25ifneq ($(DEBUG),)
 26CFLAGS+=-g
 27LDFLAGS+=-g
 28else
 29CFLAGS+=-O2 -fomit-frame-pointer
 30LDFLAGS+=-s
 31ifneq ($(DIET),)
 32DIET+=-Os
 33endif
 34endif
 35
 36ifneq ($(MINITROOT),)
 37CFLAGS+="-DMINITROOT=\"$(MINITROOT)\""
 38else
 39MINITROOT=/etc/minit
 40endif
 41
 42LDLIBS=-lowfat
 43
 44libowfat_path = $(strip $(foreach dir,../libowfat*,$(wildcard $(dir)/textcode.h)))
 45ifneq ($(libowfat_path),)
 46CFLAGS+=$(foreach fnord,$(libowfat_path),-I$(dir $(fnord)))
 47LDFLAGS+=$(foreach fnord,$(libowfat_path),-L$(dir $(fnord)))
 48endif
 49
 50minit: minit.o split.o openreadclose.o opendevconsole.o
 51msvc: msvc.o
 52ftrigger: ftrigger.o
 53minit-update: minit-update.o
 54serdo: serdo.o
 55waitinterface: waitinterface.o
 56waitport: waitport.o
 57powersave: powersave.o
 58governor: governor.o
 59
 60sepcode:
 61	echo "int main() { return 0; }" > true.c
 62	if $(DIET) $(CROSS)$(CC) $(CFLAGS) $(FLAGS) -Wl,-z,noseparate-code -o true true.c ; then echo -Wl,-z,noseparate-code 2>/dev/null; fi > sepcode
 63	rm -f true true.c
 64
 65shutdown: shutdown.o split.o openreadclose.o opendevconsole.o sepcode
 66	$(DIET) $(CROSS)$(CC) $(LDFLAGS) -o shutdown $(subst sepcode,,$^) $(shell cat sepcode)
 67
 68%.o: %.c
 69	$(DIET) $(CROSS)$(CC) $(CFLAGS) -c $<
 70
 71%: %.o sepcode
 72	$(DIET) $(CROSS)$(CC) $(LDFLAGS) -o $@ $(subst sepcode,,$^) $(LDLIBS) $(shell cat sepcode)
 73
 74clean:
 75	rm -f *.o minit msvc pidfilehack hard-reboot write_proc killall5 \
 76	shutdown minit-update serdo ftrigger waitinterface waitport \
 77	governor powersave sepcode
 78
 79test: test.c
 80	gcc -nostdlib -o $@ $^ -I../dietlibc/include ../dietlibc/start.o ../dietlibc/dietlibc.a
 81
 82pidfilehack: pidfilehack.c sepcode
 83	$(DIET) $(CROSS)$(CC) $(CFLAGS) -o $@ $< $(shell cat sepcode)
 84
 85hard-reboot: hard-reboot.c sepcode
 86	$(DIET) $(CROSS)$(CC) $(CFLAGS) -o $@ $< $(shell cat sepcode)
 87
 88write_proc: write_proc.c sepcode
 89	$(DIET) $(CROSS)$(CC) $(CFLAGS) -o $@ $< $(shell cat sepcode)
 90
 91killall5: killall5.c sepcode
 92	$(DIET) $(CROSS)$(CC) $(CFLAGS) -o $@ $< $(shell cat sepcode)
 93
 94install-files:
 95	install -d $(DESTDIR)$(MINITROOT) $(DESTDIR)/sbin $(DESTDIR)/bin $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man1
 96	install minit pidfilehack $(DESTDIR)/sbin
 97	install write_proc hard-reboot minit-update $(DESTDIR)/sbin
 98	install msvc serdo ftrigger waitinterface waitport $(DESTDIR)/bin
 99	if test -f $(DESTDIR)/sbin/shutdown; then install shutdown $(DESTDIR)/sbin/mshutdown; else install shutdown $(DESTDIR)/sbin/shutdown; fi
100	test -f $(DESTDIR)/sbin/init || ln $(DESTDIR)/sbin/minit $(DESTDIR)/sbin/init
101	install -m 644 hard-reboot.8 minit-list.8 minit-shutdown.8 minit-update.8 minit.8 msvc.8 pidfilehack.8 serdo.8 $(DESTDIR)$(MANDIR)/man8
102	install -m 644 waitinterface.1 waitport.1 ftrigger.1 $(DESTDIR)$(MANDIR)/man1
103
104install-fifos:
105	-mkfifo -m 600 $(DESTDIR)$(MINITROOT)/in $(DESTDIR)$(MINITROOT)/out
106
107install: install-files install-fifos
108
109VERSION=minit-$(shell head -n 1 CHANGES|sed 's/://')
110CURNAME=$(notdir $(shell pwd))
111
112tar: clean rename
113	cd ..; tar cvvf $(VERSION).tar.bz2 --use=bzip2 --exclude CVS $(VERSION)
114
115rename:
116	if test $(CURNAME) != $(VERSION); then cd .. && mv $(CURNAME) $(VERSION); fi
117
118pie:
119	$(MAKE) all PIE=-fpie