summaryrefslogtreecommitdiffstats
path: root/loader/Makefile
blob: 80126546288e9eb5a3ac3a69afe6443ef3b5e4cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
include ../Makefile.inc

DESTDIR = ../../trees/initrd

OBJS = log.o windows.o modules.o devices.o cdrom.o kickstart.o lang.o \
       misc.o ftp.o md5.o mediacheck.o moduledeps.o

SLANGLIB = ../minislang/libslang.a
NEWTLIB = ../mininewt/libnewt.a
ifneq (ia64, $(ARCH))
ifneq (i386, $(ARCH))
ifneq (x86_64, $(ARCH))
ifneq (ppc, $(ARCH))
OBJS += fnmatch-stub.o printf-stub.o pwd-stub.o dl-stub.o
endif
endif
endif
endif

LOADEROBJS = loader.o loader-pcmcia.o popen.o
SOURCES = $(subst .o,.c,$(OBJS)) loader.c
BINS = init
DIRS = 
NETOBJS = net.o urls.o telnet.o telnetd.o
PCMCIAOBJS = pcmcia.o $(NETOBJS)
OPTS = -Os
DEBUG = -g

MODULELINKAGE :=-lmodutils -lmodutilutil -lmodutilobj

COPTS = $(DEBUG) -Wall -DVERSION='"$(VERSION)"' 

CFLAGS = $(COPTS) $(OPTS) -Os -function-sections -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/include/kudzu -I/usr/include/rpm -I.. -I../isys -DHAVE_LIBIO_H -DPRODUCTNAME='$(PRODUCTNAME)'

# XXX diet is i386 only at the moment
ifeq (i386, $(ARCH))
CFLAGS += -DGZLIB=1
endif
ifeq (ppc, $(ARCH))
CFLAGS += -DGZLIB=1
endif

ALLOBJS = $(OBJS) $(PCMCIAOBJS)

ISYS = ../isys/libisys.a
GUNZIP = -lz
LOADERLIBS = -lpci

# XXX Japanese is i386 only at the moment
ifeq (i386, $(ARCH))
BINS += loader-local loader-network loader-pcmcia
 ifeq (1, $(JAPANESE))
 KONOBJS = ./kon2/src/libkon.a ./kon2/src/display.a ./kon2/lib/libgon.a
 CFLAGS += -DINCLUDE_KON
 DIRS += kon2
 endif
OBJS += dietstubs.o ctype.o
endif

ifeq (x86_64, $(ARCH))
BINS += loader
 ifeq (1, $(JAPANESE))
 KONOBJS = ./kon2/src/libkon.a ./kon2/src/display.a ./kon2/lib/libgon.a
 CFLAGS += -DINCLUDE_KON
 DIRS += kon2
 endif
endif

ifeq (ia64, $(ARCH))
BINS += loader
endif

ifeq (alpha, $(ARCH))
BINS += loader
OBJS += stubs.o
endif

ifeq (s390, $(ARCH))
BINS += loader
OBJS += stubs.o
S390FILES = load_anaconda
endif

ifeq (s390x, $(ARCH))
BINS += loader
OBJS += stubs.o
S390FILES = load_anaconda
endif

ifeq (sparc, $(ARCH))
BINS += loader loader-local
OBJS += stubs.o
endif

ifeq (ppc, $(ARCH))
BINS += loader loader-local loader-network
OBJS += dietstubs.o ctype.o
endif

ifeq (.depend,$(wildcard .depend))
TARGET=$(PROGS)
else
TARGET=depend $(PROGS)
endif

STATIC = -static

ifeq (i386, $(ARCH))
MINILIBC=minilibc.o
COPTS+=-DUSE_MINILIBC=1 -DUSE_LOGDEV 
LDFLAGS = -nostdlib /usr/lib/crt1.o
LOADERLIBS += -lrpc
ISYS = ../isys/libisys-diet.a
SLANGLIB = ../minislang/libslang-diet.a
NEWTLIB = ../mininewt/libnewt-diet.a
GUNZIP = ../isys/gzlib/libgunzip-diet.a
DIET=diet
REALCC=gcc
CC=$(DIET) $(REALCC)
STATIC=-static
else
REALCC=$(CC)
ifeq (sparc, $(ARCH))
MINILIBC=minilibc.o /usr/lib/libc.a
CFLAGS+=-DUSE_MINILIBC=1 -DUSE_LOGDEV
LDFLAGS = -nostdlib /usr/lib/crt1.o
LOADERLIBS += -lresolv
STATIC=-static
else
ifeq (ppc, $(ARCH))
MINILIBC=minilibc.o
COPTS+=-DUSE_MINILIBC=1 -DUSE_LOGDEV
LDFLAGS = -nostdlib /usr/lib/crt1.o
LOADERLIBS += -lrpc
ISYS = ../isys/libisys-diet.a
SLANGLIB = ../minislang/libslang-diet.a
NEWTLIB = ../mininewt/libnewt-diet.a
GUNZIP = ../isys/gzlib/libgunzip-diet.a
DIET=diet
REALCC=gcc
CC=$(DIET) $(REALCC)
STATIC=-static
else
CFLAGS+=-DUSE_MINILIBC=0
STATIC=-static
LOADERLIBS += -lresolv
endif
endif
endif

