Makefile (3093B)
1 # 08jan13abu 2 # (c) Software Lab. Alexander Burger 3 4 .SILENT: 5 6 bin = ../bin 7 lib = ../lib 8 9 ifeq ($(MAKECMDGOALS), x86-64.linux) 10 UNAME = Linux 11 MACHINE = x86_64 12 else 13 ifeq ($(MAKECMDGOALS), x86-64.freeBsd) 14 UNAME = FreeBSD 15 MACHINE = x86_64 16 else 17 ifeq ($(MAKECMDGOALS), x86-64.sunOs) 18 UNAME = SunOS 19 MACHINE = x86_64 20 else 21 ifeq ($(MAKECMDGOALS), ppc64.linux) 22 UNAME = Linux 23 MACHINE = ppc64 24 else 25 UNAME = $(shell uname) 26 ifeq ($(MAKECMDGOALS), emu) 27 MACHINE = emu 28 else 29 MACHINE = $(shell uname -m) 30 endif 31 endif 32 endif 33 endif 34 endif 35 36 SYS = 37 FMT = .c 38 ARCH = emu 39 STRIP = : 40 41 ifeq ($(UNAME), Linux) 42 OS = Linux 43 ifeq ($(MACHINE), x86_64) 44 SYS = .linux 45 FMT = .s 46 ARCH = x86-64 47 AS = as 48 else 49 ifeq ($(MACHINE), ppc64) 50 SYS = .linux 51 FMT = .s 52 ARCH = ppc64 53 AS = as -mppc64 -a64 54 endif 55 endif 56 LD-MAIN = -Wl,--no-as-needed -rdynamic -lc -lm -ldl 57 LD-SHARED = -shared -export-dynamic 58 STRIP = strip 59 else 60 ifeq ($(UNAME), FreeBSD) 61 OS = FreeBSD 62 SYS = .freeBsd 63 FMT = .s 64 ARCH = x86-64 65 AS = as 66 LD-MAIN = -Wl,--no-as-needed -rdynamic -lc -lm 67 LD-SHARED = -shared -rdynamic 68 STRIP = strip 69 else 70 ifeq ($(UNAME), SunOS) 71 OS = SunOS 72 SYS = .sunOs 73 FMT = .s 74 ARCH = x86-64 75 AS = gas --64 76 LD-MAIN = -m64 -lc -lm -ldl -lsocket -lnsl 77 LD-SHARED = -m64 -shared 78 STRIP = strip 79 else 80 ifeq ($(UNAME), Darwin) 81 OS = Darwin 82 LD-MAIN = -lc -lm -ldl 83 LD-SHARED = -dynamiclib -undefined dynamic_lookup 84 STRIP = strip -x 85 endif 86 endif 87 endif 88 endif 89 90 baseFiles = version.l glob.l main.l \ 91 gc.l apply.l flow.l sym.l subr.l big.l io.l db.l net.l err.l 92 93 sFiles = \ 94 $(ARCH)$(SYS).base$(FMT) \ 95 $(ARCH)$(SYS).ext$(FMT) \ 96 $(ARCH)$(SYS).ht$(FMT) 97 98 all: picolisp 99 100 x86-64.linux: $(sFiles) 101 x86-64.freeBsd: $(sFiles) 102 x86-64.sunOs: $(sFiles) 103 ppc64.linux: $(sFiles) 104 emu: picolisp 105 106 picolisp: $(bin)/picolisp $(lib)/ext $(lib)/ht 107 108 ### Link ### 109 $(bin)/picolisp: $(ARCH)$(SYS).base.o 110 $(CC) -o $(bin)/picolisp $(ARCH)$(SYS).base.o $(LD-MAIN) 111 $(STRIP) $(bin)/picolisp 112 113 $(lib)/ext: $(ARCH)$(SYS).ext.o 114 $(CC) -o $(lib)/ext $(ARCH)$(SYS).ext.o $(LD-SHARED) 115 $(STRIP) $(lib)/ext 116 117 $(lib)/ht: $(ARCH)$(SYS).ht.o 118 $(CC) -o $(lib)/ht $(ARCH)$(SYS).ht.o $(LD-SHARED) 119 $(STRIP) $(lib)/ht 120 121 ### Assemble ### 122 .s.o: 123 $(AS) -o $*.o $*.s 124 125 ### Compile ### 126 sysdefs: sysdefs.c 127 $(CC) -o sysdefs -D_FILE_OFFSET_BITS=64 sysdefs.c 128 $(STRIP) sysdefs 129 130 emu.base.o: sysdefs emu.base.c 131 $(CC) -c -O -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 emu.base.c 132 133 .c.o: 134 $(CC) -c -O -fpic -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 $*.c 135 136 ### Translate ### 137 $(ARCH)$(SYS).base$(FMT): arch/$(ARCH).l $(baseFiles) sys/$(ARCH)$(SYS).code.l 138 ./mkAsm $(ARCH) "$(SYS)" $(FMT) $(OS) base "" $(lib)/map $(baseFiles) sys/$(ARCH)$(SYS).code.l 139 140 $(ARCH)$(SYS).ext$(FMT): arch/$(ARCH).l ext.l $(ARCH)$(SYS).base$(FMT) 141 ./mkAsm $(ARCH) "$(SYS)" $(FMT) $(OS) ext T "" ext.l 142 143 $(ARCH)$(SYS).ht$(FMT): arch/$(ARCH).l ht.l $(ARCH)$(SYS).base$(FMT) 144 ./mkAsm $(ARCH) "$(SYS)" $(FMT) $(OS) ht T "" ht.l 145 146 ### Clean up ### 147 clean: 148 rm -f emu.*.c *.s *.o *.symtab sysdefs 149 150 # vi:noet:ts=4:sw=4