Fix for use of dpkg-buildpackage -A
[rrq/maintain_lilo.git] / src / Makefile
index d1c142e3a58edf811a79d26df40286ad0fb963f0..9ac890a45cfdd6ce561d86e9fb2a8b03d628ae8f 100644 (file)
@@ -1,4 +1,11 @@
 # -*- makefile -*-
+#
+# Copyright 2009-2015 Joachim Wiedorn
+# All rights reserved.
+# 
+# Licensed under the terms contained in the file 'COPYING'
+# in the source directory.
+#
 
 # adding variables
 include ../make.vars
@@ -9,14 +16,13 @@ include ../make.vars
 
 SHELL=/bin/sh
 CC=gcc
-CPP=$(CC) -E
+CPP=$(CC) -E -P -ffreestanding
 AS86=as86 -0 -a
 LD86=ld86 -0
 NASM=nasm
 G=`cat foo1 foo2 | grep version | cut -d " " -f 3`
 
-CFLAGS=$(OPT) -Wall -g $(PCONFIG)
-LDFLAGS=#-Xlinker -qmagic
+CFLAGS=$(OPT) -Wall $(PCONFIG)
 LIBS=$(DEVMAPPER)
 
 OBJS=lilo.o raid.o map.o geometry.o boot.o device.o common.o bsect.o cfg.o \
@@ -24,7 +30,7 @@ OBJS=lilo.o raid.o map.o geometry.o boot.o device.o common.o bsect.o cfg.o \
 
 EDIT=edit.c common.o
 
-LIS=chain.lis disk.lis dparam.lis os2_d.lis first.lis second.lis \
+LIS=chain.lis disk.lis dparam.lis first.lis second.lis \
   bootsect.lis third.lis mbr.lis bitmap.lis pseudo.lis mbr2.lis \
   pseudo1.lis loader.lis pseudo3.lis
 BFILES=first.b second.b third.b bitmap.b chain.b mbr.b mbr2.b \
@@ -63,8 +69,8 @@ floppy1: disk.com bootsect.b
 floppy2: disk.b
        @echo
        @echo Creating Diagnostic Floppy 2.4
-       @make -C ../diagnose check
-       @make -C ../diagnose floppy
+       @$(MAKE) -C ../diagnose check
+       @$(MAKE) -C ../diagnose floppy
 
 diagnostic: ../test.img diag1.img diag2.img diag3.img
 
@@ -72,7 +78,7 @@ manpath:
        echo $(MAN_DIR)
 
 .c.o:
-               $(CC) -c $(CFLAGS) $*.c
+               $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
 
 .s.o:
                $(AS86) -w -l $*.lis -o $*.o $*.s
@@ -84,56 +90,55 @@ manpath:
                dd if=$*.img of=$*.b bs=32 skip=1
 
 edit:          $(EDIT)
-               $(CC) -Wall -s -O -DSTANDALONE -o edit $(EDIT) $(LDFLAGS)
+               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DSTANDALONE -o edit $(EDIT)
 
-loader.i:      mkloader first.b second.b third.b bitmap.b mbr.b \
-                       chain.b os2_d.b mbr2.b
+loader.i:      mkloader first.b second.b third.b bitmap.b mbr.b chain.b mbr2.b
                ./mkloader >loader.i
 
 disk.com:      disk.b
                cp disk.b disk.com
 
 disk.s:                disk.S read.S bdata.h biosdata.S lilo.h Makefile
-               $(CPP) -traditional $(PCONFIG) -o disk.s  disk.S
+               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -o disk.s  disk.S
 
 mbr.s:         mbr.S lilo.h Makefile
-               $(CPP) -traditional $(PCONFIG) -DMBR=0xafbbe760 \
+               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -DMBR=0xafbbe760 \
                        -o mbr.s  mbr.S
 
 mbr.b:         mbr.img
                dd if=$*.img of=$*.b bs=32 skip=49
 
 mbr2.s:                mbr.S lilo.h Makefile
-               $(CPP) -traditional $(PCONFIG) -DMBX=0x93c00848 \
+               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -DMBX=0x93c00848 \
                        -o mbr2.s  mbr.S
 
 mbr2.b: mbr2.img
        dd if=$*.img of=$*.b bs=32 skip=49
 
 bootsect.s: bootsect.S disk.b
