Allow multiple mains in the makefile by building as a library
authorhpa <hpa>
Mon, 2 Feb 2004 08:58:35 +0000 (08:58 +0000)
committerhpa <hpa>
Mon, 2 Feb 2004 08:58:35 +0000 (08:58 +0000)
menu/Makefile
menu/README

index 4c35dbb..e782a4c 100644 (file)
@@ -1,44 +1,50 @@
-gcc_ok   = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \\r
-                  then echo $(1); else echo $(2); fi)\r
-\r
-M32     := $(call gcc_ok,-m32,)\r
-ALIGN   := $(call gcc_ok,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)\r
-\r
-CC     = gcc $(M32) -funsigned-char\r
-CFLAGS  = -g -W -Wall -march=i386 $(ALIGN) -Os\r
-AS      = as\r
-LD      = ld -m elf_i386\r
-OBJCOPY = objcopy\r
-\r
-.SUFFIXES: .c .s .s16 .o16 .elf .com\r
-\r
-.c.s:\r
-       $(CC) $(CFLAGS) -S -o $@ $<\r
-\r
-.s.s16:\r
-       echo '.code16gcc' | cat - $< > $@\r
-\r
-.s16.o16:\r
-       $(AS) -o $@ $<\r
-\r
-.elf.com:\r
-       $(OBJCOPY) -O binary $< $@\r
-\r
-\r
-all : menu.com\r
-\r
-menu.elf: startup.o16 main.o16 biosio.o16 string.o16 menu.o16 syslinux.o16\r
-       $(LD) -T com16.ld -o $@ $^\r
-\r
-startup.s16: startup.S16\r
-       $(CC) $(CFLAGS) -x assembler-with-cpp -E -o $@ $<\r
-\r
-clean:\r
-       -rm -f *.s *.s16 *.o16 *.elf *.com\r
-\r
-spotless: clean\r
-       -rm -f *~ \#*\r
-\r
-distclean: spotless\r
-       -rm -f main.c\r
-\r
+gcc_ok   = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
+                  then echo $(1); else echo $(2); fi)
+
+M32     := $(call gcc_ok,-m32,)
+ALIGN   := $(call gcc_ok,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)
+
+CC     = gcc $(M32) -funsigned-char
+CFLAGS  = -g -W -Wall -march=i386 $(ALIGN) -Os
+AR      = ar
+AS      = as
+LD      = ld -m elf_i386
+OBJCOPY = objcopy
+RANLIB  = ranlib
+
+LIBMENU = biosio.o16 string.o16 menu.o16 syslinux.o16
+
+MENUS   = simple.com complex.com
+
+.SUFFIXES: .c .s .s16 .o16 .elf .com
+
+.c.s:
+       $(CC) $(CFLAGS) -S -o $@ $<
+
+.s.s16:
+       echo '.code16gcc' | cat - $< > $@
+
+.s16.o16:
+       $(AS) -o $@ $<
+
+.elf.com:
+       $(OBJCOPY) -O binary $< $@
+
+%.elf: %.o16 startup.o16 com16.ld libmenu.a
+       $(LD) -T com16.ld -o $@ startup.o16 $< libmenu.a
+
+all : $(MENUS)
+
+startup.s16: startup.S16
+       $(CC) $(CFLAGS) -x assembler-with-cpp -E -o $@ $<
+
+libmenu.a: $(LIBMENU)
+       -rm -f $@
+       $(AR) cq $@ $^
+       $(RANLIB) $@
+
+clean:
+       -rm -f *.s *.s16 *.o16 *.elf *.com *.a
+
+spotless: clean
+       -rm -f *~ \#*
index 5014978..6f7110d 100644 (file)
@@ -4,9 +4,11 @@
 This is a menu system written by Murali Krishnan Ganapathy and ported
 from OpenWatcom to gcc by HPA.
 
-To configure the menus, you need to set up main.c to have the menu
-items you desire, then build the menu system using make.  You can use
-either simple.c or complex.c as a starting point for your own main.c.
+To configure the menus, you need to set up a menu configuration file
+to have the menu items you desire, then build the menu system using
+make.  You can use either simple.c or complex.c as a starting point
+for your own menu configuration file; then add the name with a .com
+extension to the MENUS list in the Makefile.
 
 The resulting code runs both under DOS as well as SYSLINUX.
 Currently, menu items, submenus and checkboxes are supported.