# 1. edit you OS if you want.... OS=LINUX #OS=BEOS #OS=FREEBSD #OS=OPENBSD #OS=QNX #OS=ATHEOS #OS=W32 ** please use a separate make.bat for W9x ** #OS=NETBSD # Set this to gzexe or upx if you want compression # COMPRESS=gzexe # 2. edit dest dir prefix if you want.... PREFIX='/usr/local' #PREFIX=/boot/home # 3. for vi friends only (else leave as is): # choice between '/bin/ex' or default '/bin/sed' EXMODE=SED #EXMODE=EX BINDIR='$(PREFIX)/bin' MANSEC='1' MANDIR='$(PREFIX)/man/man$(MANSEC)' #______________________do not edit below line________________________ ASOURCES=e3.asm e3.h AFLAGS = -w+orphan-labels -f elf # this fixes a nasty NASM version conflict # NASM 0.98.08 claims to use -O2 by default, but does not. # NASM 0.98 does not know the -O2 switch # ASVER := $(shell nasm -r) ifeq ($(ASVER),NASM version 0.98) NASM=nasm else NASM=nasm -O2 endif all: e3 e3: $(ASOURCES) Makefile ifeq ($(OS),LINUX) echo $(ASVER) $(NASM) -f bin -l e3.lst -o e3 e3.asm -DCRIPLED_ELF=1 -D$(OS) -D$(EXMODE) chmod +x e3 ifeq ($(COMPRESS),upx) if which upx > /dev/null 2>&1 ; then \ upx -q -q -q -k -9 e3 ; \ fi ; endif ifeq ($(COMPRESS),gzexe) if which gzexe > /dev/null 2>&1 ; then gzexe e3; fi; endif else echo $(ASVER) $(NASM) $(AFLAGS) -o e3.o e3.asm -l e3.lst -D$(OS) -D$(EXMODE) ifeq ($(OS),QNX) ld -s -o e3 e3.o -lc else ld -s -o e3 e3.o endif strip --remove-section .comment e3 endif ln -sf e3 e3ws ln -sf e3 e3em ln -sf e3 e3pi ln -sf e3 e3vi ln -sf e3 e3ne # next three are for testing purpose: linking w libc statc: $(NASM) $(AFLAGS) -o e3.o e3.asm -l e3.lst -D$(OS) -DLIBC -D$(EXMODE) ld -s -static -o e3statc e3.o -lc dync: $(NASM) $(AFLAGS) -o e3.o e3.asm -l e3.lst -D$(OS) -DLIBC -DDYN -D$(EXMODE) gcc e3.o -o e3dync # strip e3dync dync2: ifeq ($(OS),LINUX) $(NASM) $(AFLAGS) -o e3.o e3.asm -l e3.lst -D$(OS) -DLIBC -DDYN -D$(EXMODE) ld -s -m elf_i386 -o e3dync2 e3.o \ -lc -dynamic-linker /lib/ld-linux.so.2 \ /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o else $(NASM) $(AFLAGS) -o e3.o e3.asm -l e3.lst -D$(OS) -DLIBC -DDYN -D$(EXMODE) ld -m elf_i386 -o e3dync2 e3.o -lc -e _start /usr/lib/crt1.o endif # next for running in gnu debugger debug: $(ASOURCES) Makefile $(NASM) $(AFLAGS) -g -o e3.o e3.asm -l e3.lst -D$(OS) -D$(EXMODE) ld -s -o e3 e3.o strip --remove-section .comment e3 ln -sf e3 e3ws ln -sf e3 e3em ln -sf e3 e3pi ln -sf e3 e3vi ln -sf e3 e3ne # L I N U X only # Experimental stuff for using YASM assembler # needs some sed changes (jmp vs jmp near) due heavy bugs in YASM optimizer # (how to switch off that optimizer ?) yasm: $(ASOURCES) Makefile cat e3.asm | sed -f e3_nasm_yasm.sed \ | yasm -f elf -p nasm $(AFLAGS) -l e3.lstyasm -o e3.o -DLINUX -DSED -DYASM ld -s -o e3 e3.o ln -sf e3 e3ws ln -sf e3 e3em ln -sf e3 e3pi ln -sf e3 e3vi ln -sf e3 e3ne # L I N U X / AMD-64 only # ditto YASM stuff yasm64: $(ASOURCES) Makefile cat e3.asm | sed -f e3_nasm_yasm.sed \ | sed -f e3_yasm_yasm64.sed \ | yasm -m amd64 -f elf -p nasm $(AFLAGS) -l e3.lstyasm64 -o e3.o -DLINUX -DSED -DYASM -DAMD64 ld -s -o e3 e3.o ln -sf e3 e3ws ln -sf e3 e3em ln -sf e3 e3pi ln -sf e3 e3vi ln -sf e3 e3ne # next for cross asm for the ELKS people elks: nasm -w+orphan-labels -f as86 -o e3-16.o e3-16.asm -l e3-16.lst -D AS86 -D ELKS ld86 -0 -s -i -H 0xF800 -o e3-16 e3-16.o # next two for cross asm testing w32lst: $(NASM) -f coff -o e3.oW32 e3.asm -l e3.lstW32 -DW32 rm e3.oW32 qnxlst: $(NASM) -f elf -o e3.oQNX e3.asm -l e3.lstQNX -DQNX rm e3.oQNX # next for release maintainance man2html: rman -f HTML e3.man >e3.html install: e3 ifeq ($(OS),QNX) cp ./e3 $(BINDIR)/e3 ln -sf $(BINDIR)/e3 $(BINDIR)/e3ws ln -sf $(BINDIR)/e3 $(BINDIR)/e3em ln -sf $(BINDIR)/e3 $(BINDIR)/e3pi ln -sf $(BINDIR)/e3 $(BINDIR)/e3vi ln -sf $(BINDIR)/e3 $(BINDIR)/e3ne else install -d $(PREFIX) $(BINDIR) $(MANDIR) install -m 755 e3 $(BINDIR) ln -sf $(BINDIR)/e3 $(BINDIR)/e3ws ln -sf $(BINDIR)/e3 $(BINDIR)/e3em ln -sf $(BINDIR)/e3 $(BINDIR)/e3pi ln -sf $(BINDIR)/e3 $(BINDIR)/e3vi ln -sf $(BINDIR)/e3 $(BINDIR)/e3ne install -m 644 e3.man $(MANDIR)/e3.$(MANSEC) endif armlinux: e3 @cd armlinux && make all clean: rm -f e3*.o e3*.lst e3 e3em e3pi e3vi e3ws e3ne *~ \ PIPE_IN e3test~ e3test e3dync e3dync2 e3statc \ armlinux/*.o armlinux/e3arm