-       $(CPP) -traditional $(PCONFIG) \
+       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
                -DSIZEDISKB=`wc -c <disk.b | sed "s/ //g"` \
                -o bootsect.s  bootsect.S
 
 pseudo1.s: bootsect.S pseudo.S disk.com
        cat bootsect.S pseudo.S >$(TMP).S
-       $(CPP) -traditional $(PCONFIG) \
+       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
                -DSIZEKRNL=`wc -c <disk.com | sed "s/ //g"` \
                -DSIZEDISKB=512 -o pseudo1.s $(TMP).S
        rm -f $(TMP).S
 
 pseudo2.s: bootsect.S pseudo.S
-       make -C ../diagnose all
+       $(MAKE) -C ../diagnose all
        cat bootsect.S pseudo.S >$(TMP).S
-       $(CPP) -traditional $(PCONFIG) \
+       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
                -DSIZEKRNL=`wc -c <../diagnose/test4.com | sed "s/ //g"` \
                -DSIZEDISKB=512 -o pseudo2.s $(TMP).S
        rm -f $(TMP).S
 
 pseudo3.s: bootsect.S pseudo.S
-       make -C ../diagnose all
+       $(MAKE) -C ../diagnose all
        cat bootsect.S pseudo.S >$(TMP).S
-       $(CPP) -traditional $(PCONFIG) \
+       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
                -DSIZEKRNL=`wc -c <../diagnose/test5.com | sed "s/ //g"` \
                -DSIZEDISKB=512 -o pseudo3.s $(TMP).S
        rm -f $(TMP).S
@@ -147,11 +152,11 @@ diag1.img:        disk.com pseudo1.b
        cat pseudo1.b disk.com >diag1.img
 
 diag2.img: pseudo2.b
-       make -C ../diagnose all
+       $(MAKE) -C ../diagnose all
        cat pseudo2.b ../diagnose/test4.com >diag2.img
 
 diag3.img: pseudo3.b
-       make -C ../diagnose all
+       $(MAKE) -C ../diagnose all
        cat pseudo3.b ../diagnose/test5.com >diag3.img
 
 flags.i:       ../test.img Makefile version $(CFILES) $(HFILES)
@@ -170,13 +175,13 @@ dparam.s: dparam.S
                cp -p dparam.S dparam.s
 
 lilo:          $(OBJS)
-               $(CC) -o lilo $(LDFLAGS) $(OBJS) $(LIBS)
+               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o lilo $(OBJS) $(LIBS)
 
 lilo.static:   $(OBJS)
-               $(CC) -o lilo.static -static $(LDFLAGS) $(OBJS) $(LIBS)
+               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o lilo.static -static $(OBJS) $(LIBS)
 
 common.s:      common.h
-               $(CPP) -C -traditional -DLILO_ASM -o common.s common.h
+               $(CPP) $(CPPFLAGS) -C -traditional -DLILO_ASM -o common.s common.h
 
 bitmap.o: bitmap.s common.s
 third.o: third.s common.s
@@ -185,28 +190,25 @@ first.o: first.s common.s
 chain.o: chain.s common.s
 
 first.s:       first.S lilo.h version.h Makefile
-               $(CPP) $(PCONFIG) -DFIRST=0x62177489 -o first.s first.S
+               $(CPP) $(CPPFLAGS) $(PCONFIG) -DFIRST=0x62177489 -o first.s first.S
 
 second.s:      second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
                        graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
-               $(CPP) $(PCONFIG) -DTEXT=0x9dd476ec second.S -o second.s
+               $(CPP) $(CPPFLAGS) $(PCONFIG) -DTEXT=0x9dd476ec second.S -o second.s
 
 third.s:       second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
                        graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
-               $(CPP) $(PCONFIG) -DMENU=0x2012a4a7 second.S -o third.s
+               $(CPP) $(CPPFLAGS) $(PCONFIG) -DMENU=0x2012a4a7 second.S -o third.s
 
 bitmap.s:      second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
                        graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
-               $(CPP) $(PCONFIG) -DBITMAP=0x2ece2fbe second.S -o bitmap.s
+               $(CPP) $(CPPFLAGS) $(PCONFIG) -DBITMAP=0x2ece2fbe second.S -o bitmap.s
 
 chain.s:       chain.S lilo.h version.h first.b Makefile
