Add support for automatic dependency generation
authorhpa <hpa>
Fri, 26 Apr 2002 05:32:14 +0000 (05:32 +0000)
committerhpa <hpa>
Fri, 26 Apr 2002 05:32:14 +0000 (05:32 +0000)
Makefile
isolinux.asm
ldlinux.asm
memdisk/Makefile
pxelinux.asm
syslinux.asm

index d276d99..b05b30a 100644 (file)
--- a/Makefile
+++ b/Makefile
 # Main Makefile for SYSLINUX
 #
 
-NASM   = nasm
-CC     = gcc
-CFLAGS = -Wall -O2 -fomit-frame-pointer
-LDFLAGS        = -O2 -s
+CC      = gcc
+INCLUDE  =
+CFLAGS  = -Wall -O2 -fomit-frame-pointer
+LDFLAGS         = -O2 -s
 
-BINDIR  = /usr/bin
-LIBDIR  = /usr/lib/syslinux
+NASM    = nasm
+NINCLUDE = 
+BINDIR   = /usr/bin
+LIBDIR   = /usr/lib/syslinux
 
-VERSION = $(shell cat version)
+VERSION  = $(shell cat version)
 
 .c.o:
-       $(CC) $(CFLAGS) -c $<
+       $(CC) $(INCLUDE) $(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 \
-         pxelinux.asm pxe.inc mbr.asm gethostip.c \
-         isolinux.asm
+CSRC    = syslinux.c gethostip.c
+NASMSRC  = ldlinux.asm syslinux.asm copybs.asm \
+         pxelinux.asm mbr.asm isolinux.asm
+SOURCES = $(CSRC) $(NASMSRC) *.inc
 BTARGET = ldlinux.bss ldlinux.sys ldlinux.bin ldlinux.lst \
          pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin
 ITARGET = syslinux.com syslinux copybs.com gethostip
@@ -162,13 +165,19 @@ dist: tidy
        done
 
 local-spotless:
-       rm -f $(BTARGET)
+       rm -f $(BTARGET) .depend
 
 spotless: local-clean dist local-spotless
        $(MAKE) -C sample spotless
        $(MAKE) -C memdisk spotless
 
-#
+.depend:
+       rm -f .depend
+       for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -M $$csrc >> .depend ; done
+       for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
+
 # Hook to add private Makefile targets for the maintainer.
-#
 -include Makefile.private
+
+# Include dependencies file
+-include .depend
index 6758869..0250a13 100644 (file)
@@ -155,9 +155,11 @@ vk_append: resb max_cmd_len+1      ; Command line
 vk_end:                equ $                   ; Should be <= vk_size
                endstruc
 
+%ifndef DEPEND
 %if (vk_end > vk_size) || (vk_size*max_vk > 65536)
 %error "Too many vkernels defined, reduce vk_power"
 %endif
+%endif
 
 ;
 ; Segment assignments in the bottom 640K
@@ -176,9 +178,11 @@ file_sector        resd 1                  ; Sector pointer (0 = structure free)
 file_left      resd 1                  ; Number of sectors left
                endstruc
 
+%ifndef DEPEND
 %if (open_file_t_size & (open_file_t_size-1))
 %error "open_file_t is not a power of 2"
 %endif
+%endif
 
 ;
 ; For our convenience: define macros for jump-over-unconditinal jumps
@@ -890,9 +894,11 @@ Stack              dw _start, 0            ; SS:SP for stack reset
 rl_checkpt     equ $                           ; Must be <= 800h
 
 rl_checkpt_off equ ($-$$)
+%ifndef DEPEND
 %if rl_checkpt_off > 0x800
 %error "Sector 0 overflow"
 %endif
+%endif
 
 ; ----------------------------------------------------------------------------
 ;  End of code and data that have to be in the first sector
@@ -4631,9 +4637,11 @@ BufSafe          dw trackbufsize/SECTORSIZE      ; Clusters we can load into trackbuf
 BufSafeSec     dw trackbufsize/SECTORSIZE      ; = how many sectors?
 BufSafeBytes   dw trackbufsize         ; = how many bytes?
 EndOfGetCBuf   dw getcbuf+trackbufsize ; = getcbuf+BufSafeBytes
+%ifndef DEPEND
 %if ( trackbufsize % SECTORSIZE ) != 0
 %error trackbufsize must be a multiple of SECTORSIZE
 %endif
+%endif
 
 ;
 ; Stuff for the command line; we do some trickery here with equ to avoid
@@ -4659,6 +4667,8 @@ getcbuf           equ (end_of_code + 511) & 0FE00h
 vgafontbuf     equ 0E000h
 
 ; This is a compile-time assert that we didn't run out of space
+%ifndef DEPEND
 %if (getcbuf+trackbufsize) > vgafontbuf
 %error "Out of memory, better reorganize something..."
 %endif
+%endif
index ff82e2e..8999ed5 100644 (file)
@@ -140,9 +140,11 @@ vk_append: resb max_cmd_len+1      ; Command line
 vk_end:                equ $                   ; Should be <= vk_size
                endstruc
 
+%ifndef DEPEND
 %if (vk_end > vk_size) || (vk_size*max_vk > 65536)
 %error "Too many vkernels defined, reduce vk_power"
 %endif
+%endif
 
 ;
 ; Segment assignments in the bottom 640K
@@ -745,9 +747,11 @@ bailmsg:   db 'Boot failed', 0Dh, 0Ah, 0
 bs_checkpt     equ $                   ; Must be <= 7DEFh
 
 bs_checkpt_off equ ($-$$)
+%ifndef DEPEND
 %if bs_checkpt_off > 1EFh
 %error "Boot sector overflow"
 %endif
+%endif
 
                zb 1EFh-($-$$)
 bs_magic       equ $                   ; From here to the magic_len equ
@@ -1057,9 +1061,11 @@ safedumpregs:
 rl_checkpt     equ $                           ; Must be <= 8000h
 
 rl_checkpt_off equ ($-$$)
+%ifndef DEPEND
 %if rl_checkpt_off > 400h
 %error "Sector 1 overflow"
 %endif
+%endif
 
 ; ----------------------------------------------------------------------------
 ;  End of code and data that have to be in the first sector
@@ -4435,6 +4441,8 @@ getcbuf           equ (end_of_code + 511) & 0FE00h
 vgafontbuf     equ 0E000h
 
 ; This is a compile-time assert that we didn't run out of space
+%ifndef DEPEND
 %if (getcbuf+trackbufsize) > vgafontbuf
 %error "Out of memory, better reorganize something..."
 %endif
+%endif
index deb95bd..cee164d 100644 (file)
 
 VERSION := $(shell cat ../version)
 
-CC      = gcc
-CFLAGS  = -Wall -O2 -fomit-frame-pointer -march=i386 \
-         -malign-functions=0 -malign-jumps=0 -malign-loops=0 \
-         -DVERSION='"$(VERSION)"' -DDATE='"$(DATE)"'
-LDFLAGS = 
-AS      = as
-LD     = ld
-NASM    = nasm
-OBJCOPY = objcopy
-PERL    = perl
+CC       = gcc
+CFLAGS   = -Wall -O2 -fomit-frame-pointer -march=i386 \
+          -malign-functions=0 -malign-jumps=0 -malign-loops=0 \
+          -DVERSION='"$(VERSION)"' -DDATE='"$(DATE)"'
+LDFLAGS  = 
+INCLUDE  =
+AS       = as
+LD      = ld
+NASM     = nasm
+NINCLUDE = 
+OBJCOPY  = objcopy
+PERL     = perl
 
 # Important: init.o16 must be first!!
-OBJS    = init.o16 setup.o16 msetup.o16 e820func.o16 conio.o16 memdisk.o
+OBJS     = init.o16 setup.o16 msetup.o16 e820func.o16 conio.o16 memdisk.o
+
+CSRC     = setup.c msetup.c e820func.c conio.c
+SSRC     = init.S16
+NASMSRC  = memdisk.asm
 
 all: memdisk e820test
 
@@ -37,7 +43,7 @@ clean: tidy
 
 # spotless also removes the product binary
 spotless: clean
-       rm -f memdisk
+       rm -f memdisk .depend
 
 %.o16: %.s16
        $(AS) -o $@ $<
@@ -46,22 +52,22 @@ spotless: clean
        echo '.code16gcc' | cat - $< > $@
 
 %.s: %.S
-       $(CC) -x c $(CFLAGS) -traditional -E -o $@ $<
+       $(CC) -x c $(INCLUDE) $(CFLAGS) -traditional -E -o $@ $<
 
 %.s16: %.S16
-       $(CC) -x c $(CFLAGS) -traditional -E -o $@ $<
+       $(CC) -x c $(INCLUDE) $(CFLAGS) -traditional -E -o $@ $<
 
 %.s: %.c
-       $(CC) $(CFLAGS) -S -o $@ $<
+       $(CC) $(INCLUDE) $(CFLAGS) -S -o $@ $<
 
 %.i: %.c
-       $(CC) $(CFLAGS) -E -o $@ $<
+       $(CC) $(INCLUDE) $(CFLAGS) -E -o $@ $<
 
 %.o: %.c
-       $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
 
 %.bin: %.asm
-       $(NASM) -f bin -o $@ -l $*.lst $<
+       $(NASM) -f bin $(NINCLUDE) -o $@ -l $*.lst $<
 
 memdisk.elf: $(OBJS)
        $(LD) -Ttext 0 -o $@ $^
@@ -75,3 +81,12 @@ e820test: e820func.o msetup.o e820test.o memdisk.o
 
 memdisk.o: memdisk.bin
        $(LD) -r -b binary -o $@ $<
+
+.depend:
+       rm -f .depend
+       for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -M $$csrc >> .depend ; done
+       for ssrc in $(SSRC) ; do $(CC) $(INCLUDE) -x c -traditional -M $$ssrc | sed -e 's/\.S16\.o/\.o16/' >> .depend ; done
+       for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
+
+# Include dependencies file
+include .depend
index d421cad..c68e0a4 100644 (file)
@@ -166,9 +166,11 @@ vk_append: resb max_cmd_len+1      ; Command line
 vk_end:                equ $                   ; Should be <= vk_size
                endstruc
 
+%ifndef DEPEND
 %if (vk_end > vk_size) || (vk_size*max_vk > 65536)
 %error "Too many vkernels defined, reduce vk_power"
 %endif
+%endif
 
 ;
 ; Segment assignments in the bottom 640K
@@ -216,9 +218,11 @@ tftp_filepos       resd 1                  ; Position within file
 tftp_filesize  resd 1                  ; Total file size
                endstruc
 
+%ifndef DEPEND
 %if (tftp_port_t_size & (tftp_port_t_size-1))
 %error "tftp_port_t is not a power of 2"
 %endif
+%endif
 
 ;
 ; For our convenience: define macros for jump-over-unconditinal jumps
@@ -5111,9 +5115,11 @@ BufSafe          dw trackbufsize/TFTP_BLOCKSIZE  ; Clusters we can load into trackbuf
 BufSafeSec     dw trackbufsize/512     ; = how many sectors?
 BufSafeBytes   dw trackbufsize         ; = how many bytes?
 EndOfGetCBuf   dw getcbuf+trackbufsize ; = getcbuf+BufSafeBytes
+%ifndef DEPEND
 %if ( trackbufsize % TFTP_BLOCKSIZE ) != 0
 %error trackbufsize must be a multiple of TFTP_BLOCKSIZE
 %endif
+%endif
 IPAppend       db 0                    ; Default IPAPPEND option
 DHCPMagic      db 0                    ; DHCP site-specific option info
 
@@ -5141,6 +5147,8 @@ getcbuf           equ (end_of_code + 511) & 0FE00h
 vgafontbuf     equ 0E000h
 
 ; This is a compile-time assert that we didn't run out of space
+%ifndef DEPEND
 %if (getcbuf+trackbufsize) > vgafontbuf
 %error "Out of memory, better reorganize something..."
 %endif
+%endif
index 7b9ec06..d0af292 100644 (file)
@@ -18,7 +18,7 @@
 ;      DOS installer for SYSLINUX
 ;
 
-               absolute 0
+                       absolute 0
 pspInt20:              resw 1
 pspNextParagraph:      resw 1
                        resb 1          ; reserved
@@ -443,9 +443,11 @@ die_common:
 ; This includes a small subroutine make_stupid to patch up the boot sector
 ; in case we give the -s (stupid) option
 ;
-               %include "stupid.inc"
+%ifndef DEPEND ; Generated file
+%include "stupid.inc"
+%endif
 
-               section .data
+                       section .data
 msg_error_sp:          db 'ERROR $'
 msg_colon:             db ': $'
 msg_error:             db 'ERROR: $'