TARGET_ARCH=-m32
ASM=nasm
CFLAGS=-masm=intel -Wall

mioboot: mioboot.asm
	$(ASM) -l $@.lst -o $@ $<

mioboot-nobios: mioboot-nobios.asm
	$(ASM) -l $@.lst -o $@ $<

mioboot-nobios-simple: mioboot-nobios-simple.asm
	$(ASM) -l $@.lst -o $@ $<


esercizio.o: esercizio.asm
	$(ASM) -felf $<

esercizio: esercizio.o

pthreads-pc rw rw-nosync rw-mutex rw-rlotto: LDFLAGS=-lpthread

pthreads-pc: pthreads-pc.c

fork-pc: fork-pc.c

tsl.o: tsl.asm
	$(ASM) -felf tsl.asm

tsl: tsl.o

enter.o: enter.asm
	$(ASM) -felf enter.asm

threads-tsl: threads-tsl.o enter.o

threads-tsl-new: threads-tsl-new.c

%.tex : %.nw
	noweave -delay -filter btdefn -index -filter "awk -f lst.awk|tee debug" $< > $@

%.c : %.nw
	notangle -R$@ -filter btdefn $< > $@

%.pdf : %.tex
	pdflatex $< && pdflatex $< && pdflatex $<

.PHONY: clean
clean:
	rm -f mioboot mioboot-nobios mioboot-nobios-simple *.lst *~ semantic.cache esegui forca