-               $(CPP) $(PCONFIG) -DCHAIN=0x536a7646 chain.S -o chain.s
-
-os2_d.s:       chain.S lilo.h version.h first.b Makefile
-               $(CPP) $(PCONFIG) chain.S -DDOS_D -o os2_d.s
+               $(CPP) $(CPPFLAGS) $(PCONFIG) -DCHAIN=0x536a7646 chain.S -o chain.s
 
 xxx.s:         chain.S lilo.h Makefile
-               $(CPP) chain.S -DXXX -o xxx.s
+               $(CPP) $(CPPFLAGS) chain.S -DXXX -o xxx.s
 
 $(OBJS):       Makefile
 
@@ -232,39 +234,38 @@ install:
          rm -f $$DESTDIR$(BOOT_DIR)/boot-text.b; rm -f $$DESTDIR$(BOOT_DIR)/boot-text.old; fi
        @if [ -f $$DESTDIR$(BOOT_DIR)/chain.b ]; then \
          mv $$DESTDIR$(BOOT_DIR)/chain.b $$DESTDIR$(BOOT_DIR)/chain.old; fi
-       @if [ -f $$DESTDIR$(BOOT_DIR)/os2_d.b ]; then \
-         mv $$DESTDIR$(BOOT_DIR)/os2_d.b $$DESTDIR$(BOOT_DIR)/os2_d.old; fi
        @if [ -f $$DESTDIR$(BOOT_DIR)/mbr.b ]; then \
          mv $$DESTDIR$(BOOT_DIR)/mbr.b $$DESTDIR$(BOOT_DIR)/mbr.old; fi
 
-       if [ -f os2_d.b -a  $(BUILTIN) -eq 0 ]; then cp os2_d.b $$DESTDIR$(BOOT_DIR); fi
        if [ -f chain.b -a  $(BUILTIN) -eq 0 ]; then cp chain.b $$DESTDIR$(BOOT_DIR); fi
        if [ -f mbr.b   -a  $(BUILTIN) -eq 0 ]; then cp mbr.b   $$DESTDIR$(BOOT_DIR); fi
        if [ -f diag1.img ]; then cp -f diag1.img $$DESTDIR$(BOOT_DIR); fi
        if [ -f diag2.img ]; then cp -f diag2.img $$DESTDIR$(BOOT_DIR); fi
 
+       strip lilo
        cp lilo $$DESTDIR$(SBIN_DIR)/lilo
-       strip $$DESTDIR$(SBIN_DIR)/lilo
+       if [ -f lilo.static ]; then \
+         strip lilo.static; \
+         cp lilo.static $$DESTDIR$(SBIN_DIR)/lilo.static; \
+       fi
        cp ../mkrescue $$DESTDIR$(USRSBIN_DIR)/mkrescue
        cp ../keytab-lilo.pl $$DESTDIR$(USRSBIN_DIR)/keytab-lilo
 
 dep:
        sed '/\#\#\# Dependencies/q' <Makefile >tmp_make
-       $(CPP) $(CFLAGS) -MM *.c >>tmp_make
+       $(CPP) $(CFLAGS) $(CPPFLAGS) -MM *.c >>tmp_make
        mv tmp_make Makefile
 
 version:       common.c lilo.h common.h
-       $(CC) $(CFLAGS) -DSHS_MAIN -o version common.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DSHS_MAIN -o version common.c
 
 mkloader:      temp.c
-       $(CC) $(CFLAGS) -DLILO_BINARY -o mkloader temp.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DLILO_BINARY -o mkloader temp.c
 
 
 tidy:
        rm -f core $(LIS) *.shs *.crc $(TMP)*
        rm -rf sbin boot usr
-       if [ -x lilo ]; then strip lilo; fi
-       if [ -x lilo.static ]; then strip lilo.static; fi
 
 clean:
        rm -f *.o *.s *.i *.img *.b tmp_make version
@@ -280,8 +281,6 @@ uninstall:
        rm -f $$DESTDIR$(BOOT_DIR)/diag1.img
        rm -f $$DESTDIR$(BOOT_DIR)/diag2.img
 
-       if [ -f $$DESTDIR$(BOOT_DIR)/os2_d.b ]; then \
-         rm -f $$DESTDIR$(BOOT_DIR)/os2_d.b; fi
        if [ -f $$DESTDIR$(BOOT_DIR)/chain.b ]; then \
          rm -f $$DESTDIR$(BOOT_DIR)/chain.b; fi
        if [ -f $$DESTDIR$(BOOT_DIR)/mbr.b ]; then \