LANGS = $(shell awk '{ print $$2 }' ../lang-table | egrep -v '(^en$$)')

TR = $(patsubst %,tr/%.tr,$(LANGS))
TRFILES = $(patsubst %,%.tr,$(LANGS))

all: dirs $(BINS) loader.tr 

loader.tr: $(TR) ../lang-table
	(cd tr; ls $(TRFILES) | cpio --quiet -Hcrc -o | gzip -9) > $@

loader.po: *.c
	xgettext --default-domain=loader --add-comments \
		--keyword=_ --keyword=N_ *.c

tr/%.tr: ../po/%.po loader.po
	msgmerge $< loader.po | ./simplemot > $@

dirs:
	for n in . $(DIRS); do \
	    [ "$$n" = "." ] || make "DIET=$(DIET)" -C $$n ;\
	done

install: all
	mkdir -p $(DESTDIR)/$(RUNTIMEDIR)/loader
	for n in $(BINS); do \
	    install -m 755 $$n $(DESTDIR)/$(RUNTIMEDIR)/loader; \
	    strip $(DESTDIR)/$(RUNTIMEDIR)/loader/$$n; \
	done
	install -m 644 loader.tr $(DESTDIR)/$(RUNTIMEDIR)/loader
	install -m 644 module-info $(DESTDIR)/$(RUNTIMEDIR)/loader
	install -m 644 kon.cfg $(DESTDIR)/$(RUNTIMEDIR)/loader
	install -m 644 minikon.fnt $(DESTDIR)/$(RUNTIMEDIR)/loader

urltest: urltest.o ftp.o urls.o lang.o log.o windows.o
	$(CC) -g -o urltest urltest.o -lnewt ftp.o urls.o lang.o log.o windows.o -lz $(ISYS) -lresolv

loader: loader.o $(OBJS) $(NETOBJS)
	$(CC) -g $(STATIC) -o $@ $^ -lpopt     \
	-lkudzu_loader $(ISYS) ../balkan/libbalkan.a \
	$(MODULELINKAGE) $(GUNZIP) \
	-lpump $(NEWTLIB) $(SLANGLIB) $(LOADERLIBS) $(KONOBJS)

loader-local: loader-local.o $(OBJS)
	$(CC) -g $(STATIC) -o $@ $^ -lpopt     \
	-lkudzu_loader $(ISYS) ../balkan/libbalkan.a \
	$(MODULELINKAGE) $(GUNZIP) \
        -L ../stubs $(NEWTLIB) $(SLANGLIB) $(LOADERLIBS) $(KONOBJS)

loader-network: loader-net.o $(OBJS) $(NETOBJS)
	$(CC) -g $(STATIC) -o $@ $^ -lpopt     \
	-lkudzu_loader $(ISYS) ../balkan/libbalkan.a \
	$(MODULELINKAGE) $(GUNZIP) \
        -lpump -L ../stubs $(NEWTLIB) $(SLANGLIB) $(LOADERLIBS) $(KONOBJS)

loader-pcmcia: loader-pcmcia.o pcmcia.o popen.o $(OBJS) $(PCMCIAOBJS)
	$(CC) -g $(STATIC) -o $@ loader-pcmcia.o $(OBJS) \
	    $(PCMCIAOBJS) -lcardmgr_loader -lprobe_loader popen.o \
        -lpopt     \
        -lkudzu_loader $(ISYS) ../balkan/libbalkan.a \
	$(MODULELINKAGE) $(GUNZIP) \
        -lpump -lresolv $(NEWTLIB) $(SLANGLIB) $(LOADERLIBS) $(KONOBJS)

loader.o: loader.c
	$(CC) -DINCLUDE_LOCAL -DINCLUDE_NETWORK $(CFLAGS) -o $@ -c $<

loader-local.o: loader.c
	$(CC) -DINCLUDE_LOCAL $(CFLAGS) -o $@ -c $<

loader-net.o: loader.c
	$(CC) -DINCLUDE_NETWORK $(CFLAGS) -o $@ -c $<

loader-pcmcia.o: loader.c
	$(CC) -DINCLUDE_PCMCIA -DINCLUDE_LOCAL -DINCLUDE_NETWORK \
	    $(CFLAGS) -o $@ -c $<

init: init.o $(MINILIBC)
	$(REALCC) $(STATIC) $(COPTS) $(LDFLAGS) -o $@ init.o $(MINILIBC)

init.o: init.c 
	$(REALCC) -O2 $(COPTS) -c -o init.o init.c

minilibc.o: minilibc.c
	$(REALCC) -O2 $(COPTS) -c -o minilibc.o minilibc.c

mkctype: mkctype.c
	$(REALCC) $(COPTS) -o mkctype mkctype.c

ctype.c: mkctype
	./mkctype > ctype.c

clean: 
	rm -f *.o .depend *~ loader-local loader-network loader.old \
	      loader-pcmcia probe modprobe loader.po loader.tr tr/*.tr \
	      loader init ctype.c mkctype
	for n in $(DIRS); do \
	    (cd $$n; make clean) \
	done

depend:
	$(CPP) $(CFLAGS) -DHAVE_CONFIG_H -M $(SOURCES) > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif