summaryrefslogtreecommitdiff
path: root/Makefile
blob: 66b831c5b363df12c6b305defcb32862c2c8bc03 (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
## -----------------------------------------------------------------------
##  $Id$
##
##   Copyright 1998 H. Peter Anvin - All Rights Reserved
##
##   This program is free software; you can redistribute it and/or modify
##   it under the terms of the GNU General Public License as published by
##   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
##   USA; either version 2 of the License, or (at your option) any later
##   version; incorporated herein by reference.
##
## -----------------------------------------------------------------------

#
# Main Makefile for SYSLINUX
#

NASM	= nasm
CC	= gcc
CFLAGS	= -Wall -O2 -fomit-frame-pointer
LDFLAGS	= -O2 -s

BINDIR  = /usr/bin

VERSION = $(shell cat version)

.c.o:
	$(CC) $(CFLAGS) -c $<

#
# The BTARGET refers to objects that are derived from ldlinux.asm; we
# like to keep those uniform for debugging reasons; however, distributors 
# want to recompile the installers (ITARGET).
#
SOURCES = ldlinux.asm syslinux.asm syslinux.c copybs.asm
BTARGET = bootsect.bin ldlinux.sys ldlinux.bin ldlinux.lst
ITARGET = syslinux.com syslinux copybs.com
DOCS    = COPYING NEWS README TODO *.doc
OTHER   = Makefile bin2c.pl now.pl genstupid.pl keytab-lilo.pl version \
	  sys2ansi.pl

all:	$(BTARGET) $(ITARGET)
	ls -l $(BTARGET) $(ITARGET)

installer: $(ITARGET)
	ls -l $(BTARGET) $(ITARGET)

# The DATE is set on the make command line when building binaries for
# official release.  Otherwise, substitute a hex string that is pretty much
# guaranteed to be unique to be unique from build to build.
ifndef HEXDATE
HEXDATE := $(shell perl now.pl ldlinux.asm)
endif
ifndef DATE
DATE    := $(HEXDATE)
endif

ldlinux.bin: ldlinux.asm
	$(NASM) -f bin -dVERSION="'$(VERSION)'" -dDATE_STR="'$(DATE)'" -dHEXDATE="$(HEXDATE)" -l ldlinux.lst -o ldlinux.bin ldlinux.asm
	perl genstupid.pl < ldlinux.lst

bootsect.bin: ldlinux.bin
	dd if=ldlinux.bin of=bootsect.bin bs=512 count=1

ldlinux.sys: ldlinux.bin
	dd if=ldlinux.bin of=ldlinux.sys  bs=512 skip=1

syslinux.com: syslinux.asm bootsect.bin ldlinux.sys stupid.inc
	$(NASM) -f bin -l syslinux.lst -o syslinux.com syslinux.asm

copybs.com: copybs.asm
	$(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm

bootsect_bin.c: bootsect.bin bin2c.pl
	perl bin2c.pl bootsect < bootsect.bin > bootsect_bin.c

ldlinux_bin.c: ldlinux.sys bin2c.pl
	perl bin2c.pl ldlinux < ldlinux.sys > ldlinux_bin.c

syslinux: syslinux.o bootsect_bin.o ldlinux_bin.o stupid.o
	$(CC) $(LDFLAGS) -o syslinux \
		syslinux.o bootsect_bin.o ldlinux_bin.o stupid.o

ldlinux.lst: ldlinux.bin
	: Generated by side effect

stupid.c: ldlinux.lst genstupid.pl
	perl genstupid.pl < ldlinux.lst

stupid.inc: stupid.c
	: Generated by side effect

stupid.o: stupid.c

install: all
	install -c syslinux $(BINDIR)

tidy:
	rm -f syslinux.lst copybs.lst *.o *_bin.c stupid.*

clean: tidy
	rm -f $(ITARGET)

spotless: clean
	rm -f $(BTARGET)

dist: tidy
	rm -f *~ \#*

#
# This should only be used by the maintainer to generate official binaries
# for release.  Please do not "make official" and distribute the binaries,
# please.
#
.PHONY: official release

official:
	$(MAKE) spotless
	$(MAKE) all DATE=`date +'%Y-%m-%d'`
	$(MAKE) dist

release:
	-rm -rf release/syslinux-$(VERSION)
	-rm -f release/syslinux-$(VERSION).*
	mkdir -p release/syslinux-$(VERSION)
	cp $(SOURCES) $(DOCS) $(OTHER) release/syslinux-$(VERSION)
	make -C release/syslinux-$(VERSION) official
	cd release ; tar cvvf - syslinux-$(VERSION) | \
		gzip -9 > syslinux-$(VERSION).tar.gz
	cd release/syslinux-$(VERSION) ; \
		zip -9r ../syslinux-$(VERSION).zip *


PREREL    := syslinux-$(VERSION)-$(DATE)
PRERELDIR := release/syslinux-$(VERSION)-prerel
 
prerel:
	mkdir -p $(PRERELDIR)
	-rm -rf $(PRERELDIR)/$(PREREL)
	-rm -f $(PRERELDIR)/$(PREREL).*
	mkdir -p $(PRERELDIR)/$(PREREL)
	cp $(SOURCES) $(DOCS) $(OTHER) $(PRERELDIR)/$(PREREL)
	make -C $(PRERELDIR)/$(PREREL) spotless
	make -C $(PRERELDIR)/$(PREREL) HEXDATE="$(DATE)"
	make -C $(PRERELDIR)/$(PREREL) dist
	cd $(PRERELDIR) && tar cvvf - $(PREREL) | \
		gzip -9 > $(PREREL).tar.gz 
	cd $(PRERELDIR) && uuencode $(PREREL).tar.gz $(PREREL).tar.gz > $(PREREL).uu
	cd $(PRERELDIR)/$(PREREL) && \
		zip -9r ../$(PREREL).zip *